10327 Commits

Author SHA1 Message Date
Jakub Konka
3465203824 libc: add support for arm64 msvc installation 2022-11-03 15:07:31 +01:00
Andrew Kelley
57dbeb90af
Merge pull request #13396 from Luukdegram/fix-12880
llvm: mangle extern function names for Wasm target
2022-11-02 14:10:07 -04:00
Cody Tapscott
c22f17e15f stage2 llvm: Respect alignment for .union_init
Resolves #13232.
2022-11-02 12:45:06 +02:00
Joachim Schmidt
81c27677d4
Merge pull request #13404 from joachimschmidt557/stage2-aarch64
stage2 aarch64: enable printing test results in the test runner
2022-11-02 09:59:15 +01:00
Jakub Konka
ebf9ffd342 cli: set sysroot when --sysroot option was passed
Fixes regression introduced in 0b47e69b7c
2022-11-01 23:11:29 +01:00
joachimschmidt557
3051fab97c
stage2 AArch64: misc fixes, enable printing in test runner
- Fixed missing airRetPtr implementation
- Fixed wrong pop_regs order
- Fixed wrong source and destination register in store
2022-11-01 20:44:18 +01:00
joachimschmidt557
4e0779813b
stage2 AArch64: add inline memset 2022-11-01 20:43:27 +01:00
joachimschmidt557
8a022d9c92
stage2 AArch64: implement wrap_errunion_{err,payload} 2022-11-01 20:43:27 +01:00
joachimschmidt557
3ecec50f0c
stage2 AArch64: implement basic switch statements 2022-11-01 20:43:27 +01:00
joachimschmidt557
d2a5a36cab
stage2 AArch64: implement min/max 2022-11-01 20:43:27 +01:00
Luuk de Gram
66bcc55e01
llvm: mangle extern Wasm functions
When Wasm extern functions contain the same name, but have a
different module name such as `extern "a"` vs `extern "b"` LLVM will
currently resolve the two functions to the same symbol. By mangling
the name of the symbol, we ensure the functions are resolved
seperately. We mangle the name by applying <name>|<module> where
module is also known as the library name.
2022-11-01 15:05:09 +01:00
Jacob Young
ff83296256 cbe: fix gcc warnings 2022-10-31 21:01:47 -04:00
Jacob Young
b945d3eb90 cbe: improve support for non-native float types
* Fix _start on aarch64.
 * Add fallbacks when a float type is unsupported.

Fixes #13357
2022-10-31 20:18:15 -04:00
Andrew Kelley
cbdc91eb1a stage2: fix compilation on 32-bit arm 2022-10-31 14:21:36 -07:00
Cody Tapscott
049e6025f2 stage2: Add explicit type qualifier to workaround #13366
Depending on how #13366 is resolved, this code should arguably have
been rejected with a compile error in the first place.
2022-10-31 13:13:11 -04:00
Cody Tapscott
6f2408aab8 link/MachO: Avoid depending on host PATH_MAX
Repeat of a4eb221b9 for the newly-synchronized zld code.

Restores ability to compile Zig for WASI.
2022-10-31 13:12:37 -04:00
Andrew Kelley
ef761c2cbc
Merge pull request #13360 from topolarity/comptime-bool-binops
Make `x and false` and `x or true` comptime-known
2022-10-30 22:11:44 -04:00
Andrew Kelley
d4f668b241
Merge pull request #13361 from jacobly0/while-cont-scope
AstGen: avoid access to capture defined in an inner scope from a continue expression
2022-10-30 21:44:07 -04:00
Andrew Kelley
30b8b29f88 re-apply "Fix C include files not being in whole cache (#11365)"
This reverts commit 06310e3d4eb47fed88b175891cb5865bb050f020, reapplying
commit a430630002bf02162ccbf8d3eb10fd73e490cefd.

I deeply apologize to @moosichu and those affected by this bug. The
original fix was actually fine. When I reverted it, I misremembered
how the Cache API works. I thought the fix was going to introduce
nondeterminism into the hash, but I forgot that the order of files in
the manifest doesn't actually matter when checking for a cache hit.

