* don't assert that the child process doesn't crash
* don't give a false negative on warnings printed to stderr
Also fix getSdk from the same file in the same way
Regressed in 2006add8496c47804ee3b6c562f420871cb4ea0a.
References to native_darwin_sdk are no longer kept in the frontend.
Instead the darwin SDK is detected as part of NativePaths and as part of
LibCInstallation.
The `null` value here was missed in
0a4d4eb252a73555a568a532902951a13284d2ef. I hope it is the cause of the
CI failures on Windows.
The fact that libc++ depends on libc is not important for the CLI and
Compilation.create already handles that logic.
This can be null in two cases right now:
1. Windows DLLs that zig ships such as advapi32.
2. extern "foo" fn declarations where we find out about libraries too late
TODO: make this non-optional and resolve those two cases somehow.
chicken out and make -l match the status quo behavior, where it looks
for dynamic libraries and then falls back to static libraries.
library resolution is still done in the CLI now though, and these
options are added:
-search_static_first Search for static libs in all library search
paths, then dynamic libs.
-search_dylibs_only Only search for dynamic libs.
-search_static_only Only search for static libs.
this matches the already existing options below:
-search_paths_first For each library search path, check for dynamic
lib then static lib before proceeding to next path.
-search_dylibs_first Search for dynamic libs in all library search
So, it is still possible to get the strict behavior by passing
`-search_dylibs_only` or `-search_static_only`.
This commit also makes -dynamic and -static affect the preferred link
mode and search strategy.
Putting them in both causes collisions because the same lib ends up
being linked in twice.
Putting them in positionals instead of libs makes their properties about
needed and weak being ignored.
First, system_libs are collected into a list. This is the same as
before.
Next, system_libs are filtered into external_system_libs, which is the
same list but without any libc, compiler_rt, etc.
At this point, if there are any external system libs, native library
directory paths are detected and added to lib_dirs.
Finally, extern_system_libs are filtered into resolved_system_libs,
which has full paths to all of the libraries. This is the list passed
into Compilation.
This makes the required changes noted by @ifreund in the code review for
this branch.
Before, we would end up with the LLVM_LIBRARIES variable containing,
for example, "-lLLVMAnalysis;-lz" and the Zig compiler CLI would be
stuck with ambiguous library names. In this branch, that ambiguity is
not allowed; it will look for a dynamically linked LLVMAnalysis and fail
to find it in the case that the build of LLVM is static.
With this change, LLVM_LIBRARIES will contain, for example,
"/full/path/to/libLLVMAnalysis.a;-lz" and it is unambiguous that the
first library should be linked statically and the second dynamically.
In the case of a dynamically linked system LLVM, it will look like
"/full/path/to/libLLVM.so;-lz" which again is fully unambiguous.
This fixes building Zig from source.
search_strategy is no longer passed to Compilation at all; instead it is
used in the CLI code only.
When using Zig CLI mode, `-l` no longer has the ability to link
statically; use positional arguments for this.
The CLI has a small abstraction around library resolution handling which
is used to remove some code duplication regarding static libraries, as
well as handle the difference between zig cc CLI mode and zig CLI mode.
Thanks to this, system libraries are now included in the cache hash, and
thus changes to them will correctly cause cache misses.
In the future, lib_dirs should no longer be passed to Compilation at
all, because it is a frontend-only concept.
Previously, -search_paths_first and -search_dylibs_first were
Darwin-only arguments; they now work the same for all targets. Same
thing with --sysroot.
Improved the error reporting for failure to find a system library. An
example error now looks like this:
```
$ zig build-exe test.zig -lfoo -L. -L/a -target x86_64-macos --sysroot /home/andy/local
error: unable to find Dynamic system library 'foo' using strategy 'no_fallback'. search paths:
./libfoo.tbd
./libfoo.dylib
./libfoo.so
/home/andy/local/a/libfoo.tbd
/home/andy/local/a/libfoo.dylib
/home/andy/local/a/libfoo.so
/a/libfoo.tbd
/a/libfoo.dylib
/a/libfoo.so
```
closes#14963
This was discussed in #16597. It makes sense for most of the functions
in this file to be marked inline: many are simple helper functions so
inlining is likely a strict win, and having the return values be
comptime-known may improve userspace code in some cases by preventing it
from unintentionally checking properties of the target at runtime.
This changeset is somewhat conservative: the functions marked inline are
generally returning booleans or simple integers, and many are simple
one-line checks.
Reverts 4fa8cc736966544da381c90a6111158179fc550b. This check was added
because it depended on C++ code, but after
77b96231a6bc195cc482d05599e8c20ee01645a6, this functionality no longer
depends on C++ code.
Without duping, users could get some unexpected behavior if they used a
string with a lifetime that didn't persist throughout the full build,
i.e. if it wasn't heap allocated, or if it was explicitly freed.
* Replaces the exit assembly with the function from std.
* Reads the top-of-stack struct at program startup that can get information
like the pid.
* Changes the read and write functions to use the Pread and Pwrite syscalls
instead of the depreciated _READ and _WRITE
* Changes the openat function to use flags instead of perms.
Plan9 does not support perms when opening, just when creating.
* Adds an errstr function to read the errstr buf created by the kernel
Implements issue #6451.
This was needed to support allocation on Plan 9 and now other operating
systems like DOS can also use it.
It is a modified version of the WasmAllocator since wasm also uses a
sbrk-esque allocation system.
This commit also adds the necessary system bits for sbrk to work on plan 9.
This solves the nuance case of compiling hand-crafted assembly files
which do not feature `MH_SUBSECTIONS_VIA_SYMBOLS` flag resulting in
input `Atom`s encompassing multiple symbols each with unique unwind
information.