It is now possible to force linking with system linker `ld` instead
of the LLVM `lld` linker when building natively on the target. This
can be done at each stage by specifying `--system-linker-hack` flag,
and can be useful on platforms where `lld` fails to operate properly
such as macOS 11 Big Sur on ARM64 where every binary/dylib is expected
to be codesigned.
Some example invocations for each stage of compilation of Zig
toolchain:
```
cmake .. -DCMAKE_PREFIX_PATH=/path/to/llvm -DSYSTEM_LINKER_HACK=1
```
```
build/zig build test --system-linker-hack
```
```
build/zig build --prefix $(pwd)/stage2 -Denable-llvm
--system-linker-hack
```
```
build/zig build-exe hello.zig --system-linker-hack
```
mimics the duplication of strings in `Builder` for `Pkg`. This
ensures the lifetime of the memory backing strings in a `Pkg`
struct and the `Pkg.dependencies` slice is not shorter than the
`Builder` that the data is associated with.
Before this it was trying to copy all the files from the zig-cache dir
to the output dir, but in the current compiler architecture the cache
dir is also used for internal compiler files.
See #6552#6553#6483
Also fixes a regression introduced in
1d777e99588be047ec4d7650f048b043d6e52da0 of not converting an integer to
a string for a command line parameter.
This is convenient for debugging purposes, as well as simplifying the
caching system since executable basenames will not conflict with their
corresponding object files.
* Don't try to generate C header files yet since it will only cause a
crash saying the feature is unimplemented.
* Rename the CLI options for release modes to use the `-O` prefix to
match C compiler precedent. Options are now `-ODebug`,
`-OReleaseFast`, `-OReleaseSafe`, `-OReleaseSmall`. The optimization
mode matches the enum tags of std.builtin.Mode. It is planned to, at
some point, rename std.builtin.Mode to std.builtin.OptimizationMode
and modify the tags to be lower case to match the style convention.
- Update build.zig code to support this new CLI.
* update std.zig.binNameAlloc to support an optional Version and update
the implementation to correctly deal with dynamic library version
suffixes.
As part of this:
* add std.process.cleanExit. closes#6395
- use it in several places
* adjust the alignment of text in `zig build --help` menu
* Cache: support the concept of "unhit" so that we properly keep track
of the cache when we find out using the secondary hash that the cache
"hit" was actually a miss. Use this to fix false negatives of caching
of stage1 build artifacts.
* fix not deleting the symlink hash for stage1 build artifacts causing
false positives.
* implement support for Package arguments in stage1 build artifacts
* update and add missing usage text
* add --override-lib-dir and --enable-cache CLI options
- `--enable-cache` takes the place of `--cache on`
* CLI supports -femit-bin=foo combined with --enable-cache to do an
"update file" operation. --enable-cache without that argument
will build the output into a cache directory and then print the path
to stdout (matching master branch behavior).
* errors surfacing from main() now print "error: Foo" instead of
"error: error.Foo".
This commit changes the behavior of stage1 to emit libfoo.so instead
of libfoo.so.0.0.0 when none of the --ver-major, --ver-minor, or
--ver-patch flags are set.
It also makes it possible to create unversioned shared libraries
using the zig build system, changing the version parameter of
addSharedLibrary() to a tagged union.