15912 Commits

Author SHA1 Message Date
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
Jakub Konka
e17c4a497f zld: parse []TbdV3 before TbdV3 2021-11-22 18:01:15 +01:00
Jakub Konka
40e49fe2f0 zld: add missing Tbdv3 fields to the declarative struct 2021-11-22 18:01:15 +01:00
Stephen Gutekanst
9836f1b2f9
add support for compiling Objective-C++ code (#10096)
* add support for compiling Objective-C++ code

Prior to this change, calling `step.addCSourceFiles` with Obj-C++ file extensions
(`.mm`) would result in an error due to Zig not being aware of that extension.
Clang supports an `-ObjC++` compilation mode flag, but it was only possible to use
if you violated standards and renamed your `.mm` Obj-C++ files to `.m` (Obj-C) to
workaround Zig being unaware of the extension.

This change makes Zig aware of `.mm` files so they can be compiled, enabling compilation
of projects such as [Google's Dawn WebGPU](https://dawn.googlesource.com/dawn/) using
a `build.zig` file only.

Helps hexops/mach#21

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>

* test/standalone: add ObjC++ compilation/linking test

Based on the existing objc example, just tweaked for ObjC++.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-22 08:44:49 +01:00
Robin Voetter
2b589d71fb stage2: move some tests which are now passing 2021-11-22 04:36:57 +01:00
Andrew Kelley
722c6b9567
Merge pull request #10188 from Luukdegram/stage2-wasm-stack
stage2: wasm - implement the stack
2021-11-21 22:09:47 -05:00
Andrew Kelley
2991e3f66b ci: add coverage for building stage2 for arm-linux-musleabihf 2021-11-21 19:50:20 -07:00
Andrew Kelley
6afcaf4a08 stage2: fix the build for 32-bit architectures
* Introduce a mechanism into Sema for emitting a compile error when an
   integer is too big and we need it to fit into a usize.
 * Add `@intCast` where necessary
 * link/MachO: fix an unnecessary allocation when all that was happening
   was appending zeroes to an ArrayList.
 * Add `error.Overflow` as a possible error to some codepaths, allowing
   usage of `math.intCast`.

closes #9710
2021-11-21 19:43:08 -07:00
Robin Voetter
cb248898ab sema: error union in-memory coercion 2021-11-22 03:21:31 +01:00
Robin Voetter
83a0329c92 sema: move error set coercion to coerceInMemoryAlloed 2021-11-22 03:04:55 +01:00
Robin Voetter
41b37712ea sema: function (pointer) in-memory coercion 2021-11-22 03:04:55 +01:00
Andrew Kelley
96e5f661bd zig cc: add -fcolor-diagnostics and -fcaret-diagnostics integration
Closes #6290
2021-11-21 17:07:18 -07:00
Andrew Kelley
ceeb230c23 zig cc: add -ffunction-sections integration
Also update to latest LLVM 13 command line options.

See #6290
2021-11-21 17:01:07 -07:00
Trioct
b644d49365 Fix type error for u8 in writeIntSlice 2021-11-21 16:47:39 -05:00
J.C. Moyer
939f51aebb compiler_rt: export floorf, floor, and floorl
This fixes a stage1 linker error when compiling with VS2022 on Windows.
2021-11-21 16:44:21 -05:00
Dante Catalfamo
12140ead43 Change darwin c.VMIN -> c.V.MIN to match Linux 2021-11-21 16:43:16 -05:00