25369 Commits

Author SHA1 Message Date
Andrew Kelley
67709b6382 Release 0.11.0 0.11.0 2023-08-03 11:22:03 -07:00
Krzysztof Wolicki
b317ca4d6f autodoc: Added line_comment tokens to ziglexer.js tokenizer 2023-08-03 19:07:33 +02:00
Andrew Kelley
c4e62be62e
Merge pull request #16058 from ziglang/frontend-lib-paths
compiler: resolve library paths in the frontend
2023-08-03 09:53:18 -07:00
Andrew Kelley
d0fd67cffe std.zig.system.NativePaths: remove bad framework dir
This path actually has nothing useful in it.
2023-08-03 09:52:15 -07:00
Jakub Konka
f96d773d98 macho: append syslibroot to search dirs when resolving libSystem 2023-08-03 09:52:15 -07:00
Andrew Kelley
72fb58f107 CLI: fix a typo that made static/dynamic do the opposite 2023-08-03 09:52:15 -07:00
Andrew Kelley
4923e64199 Compilation: detect sysroot from libc installation 2023-08-03 09:52:15 -07:00
Andrew Kelley
4089f96def darwin: pass -iframework to clang for system frameworks 2023-08-03 09:52:15 -07:00
Andrew Kelley
9dd9aa49a5 Compilation: fix incorrect non-optional assumption 2023-08-03 09:52:15 -07:00
Andrew Kelley
7360927afe CLI: add native paths only if ABI is also native 2023-08-03 09:52:15 -07:00
Andrew Kelley
c012f5d55d std.zig.system.darwin.isSdkInstalled: fix implementation
* 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
2023-08-03 09:52:15 -07:00
Andrew Kelley
e582a3642b std.zig.system.darwin: fix redundant names 2023-08-03 09:52:15 -07:00
Andrew Kelley
da91ef5c28 zig libc: restore functionality on macOS
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.
2023-08-03 09:52:15 -07:00
Andrew Kelley
c94bbebb91 std.zig.system.NativePaths: simplify and integrate with Darwin SDK 2023-08-03 09:52:15 -07:00
Andrew Kelley
ea0e6e737b CLI: reduce code size bloat
Make a bunch of ArrayList objects use arena instead of gpa, eliminating
the `defer` expressions, which reduces code size of zig1.wasm by 1%
2023-08-03 09:52:15 -07:00
Andrew Kelley
469af67804 CLI: delete redundant logic and use null instead of undef
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.
2023-08-03 09:52:15 -07:00
Andrew Kelley
d7e74f7cbf CI: fix path to output langref
Apparently tidy doesn't exit with failure status if the input file is
not found? wtf tidy
2023-08-03 09:52:15 -07:00
Andrew Kelley
6ce37845af build.zig: use InstallArtifact Options instead of mutation
I expect this to have no functional change.
2023-08-03 09:52:15 -07:00
Andrew Kelley
aef8bcf776 std.Build.Step.Compile: fine-grained system lib search control
For each library you can specify the preferred mode and search strategy.

The old way of setting global state is eliminated.
2023-08-03 09:52:15 -07:00
Andrew Kelley
a0e94ec576 CLI: add -search_paths_first_static to complete the API
There was no previous way to set preferred mode static, search strategy
paths_first.
2023-08-03 09:52:15 -07:00
Andrew Kelley
986a3d23ab frontend: make SystemLib.path optional
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.
2023-08-03 09:52:14 -07:00
Andrew Kelley
e565ff305a CLI: revert -l behavior
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.
2023-08-03 09:52:14 -07:00
Andrew Kelley
9e50f96087 MachO: put system_libs into libs not positionals
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.
2023-08-03 09:52:14 -07:00
Andrew Kelley
2725c20a72 coff: always link uuid.lib as part of mingw libc 2023-08-03 09:52:14 -07:00
Andrew Kelley
e477352af3 CLI: Windows: system DLLs no longer trigger native paths detection 2023-08-03 09:52:14 -07:00
Andrew Kelley
c65a061881 CLI: adjust order of operations of system libraries
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.
2023-08-03 09:52:14 -07:00
Andrew Kelley
256074428f frontend: update is_libc_lib_name for mingw-w64 crt files 2023-08-03 09:52:14 -07:00
Andrew Kelley
5c441f7f8a cmake: find LLVM libraries unambiguously
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.
2023-08-03 09:52:14 -07:00
Andrew Kelley
8e687cb0d9 CLI: remove --ambiguous-static-library
Reverts 6232e63ca4460a953ca8453a6f7583eb910e87c8, but keeps the usage
text cleanup.

