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....@@ -70,14 +70,13 @@ In this case, the only system dependency is a C compiler.
7070
71```71```
72cc -o bootstrap bootstrap.c72cc -o bootstrap bootstrap.c
73./bootstrap build73./bootstrap
74```74```
7575
76You can pass any options to this that you would pass to `zig build` (see76This produces a `zig2` executable in the current working directory. This is a
77`--help` for options).77"stage2" build of the compiler,
7878[without LLVM extensions](https://github.com/ziglang/zig/issues/16270), and is
79[Without LLVM extensions](https://github.com/ziglang/zig/issues/16270), a Zig79therefore lacking these features:
80compiler is missing these features:
81- Release mode optimizations80- Release mode optimizations
82- aarch64 machine code backend81- aarch64 machine code backend
83- `@cImport` / `zig translate-c`82- `@cImport` / `zig translate-c`
...@@ -86,7 +85,6 @@ compiler is missing these features:...@@ -86,7 +85,6 @@ compiler is missing these features:
86- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)85- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)
87- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)86- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
88- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)87- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)
89- [COFF linking](https://github.com/ziglang/zig/issues/17751)
90- [Ability to output LLVM bitcode](https://github.com/ziglang/zig/issues/13265)88- [Ability to output LLVM bitcode](https://github.com/ziglang/zig/issues/13265)
91- [Windows resource file compilation](https://github.com/ziglang/zig/issues/17752)89- [Windows resource file compilation](https://github.com/ziglang/zig/issues/17752)
92- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)90- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)
...@@ -94,6 +92,10 @@ compiler is missing these features:...@@ -94,6 +92,10 @@ compiler is missing these features:
94- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)92- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)
95- Ability to compile C++, Objective-C, and Objective-C++ files93- 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
97## Contributing99## Contributing
98100
99[Donate monthly](https://ziglang.org/zsf/).101[Donate monthly](https://ziglang.org/zsf/).
bootstrap.c-11
...@@ -42,11 +42,6 @@ static void run(char **argv) {...@@ -42,11 +42,6 @@ static void run(char **argv) {
42 if (WEXITSTATUS(status) != 0)42 if (WEXITSTATUS(status) != 0)
43 panic("child process failed");43 panic("child process failed");
44}44}
45
46static void run_execv(char **argv) {
47 if (execv(argv[0], argv) == -1 && errno == ENOENT) return;
48 perror("execv failed");
49}
50#endif45#endif
5146
52static void print_and_run(const char **argv) {47static void print_and_run(const char **argv) {
...@@ -87,9 +82,6 @@ static const char *get_host_triple(void) {...@@ -87,9 +82,6 @@ static const char *get_host_triple(void) {
87}82}
8883
89int main(int argc, char **argv) {84int main(int argc, char **argv) {
90 argv[0] = "./zig2";
91 run_execv(argv);
92
93 const char *cc = get_c_compiler();85 const char *cc = get_c_compiler();
94 const char *host_triple = get_host_triple();86 const char *host_triple = get_host_triple();
9587
...@@ -188,7 +180,4 @@ int main(int argc, char **argv) {...@@ -188,7 +180,4 @@ int main(int argc, char **argv) {
188 };180 };
189 print_and_run(child_argv);181 print_and_run(child_argv);
190 }182 }
191
192 run_execv(argv);
193 panic("build script failed to create valid zig2 executable");
194}183}
ci/x86_64-linux-debug.sh+2-1
...@@ -24,7 +24,8 @@ git fetch --tags...@@ -24,7 +24,8 @@ git fetch --tags
24git clean -fd24git clean -fd
25rm -rf zig-out25rm -rf zig-out
26cc -o bootstrap bootstrap.c26cc -o bootstrap bootstrap.c
27./bootstrap build -Dno-lib27./bootstrap
28./zig2 build -Dno-lib
28# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.29# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
29# ./zig-out/bin/zig test test/behavior.zig30# ./zig-out/bin/zig test test/behavior.zig
3031
ci/x86_64-linux-release.sh+2-1
...@@ -24,7 +24,8 @@ git fetch --tags...@@ -24,7 +24,8 @@ git fetch --tags
24git clean -fd24git clean -fd
25rm -rf zig-out25rm -rf zig-out
26cc -o bootstrap bootstrap.c26cc -o bootstrap bootstrap.c
27./bootstrap build -Dno-lib27./bootstrap
28./zig2 build -Dno-lib
28# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.29# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
29# ./zig-out/bin/zig test test/behavior.zig30# ./zig-out/bin/zig test test/behavior.zig
3031