mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
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!
This commit is contained in:
parent
569182dbb2
commit
f8b38a174f
4 changed files with 13 additions and 20 deletions
16
README.md
16
README.md
|
|
@ -70,14 +70,13 @@ In this case, the only system dependency is a C compiler.
|
||||||
|
|
||||||
```
|
```
|
||||||
cc -o bootstrap bootstrap.c
|
cc -o bootstrap bootstrap.c
|
||||||
./bootstrap build
|
./bootstrap
|
||||||
```
|
```
|
||||||
|
|
||||||
You can pass any options to this that you would pass to `zig build` (see
|
This produces a `zig2` executable in the current working directory. This is a
|
||||||
`--help` for options).
|
"stage2" build of the compiler,
|
||||||
|
[without LLVM extensions](https://github.com/ziglang/zig/issues/16270), and is
|
||||||
[Without LLVM extensions](https://github.com/ziglang/zig/issues/16270), a Zig
|
therefore lacking these features:
|
||||||
compiler is missing these features:
|
|
||||||
- Release mode optimizations
|
- Release mode optimizations
|
||||||
- aarch64 machine code backend
|
- aarch64 machine code backend
|
||||||
- `@cImport` / `zig translate-c`
|
- `@cImport` / `zig translate-c`
|
||||||
|
|
@ -86,7 +85,6 @@ compiler is missing these features:
|
||||||
- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)
|
- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)
|
||||||
- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
|
- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
|
||||||
- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)
|
- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)
|
||||||
- [COFF linking](https://github.com/ziglang/zig/issues/17751)
|
|
||||||
- [Ability to output LLVM bitcode](https://github.com/ziglang/zig/issues/13265)
|
- [Ability to output LLVM bitcode](https://github.com/ziglang/zig/issues/13265)
|
||||||
- [Windows resource file compilation](https://github.com/ziglang/zig/issues/17752)
|
- [Windows resource file compilation](https://github.com/ziglang/zig/issues/17752)
|
||||||
- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)
|
- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)
|
||||||
|
|
@ -94,6 +92,10 @@ compiler is missing these features:
|
||||||
- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)
|
- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)
|
||||||
- Ability to compile C++, Objective-C, and Objective-C++ files
|
- Ability to compile C++, Objective-C, and Objective-C++ files
|
||||||
|
|
||||||
|
However, a compiler built this way does provide a C backend, which may be
|
||||||
|
useful for creating system packages of Zig projects using the system C
|
||||||
|
toolchain. In such case, LLVM is not needed!
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
[Donate monthly](https://ziglang.org/zsf/).
|
[Donate monthly](https://ziglang.org/zsf/).
|
||||||
|
|
|
||||||
11
bootstrap.c
11
bootstrap.c
|
|
@ -42,11 +42,6 @@ static void run(char **argv) {
|
||||||
if (WEXITSTATUS(status) != 0)
|
if (WEXITSTATUS(status) != 0)
|
||||||
panic("child process failed");
|
panic("child process failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_execv(char **argv) {
|
|
||||||
if (execv(argv[0], argv) == -1 && errno == ENOENT) return;
|
|
||||||
perror("execv failed");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void print_and_run(const char **argv) {
|
static void print_and_run(const char **argv) {
|
||||||
|
|
@ -87,9 +82,6 @@ static const char *get_host_triple(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
argv[0] = "./zig2";
|
|
||||||
run_execv(argv);
|
|
||||||
|
|
||||||
const char *cc = get_c_compiler();
|
const char *cc = get_c_compiler();
|
||||||
const char *host_triple = get_host_triple();
|
const char *host_triple = get_host_triple();
|
||||||
|
|
||||||
|
|
@ -188,7 +180,4 @@ int main(int argc, char **argv) {
|
||||||
};
|
};
|
||||||
print_and_run(child_argv);
|
print_and_run(child_argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
run_execv(argv);
|
|
||||||
panic("build script failed to create valid zig2 executable");
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ git fetch --tags
|
||||||
git clean -fd
|
git clean -fd
|
||||||
rm -rf zig-out
|
rm -rf zig-out
|
||||||
cc -o bootstrap bootstrap.c
|
cc -o bootstrap bootstrap.c
|
||||||
./bootstrap build -Dno-lib
|
./bootstrap
|
||||||
|
./zig2 build -Dno-lib
|
||||||
# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
|
# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
|
||||||
# ./zig-out/bin/zig test test/behavior.zig
|
# ./zig-out/bin/zig test test/behavior.zig
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ git fetch --tags
|
||||||
git clean -fd
|
git clean -fd
|
||||||
rm -rf zig-out
|
rm -rf zig-out
|
||||||
cc -o bootstrap bootstrap.c
|
cc -o bootstrap bootstrap.c
|
||||||
./bootstrap build -Dno-lib
|
./bootstrap
|
||||||
|
./zig2 build -Dno-lib
|
||||||
# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
|
# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
|
||||||
# ./zig-out/bin/zig test test/behavior.zig
|
# ./zig-out/bin/zig test test/behavior.zig
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue