Skip to content

Commit f8b38a1

Browse files
committed
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!
1 parent 569182d commit f8b38a1

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ In this case, the only system dependency is a C compiler.
7070

7171
```
7272
cc -o bootstrap bootstrap.c
73-
./bootstrap build
73+
./bootstrap
7474
```
7575

76-
You 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
80-
compiler is missing these features:
76+
This 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
79+
therefore lacking these features:
8180
- Release mode optimizations
8281
- aarch64 machine code backend
8382
- `@cImport` / `zig translate-c`
@@ -86,14 +85,17 @@ 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)
9391
- [Automatic importlib file generation for Windows DLLs](https://github.com/ziglang/zig/issues/17753)
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

95+
However, a compiler built this way does provide a C backend, which may be
96+
useful for creating system packages of Zig projects using the system C
97+
toolchain. In such case, LLVM is not needed!
98+
9799
## Contributing
98100

99101
[Donate monthly](https://ziglang.org/zsf/).

bootstrap.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ static void run(char **argv) {
4242
if (WEXITSTATUS(status) != 0)
4343
panic("child process failed");
4444
}
45-
46-
static void run_execv(char **argv) {
47-
if (execv(argv[0], argv) == -1 && errno == ENOENT) return;
48-
perror("execv failed");
49-
}
5045
#endif
5146

5247
static void print_and_run(const char **argv) {
@@ -87,9 +82,6 @@ static const char *get_host_triple(void) {
8782
}
8883

8984
int 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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ git fetch --tags
2424
git clean -fd
2525
rm -rf zig-out
2626
cc -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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ git fetch --tags
2424
git clean -fd
2525
rm -rf zig-out
2626
cc -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

0 commit comments

Comments
 (0)