authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-13 14:30:21-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-14 02:17:51-05:00
logf8b38a174f0c4a843688fe8adac09dc4f66cd585
tree646d6157394480effbc44ef71717636a1511df71
parent569182dbb259b2b5cfb457e798407d8ec2eacc2d

adjust building from source without LLVM process

The idea here is that the zig2 executable is perhaps the more useful deliverable until we implement our own optimization passes. This will allow system packages to provide Zig, and use it to compile Zig projects, all without LLVM!

4 files changed, 13 insertions(+), 20 deletions(-)

README.md+9-7
......@@ -70,14 +70,13 @@ In this case, the only system dependency is a C compiler.
7070
7171```
7272cc -o bootstrap bootstrap.c
73./bootstrap build
73./bootstrap
7474```
7575
76You can pass any options to this that you would pass to `zig build` (see
77`--help` for options).
78
79[Without LLVM extensions](https://github.com/ziglang/zig/issues/16270), a Zig
80compiler is missing these features:
76This produces a `zig2` executable in the current working directory. This is a
77"stage2" build of the compiler,
78[without LLVM extensions](https://github.com/ziglang/zig/issues/16270), and is
79therefore lacking these features:
8180- Release mode optimizations
8281- aarch64 machine code backend
8382- `@cImport` / `zig translate-c`
......@@ -86,7 +85,6 @@ compiler is missing these features:
8685- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)
8786- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
8887- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)
89- [COFF linking](https://github.com/ziglang/zig/issues/17751)
9088- [Ability to output LLVM bitcode](https://github.com/ziglang/zig/issues/13265)
9189- [Windows resource file compilation](https://github.com/ziglang/zig/issues/17752)
9290- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)
......@@ -94,6 +92,10 @@ compiler is missing these features:
9492- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)
9593- Ability to compile C++, Objective-C, and Objective-C++ files
9694
95However, a compiler built this way does provide a C backend, which may be
96useful for creating system packages of Zig projects using the system C
97toolchain. In such case, LLVM is not needed!
98
9799## Contributing
98100
99101[Donate monthly](https://ziglang.org/zsf/).
bootstrap.c-11
......@@ -42,11 +42,6 @@ static void run(char **argv) {
4242 if (WEXITSTATUS(status) != 0)
4343 panic("child process failed");
4444}
45
46static void run_execv(char **argv) {
47 if (execv(argv[0], argv) == -1 && errno == ENOENT) return;
48 perror("execv failed");
49}
5045#endif
5146
5247static void print_and_run(const char **argv) {
......@@ -87,9 +82,6 @@ static const char *get_host_triple(void) {
8782}
8883
8984int main(int argc, char **argv) {
90 argv[0] = "./zig2";
91 run_execv(argv);
92
9385 const char *cc = get_c_compiler();
9486 const char *host_triple = get_host_triple();
9587
......@@ -188,7 +180,4 @@ int main(int argc, char **argv) {
188180 };
189181 print_and_run(child_argv);
190182 }
191
192 run_execv(argv);
193 panic("build script failed to create valid zig2 executable");
194183}
ci/x86_64-linux-debug.sh+2-1
......@@ -24,7 +24,8 @@ git fetch --tags
2424git clean -fd
2525rm -rf zig-out
2626cc -o bootstrap bootstrap.c
27./bootstrap build -Dno-lib
27./bootstrap
28./zig2 build -Dno-lib
2829# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
2930# ./zig-out/bin/zig test test/behavior.zig
3031
ci/x86_64-linux-release.sh+2-1
......@@ -24,7 +24,8 @@ git fetch --tags
2424git clean -fd
2525rm -rf zig-out
2626cc -o bootstrap bootstrap.c
27./bootstrap build -Dno-lib
27./bootstrap
28./zig2 build -Dno-lib
2829# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
2930# ./zig-out/bin/zig test test/behavior.zig
3031