Actually, it does matter a little bit. This fix has a subtle downside
which is that it does introduce the possibility of false negatives when
checking for cache hits of 2+ iterations ago. For example, if the code
goes from "foo", to "bar", and then back to "foo", it may look like a
cache miss when it should have been a hit because 2 iterations ago the
code was the same. However, this is an uncommon use case, and all it
does is cause a bit of wasted time and disk space. That said, my
suggestion from earlier still applies and would be a nice follow-up
enhancement to this fix:

The proper solution to this is to, in whole cache mode, append the hash
inputs to some data structure, and then after the compilation is
complete, do some kind of sorting on the hash inputs so that they will
be the same order every time, then apply them in sequence. No lock on
the Cache object is needed for this scheme.

closes #11063
2022-10-30 17:04:09 -07:00
Andrew Kelley
9b54c9dee8 zig test: forward target CLI args to zig run when using -ofmt=c
Previously, if you used `zig test -ofmt=c -target foobar` then Zig would
try to compile the generated C code with the native target instead of
"foobar".

With this change, `--test-cmd` with e.g. QEMU still won't work, but at
least the binary will get compiled for the correct target.
2022-10-30 15:44:58 -07:00
Jacob Young
01d76d419e Sema: avoid comptime null unwrap
This avoids a crash analyzing check_comptime_control_flow.
2022-10-30 15:38:46 -04:00
Cody Tapscott
ca332f57f7 stage2: Make x and false/x or true comptime-known
Same as preceding change, but for stage2.
2022-10-30 12:38:08 -07:00
Jacob Young
5c3a486639 AstGen: avoid accessing value from inner scope
While continue expressions can access the capture, so ensure that it is
unwrapped in an outer scope.
2022-10-30 15:25:58 -04:00
Cody Tapscott
2f732deb3d stage1: Make x and false/x or true comptime-known
We need to be careful to respect side-effects/branching in these
cases, but otherwise this behaves very similarly to multiplication.
`lhs and rhs == false` if either lhs or rhs is comptime-known `false`,
just like `lhs * rhs == 0` if either lhs or rhs is comptime-known to
be zero.

Similar reasoning applies to `lhs or rhs`.
2022-10-30 12:21:37 -07:00
Loris Cro
d4487b6a2e autodoc: update to new func zir body structure
this is a hack meant to restore functionality for the upcoming release,
a proper analysis of the new zir structure is required to make a robust
change.
2022-10-30 17:17:34 +01:00
Jakub Konka
9b0c555db4 macho: fix regression in dead strip for x86_64
Correctly handle calculating encompassing atoms for local
relocations (`r_extern == 0`).
2022-10-30 10:49:00 +01:00
Jakub Konka
27bcd4ec79 macho: do not unnecessarily dupe sym names in resolver 2022-10-30 10:12:25 +01:00
Andrew Kelley
5f5a20ebaf
Merge pull request #13093 from jacobly0/backend-fixes
C backend fixes
2022-10-29 23:06:59 -04:00
Andrew Kelley
28dc208f65
Merge pull request #13082 from g-w1/unnamed-decls-and-relocs-p9
Plan9: Fix The Backend
2022-10-29 17:45:00 -04:00
Andrew Kelley
4cfeb9a541 glibc: fix race condition when building stubs
Before, the code for building glibc stubs used a special case of the
Cache API that did not add any file inputs, and did not use
writeManifest(). This is not really how the Cache API is designed to
work and it shows because there was a race condition.

This commit adds as an input file the abilists file that comes with
Zig's installation, which has the added benefit of making glibc stub
caching properly detect cache invalidation when the user decides to
overwrite their abilists file. This harmonizes with the rest of how Zig
works, which intentionally allows you to hack the installation files and
have it behave properly with the cache system.

Finally, because of having any file inputs, the normal API flow of the
Cache system can be used, eliminating the one place that used the Cache
API in a special way. In other words, it uses writeManifest() now and
properly obeys the cache hit/miss semantics.