Let's resist adding this as long as possible.
2023-08-03 09:52:14 -07:00
Andrew Kelley
89c605d140 CLI: add --ambiguous-static-library
I hate this, gonna revert it in the next commit
2023-08-03 09:52:14 -07:00
Andrew Kelley
a1e21ceec8 frontend: fix linking to Windows DLLs as system libs 2023-08-03 09:52:14 -07:00
Andrew Kelley
a08cc7d2ae compiler: resolve library paths in the frontend
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
2023-08-03 09:52:14 -07:00
Andrew Kelley
f887b02518
Merge pull request #16359 from g-w1/plan9-more-std
Plan 9: more standard library support
2023-08-03 09:41:20 -07:00
Fabio Arnold
31979b1006 Fix compile error in addVcpkgPaths 2023-08-03 09:37:26 -07:00
mlugg
88fb4dab81 std.target: mark helper functions inline
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.
2023-08-03 09:37:10 -07:00
Andrew Kelley
22662773b2 LibCInstallation: no longer depends on LLVM
Reverts 4fa8cc736966544da381c90a6111158179fc550b. This check was added
because it depended on C++ code, but after
77b96231a6bc195cc482d05599e8c20ee01645a6, this functionality no longer
depends on C++ code.
2023-08-03 02:58:08 -07:00
Andrew Kelley
e85a46cb84
Merge pull request #16656 from ziglang/issue-16628
macho: track unwind/dwarf cfi records by symbol rather than atom
2023-08-02 22:28:02 -07:00
Jacob Young
a61495a988 cmake: fix early issues when bootstrapping on mingw
This gets all the way to the final link, where `libssp` symbols are
undefined, referenced by `libzstd.a`.
2023-08-02 22:13:04 -07:00
Mitchell Hashimoto
76f7b40e15 build: dupe library, rpath, and framework LazyPaths
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.
2023-08-02 20:20:48 -07:00
Jacob Young
89d660c3eb Sema: improve new error messages related to naked functions
* pass a source location to all safety checks
 * add notes about what is disallowed in naked functions

Closes #16651
2023-08-02 16:12:30 -07:00
Jacob G-W
d0fbfd3c9f Plan 9: add more features to std.os.plan9
* 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
2023-08-02 18:19:07 -04:00
Jakub Konka
26adbf2cb7 macho: set first and last atom indexes to 0 when marking section for pruning 2023-08-03 00:12:30 +02:00
Jacob G-W
841b54f5e3 std: add SbrkAllocator and use it for Plan 9
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.
2023-08-02 17:39:52 -04:00
Jacob G-W
4d711e8edd Plan 9 linker: don't try to calculate the vaddr before we know it
Previously, this worked on small codebases, but it is not correct.
Unconditionally emitting a reloc fixes it (and it might be more performant).
2023-08-02 17:39:52 -04:00
Jacob G-W
b9aa1dcaf1 plan 9: filesystem support 2023-08-02 17:39:52 -04:00
Jacob G-W
6293a646e3 Plan9: support linking to external 'special' symbols 2023-08-02 17:39:52 -04:00
Jacob G-W
4d22bae27e langref: fix documentation for @extern 2023-08-02 17:39:52 -04:00
Jakub Konka
16f09127b5 link-test: add matching test case for unwind info when MH_SUBSECTIONS_VIA_SYMBOLS is not set 2023-08-02 22:12:26 +02:00
Jakub Konka
d6e095de2c macho: track unwind/dwarf cfi records by symbol rather than atom
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.
2023-08-02 21:45:33 +02:00
Adam Goertz
9e19969e09 Remove math.ln in favor of @log 2023-08-02 12:00:14 -07:00