15928 Commits

Author SHA1 Message Date
Jakub Konka
8317dbd1cb macos: detect SDK path and version, then pass to the linker
Since we are already detecting the path to the native SDK,
if available, also fetch SDK's version and route that to the linker.
The linker can then use it to correctly populate LC_BUILD_VERSION
load command.
2021-11-26 16:26:44 +01:00
Jakub Konka
02d8ca71f9 macos: always use Zig shipped libc headers when no native SDK
If Zig didn't detect native SDK, always use shipped libc headers
when targeting macOS.
2021-11-26 12:44:49 +01:00
Jakub Konka
a2c546fea3 Merge branch 'mattnite-build-obj-no-link' 2021-11-26 10:54:16 +01:00
Jakub Konka
d6f43a1eac bpf: do not invoke lld when linking eBPF relocatables
Due to a deficiency in LLD, we need to special-case BPF to a simple
file copy when generating relocatables. Normally, we would expect
`lld -r` to work. However, because LLD wants to resolve BPF relocations
which it shouldn't, it fails before even generating the relocatable.

Co-authored-by: Matthew Knight <mattnite@protonmail.com>
2021-11-26 10:53:30 +01:00
Jakub Konka
a96b6ad83f Merge branch 'build-obj-no-link' of git://github.com/mattnite/zig into mattnite-build-obj-no-link 2021-11-26 10:45:16 +01:00
Fabio Arnold
da7baf7dae
std.mem.indexOfPos should return start_index when needle length is zero (#10220)
Closes #10216
2021-11-25 20:56:38 -05:00
Andrew Kelley
b891ee1f23 mingw-w64: add glu32 def files
closes #9372
2021-11-25 18:41:07 -07:00
Andrew Kelley
67b201982b stage1: fix exporting enums
After extern enums were removed, stage1 was left in an incorrect state
of checking for `extern enum` for exported enums. This commit fixes it
to look for an explicit integer tag type instead, and adds test coverage
for the compile error case as well as the success case.

closes #9498
2021-11-25 18:20:39 -07:00
Andrew Kelley
7b78b4fff0 stage2: better error message when copying artifacts fails 2021-11-25 17:43:27 -07:00
Jakub Konka
2006add849
Merge pull request #10215 from ziglang/macos-versions
Ship versioned libc headers on macOS
2021-11-26 01:08:16 +01:00
joachimschmidt557
9177f5c17b stage2 RISCV64: remove MCValue.compare_flags_(un)signed
These status flags do not exist in the RISCV architecture
2021-11-25 14:46:52 -08:00
Jakub Konka
a041401256 libstd: fix bug in std.Thread.Futex selecting incorrect default macOS version 2021-11-25 22:20:32 +01:00
Jakub Konka
3a3576da60 Version libSystem shipped with zig toolchain
We will mimick the same solution as with the headers:
* `libSystem.10.tbd`
* `libSystem.11.tbd`
* `libSystem.12.tbd`

and so on...
2021-11-25 17:10:08 +01:00
Jakub Konka
4270f234db Skip detecting native libc dirs on darwin
This is handled before by detecting and adding SDK path which
is a centralised point for the native libc installation on darwin.
2021-11-25 12:19:16 +01:00
Jakub Konka
1954cdc106 Autofetch macOS SDK if native target on macOS only
This means that I am purposefully regressing linking iOS and related
which will require manual specification of the sysroot path, etc.
2021-11-25 12:19:16 +01:00
Jakub Konka
c42439dff9 Pass inferred cpu_arch to defaultVersionRange
This is mainly because arm64 macOS doesn't support all
versions supported by x86_64 macOS. This is just a temporary
thing until both architectures support the same set of OSes.
2021-11-25 12:19:16 +01:00
Jakub Konka
42a351e099 infer and match macos sdk version for libc headers 2021-11-25 12:19:16 +01:00
Jakub Konka
2dcfa486fe add libc headers for all supported macOS versions
`fetch-them-macos-headers` gitrev
7036517cc6a9aa154e7aef4c4593b5c4a5143ed4
2021-11-25 12:19:16 +01:00
Andrew Kelley
c9352ef9d6 stage2: fix logic for default -femit-implib path
Previously when using `--enable-cache` and creating a Windows DLL,
without overriding the `-femit-implib` option, Zig would incorrectly
dump the .lib file to the current working directory, rather than
outputting it into the artifact directory, next to the .dll file.

Fixed.
2021-11-24 23:09:27 -07:00
Andrew Kelley
078a7ff198 Cache: add debug log statement 2021-11-24 23:08:37 -07:00
Andrew Kelley
6b87f0dc56 build system: add --debug-log advanced option to build runner 2021-11-24 23:08:16 -07:00
Andrew Kelley
b560f46c87 stage2: fix unwrap function call with optional pointer return value 2021-11-24 22:44:33 -07:00
tjohnes
a130eac785 zig fmt: fix formatting for single-line containers with comments
* Fixes #8810.
* Prevent a single-line container declaration if it contains a comment
  or multiline string.
* If a container declaration cannot be single-line, ensure container
  fields are rendered with a trailing comma.
* If `Space.comma` is passed to `renderExpressionComma` or
  `renderTokenComma`, and there already exists a comma in the source,
  then render one comma instead of two.
2021-11-24 18:45:09 -08:00
Andrew Kelley
36c8adf589
Merge pull request #10073 from hoanga/haiku-support-build2
more haiku support
2021-11-24 18:42:30 -08:00
Andrew Kelley
e266ede6e3 stage2: fix cleanup code for @import errors
When adding test coverage, I noticed an inconsistency in which source
location the compile error was pointing to for `@embedFile` errors vs
`@import` errors. They now both point to the same place, the string
operand.

closes #9404
closes #9939
2021-11-24 19:10:58 -07:00
Andrew Kelley
0581756453
Merge pull request #9347 from kkartaltepe/implib-support
Coff linker: Add IMPLIB support
2021-11-24 17:47:56 -08:00
Andrew Kelley
20cc7af8e6 stage2: support LLD -O flags on ELF
In 7e23b3245a9bf6e002009e6c18c10a9995671afa I made -O flags to the
linker emit a warning that the argument does nothing. That was not
correct however; LLD does have some logic that does different things
depending on -O0, -O1, and -O2. It defaults to -O1, and it does less
optimizations with -O0 and more with -O2.

With this commit, e.g. `-Wl,-O1` is supported by the `zig cc` frontend,
and by default we pass `-O0` to LLD in debug mode, and `-O3` in release
modes.

I also fixed a bug in the LLD ELF linker line which was incorrectly
passing `-O` flags instead of `--lto-O` flags for LTO.
2021-11-24 18:46:32 -07:00
Andrew Kelley
27c5c7fb23 stage2: proper -femit-implib frontend support
* Improve the logic for determining whether emitting an import lib is
   eligible, and improve the error message when the user provides
   contradictory arguments.
 * Integrate with the EmitLoc / Emit system that already exists, and use
   the `-femit-implib[=path]`/`-fno-emit-implib` convention that already
   exists.
 * Proper integration with the caching system.
 * CLI: fix bug in error reporting for resolving EmitLoc values for
   other parameters.
2021-11-24 18:12:56 -07:00
Andrew Kelley
7e23b3245a stage2: remove extra_lld_args
This mechanism for sending arbitrary linker args to LLD has no place in
the Zig frontend, because our goal is for the frontend to understand all
the arguments and not treat linker args like a black box.

For example we have self-hosted linking in addition to LLD, so we want to
have the options make sense to both linking codepaths, not just the LLD one.

Passing -O linker args will now result in a warning that the arg does
nothing.
2021-11-24 17:14:20 -07:00
Kurt Kartaltepe
fd369bcb0b Coff Linker: Pass extra lld args
Previously these were added to the hash but not actually appended to the
linker arguments.
2021-11-24 17:14:20 -07:00
Kurt Kartaltepe
a950cb42bd Coff linker: Add IMPLIB support
Allow --out-implib and -implib as passed by cmake and meson to be
correctly passed through to the linker to generate import libraries.
2021-11-24 17:14:20 -07:00
Andrew Kelley
fdcac5ecbd stage2: add cleanup logic for EmbedFile
It was never implemented, leading to a memory leak that was caught when
test coverage for the compile error was added.
2021-11-24 16:58:01 -07:00
Andrew Kelley
02b8d88153 stage2: add test coverage for @embedFile outside package path
closes #6662
2021-11-24 14:57:13 -07:00
Andrew Kelley
c42763f8cc AstGen: use reachableExpr for return operand
Related: #9630
2021-11-24 14:47:33 -07:00
Andrew Kelley
57e1f6a89f
Merge pull request #10166 from Scibuild/master
C backend: errors and optionals
2021-11-23 15:55:55 -05:00
Andrew Kelley
7ee02b5e70 C backend: avoid branching multiple times on AIR tag
for cmp_eq and cmp_neq.
2021-11-23 13:54:08 -07:00
Scibuild
2e15a404e2 C backend: errors and optionals
* bitcast treats all pointers as pointers
 * correctly unwrapping error unions with pointers
 * equality operators for primitive optional types
2021-11-23 13:46:56 -07:00
Marc Tiehuis
8f1e417757 std/math: add ldexp and make scalbn an alias
We assume we are compiled on a base-2 radix floating point system. This
is a reasonable assumption. musl libc as an example also assumes this.

We implement scalbn as an alias for ldexp, since ldexp is defined as 2
regardless of the float radix. This is opposite to musl which defines
scalbn in terms of ldexp.

Closes #9799.
2021-11-23 14:47:01 -05:00
Andrew Kelley
8e6c038dd8
Merge pull request #10208 from ziglang/zld-frameworks
zld: resolve frameworks in BFS order and handle additional macOS flags
2021-11-23 13:52:44 -05:00
Hiroaki Nakamura
f5c0c0803f
Merge pull request #10151 from hnakamur/zig
io_uring: adds link_timeout
2021-11-23 12:32:25 -06:00
Jakub Konka
0c1d610015 zld: handle -current_version and -compatibility_version
and transfer them correctly to the generated dylib as part of the dylib
id load command.
2021-11-23 15:59:49 +01:00
Jakub Konka
de8e612455 zld: resolve frameworks in BFS order
Handle clang's linker flag `-weak_framework` as a standard framework to
link. This requires further investigation especially to do with weak
imports and how to tie one with the other.
2021-11-23 12:59:58 +01:00
Andrew Kelley
e08b6149ab Sema: fix alignment of type-inferred locals 2021-11-22 20:30:20 -07:00
Andrew Kelley
e8b9942873 add more alignment behavior test coverage 2021-11-22 20:12:19 -07:00
Andrew Kelley
af1a5751d9
Merge pull request #10165 from jmc-88/cbe
CBE: add .optional_single_mut_pointer and .optional_single_const_pointer to Type.childType
2021-11-22 21:36:24 -05:00
Kirk Scheibelhut
065f40a3c5 stage1: improve packed struct array padding error message 2021-11-22 21:33:08 -05:00
Stephen von Takach
ed70f9981c
feat(uefi): add virtual addressing helpers (#10195)
based off definitions in https://uefi.org/sites/default/files/resources/UEFI%20Spec%202_6.pdf
2021-11-22 21:32:16 -05:00
Lewis Gaul
bc3e86c4b7 Add std.meta.Float, alongside std.meta.Int 2021-11-22 21:30:20 -05:00
Andrew Kelley
11330cbcc5
Merge pull request #10201 from Snektron/stage2-more-coercion
stage2: more in-memory coercion
2021-11-22 19:00:30 -05:00
Jakub Konka
691090f342 zld: parse ObjC ivars and eh_types in tapi v3 and v4 2021-11-22 18:01:15 +01:00