closes #13160
2022-10-29 12:15:47 -07:00
Jacob Young
48a2783969 cbe: implement optional slice representation change 2022-10-29 05:58:41 -04:00
Andrew Kelley
c36eb4ede9
Merge pull request #13221 from topolarity/packed-mem
Introduce `std.mem.readPackedInt` and improve bitcasting of packed memory layouts
2022-10-28 21:15:16 -04:00
Andrew Kelley
84e0c148b1 CLI: report error when -fstage1 requested but not available 2022-10-28 15:30:04 -07:00
Evan Haas
c616141241 translate-c: Better support for division in macros
Perform C-style arithmetic conversions on operands to division operator
in macros

Closes #13162
2022-10-28 17:59:32 -04:00
Cody Tapscott
9d0a4b60e1 Value: Add @intCast in writeToPackedMemory for 32-bit targets 2022-10-28 08:41:04 -07:00
Cody Tapscott
3295fee911 stage2: Use mem.readPackedInt etc. for packed bitcasts
Packed memory has a well-defined layout that doesn't require
conversion from an integer to read from. Let's use it :-)

This change means that for bitcasting to/from a packed value that
is N layers deep, we no longer have to create N temporary big-ints
and perform N copies.

Other miscellaneous improvements:
  - Adds support for casting to packed enums and vectors
  - Fixes bitcasting to/from vectors outside of a packed struct
  - Adds a fast path for bitcasting <= u/i64
  - Fixes bug when bitcasting f80 which would clear following fields

This also changes the bitcast memory layout of exotic integers on
big-endian systems to match what's empirically observed on our targets.
Technically, this layout is not guaranteed by LLVM so we should probably
ban bitcasts that reveal these padding bits, but for now this is an
improvement.
2022-10-28 08:41:04 -07:00
Veikka Tuominen
6fc71835c3 value: properly hash null_value pointer
Closes #13325
2022-10-28 13:31:16 +03:00
Veikka Tuominen
c3b85e4e2f Sema: further enhance explanation of why expr is evaluated at comptime 2022-10-28 13:31:16 +03:00
Andrew Kelley
c389f8800b
Merge pull request #13290 from Vexu/generic-deletion-mitigation
Mitigate generic deletion bug
2022-10-28 01:04:00 -04:00
Andrew Kelley
2991e4a454
Merge pull request #13288 from Vexu/opt-slice
Optimize size of optional slices (+ some fixes)
2022-10-27 22:09:17 -04:00
InKryption
bc72ae5e4e Sema: Prevent coercion from tuple pointer to mutable slice.
Also fix some stdlib code affected by this.

Co-authored by: topolarity <topolarity@tapscott.me>
2022-10-27 22:00:47 -04:00
Andrew Kelley
1d1c7ae5de
Merge pull request #13257 from topolarity/ctype-fixes
stage 2: Update `CType` size/alignment
2022-10-27 21:15:22 -04:00
Veikka Tuominen
d03c47bf85 Sema: use runtime_value instead of creating allocs 2022-10-27 21:08:25 -04:00
Veikka Tuominen
648d34d8ea Sema: coerce zero-bit generic args are coerced properly
Closes #13307
2022-10-27 13:40:20 +03:00
Andrew Kelley
710e2e7f10 libcxx: only pass -DHAVE___CXA_THREAD_ATEXIT_IMPL for glibc
This definition communicates to libcxxabi that the libc will provide the
`__cxa_thread_atexit_impl` symbol. This is true for glibc but not
true for other libcs, such as musl.
2022-10-27 01:03:11 -04:00
Veikka Tuominen
b937a04560 Sema: check coerceInMemoryAllowed earlier in resolvePeerTypes
Closes #13310
2022-10-27 01:31:18 +03:00
Veikka Tuominen
f3a3fb3d88 llvm: pass optional slices like regular slices 2022-10-27 01:31:18 +03:00
Veikka Tuominen
595ccecd88 llvm: do not return undefined pointers from array_to_slice 2022-10-27 01:31:18 +03:00
Veikka Tuominen
d9fe5ba7f8 Sema: add error for too big packed struct 2022-10-27 01:31:18 +03:00
Veikka Tuominen
9dcfc829e6 Sema: fix some edge cases with error return traces and typeof blocks
Closes #13293
2022-10-27 01:31:18 +03:00