Commit Graph

31476 Commits

Author SHA1 Message Date
Andrew Kelley
65d42086ff CLI: dylibs provided by path act as inferred root module 2024-10-23 16:27:38 -07:00
Andrew Kelley
e2a71b37d8 fix MachO linking regression 2024-10-23 16:27:38 -07:00
Andrew Kelley
8cfe303da9 fix resolving link inputs 2024-10-23 16:27:38 -07:00
Andrew Kelley
7656903518 CLI: fix detection of link inputs 2024-10-23 16:27:38 -07:00
Andrew Kelley
861df93768 link.Elf: fix double free of header in parseDso 2024-10-23 16:27:38 -07:00
Andrew Kelley
e567abb339 rework linker inputs
* Compilation.objects changes to Compilation.link_inputs which stores
  objects, archives, windows resources, shared objects, and strings
  intended to be put directly into the dynamic section. Order is now
  preserved between all of these kinds of linker inputs. If it is
  determined the order does not matter for a particular kind of linker
  input, that item should be moved to a different array.
* rename system_libs to windows_libs
* untangle library lookup from CLI types
* when doing library lookup, instead of using access syscalls, go ahead
  and open the files and keep the handles around for passing to the
  cache system and the linker.
* during library lookup and cache file hashing, use positioned reads to
  avoid affecting the file seek position.
* library directories are opened in the CLI and converted to Directory
  objects, warnings emitted for those that cannot be opened.
2024-10-23 16:27:38 -07:00
Andrew Kelley
4706ec81d4 introduce a CLI flag to enable .so scripts; default off
The compiler defaults this value to off so that users whose system
shared libraries are all ELF files don't have to pay the cost of
checking every file to find out if it is a text file instead.

When a GNU ld script is encountered, the error message instructs users
about the CLI flag that will immediately solve their problem.
2024-10-23 16:27:38 -07:00
Andrew Kelley
5b016e290a move ld script processing to the frontend
along with the relevant logic, making the libraries within subject to
the same search criteria as all the other libraries.

this unfortunately means doing file system access on all .so files when
targeting ELF to determine if they are linker scripts, however, I have a
plan to address this.
2024-10-23 16:27:38 -07:00
Andrew Kelley
a4cc344aa0 std.Build.Step.Compile: add a way to expect an error message
other than a compile error, specifically
2024-10-23 16:27:38 -07:00
Andrew Kelley
1e785409bb move link.Elf.LdScript to link.LdScript 2024-10-23 16:27:38 -07:00
Andrew Kelley
028a9a1054 link.Elf.LdScript: eliminate dependency on Elf.File
this allows it to be used by the frontend
2024-10-23 16:27:38 -07:00
Andrew Kelley
33d07f4b6e
Merge pull request #21779 from ziglang/avoid-data-races
link.MachO: remove buggy multi-threading
2024-10-23 16:27:09 -07:00
Andrew Kelley
78f643c46d
Merge pull request #21758 from kcbanner/dll_storage_class
Add `is_dll_import` to @extern, to support `__declspec(dllimport)` with the MSVC ABI
2024-10-23 15:35:54 -07:00
Andrew Kelley
322d71139d link.MachO: remove buggy multi-threading
thread-sanitizer reports data races here when running test-link. I tried
only removing the ones that triggered races, but after 10 back and
forths with the compiler and tsan, I got impatient and removed all of
them.

next time, let's be sure the test suite runs tsan-clean before merging
any changes that add parallelism.

after this commit, `zig build test-link` completes without any tsan
warnings.

closes #21778
2024-10-23 14:08:03 -07:00
Andrew Kelley
d210f733f8 std.Progress: fix data race
In end(), the freelist pointer is owned so the bare store would be ok.
However, there is a load in start() that can happen at the same time, if
another start() and end() pair grabs that same index.

I don't think this fixes #21663 actually because even if the data race
corrupts the value for `next`, the cmpxchg protects the value from being
stored there.
2024-10-23 13:47:44 -07:00
Matthew Lugg
6bf52b0505
Merge pull request #21697 from mlugg/callconv
Replace `std.builtin.CallingConvention` with a tagged union, eliminating `@setAlignStack`
2024-10-23 16:48:33 +01:00
kcbanner
7edd69d8aa tests: add tests for is_dll_import externs
- tests/standalone/extern wasn't running its test step
- add compile error tests for thread local / dll import @extern in a comptime scope
2024-10-22 18:46:14 -04:00
kcbanner
b87fa93500 Change ExternOptions.dll_storage_class to is_dll_import
It wouldn't make sense to have passe `.export` here, and that was
in fact a compile error - so simply make this a bool instead.
2024-10-22 12:41:35 -04:00
kcbanner
a4690ecb1f Cause a compilation error to occur if using @extern with is_dll_import in a comptime scope.
Add a note about thread local / dll import being the cause.
2024-10-22 12:41:35 -04:00
kcbanner
ee25757245 Add support for specifying dll_storage_class in @extern 2024-10-22 12:41:35 -04:00
kcbanner
2d888a8e63 tests: re-enable tests that now pass on aarch64-windows 2024-10-22 11:39:29 +02:00
kcbanner
85d87c9ca1 coff: fix incorrect default image_base values and re-enable shared library tests on Windows
This was the cause of aarch64-windows shared libraries causing  "bad image" errors
during load-time linking. I also re-enabled the tests that were surfacing this bug.
2024-10-21 22:54:52 -07:00
Mario Nachbaur
9f84f7f921 watchOS: add os to aarch64 architecture
Needed for creating libraries that run both on
physical Apple Watches and the watchOS simulator.
2024-10-21 09:24:24 +02:00
mlugg
f7d679ceae
riscv: disable failing test
Looks like the self-hosted riscv64 backend can't handle `std.meta.eql`
involving the new `CallingConvention` right now.
2024-10-19 20:06:04 +01:00
mlugg
8d5ac6bdea
Sema: add and improve some callconv compile errors 2024-10-19 19:46:07 +01:00
mlugg
73f4c68005
x86_64: handle incoming stack alignment 2024-10-19 19:46:07 +01:00
mlugg
387965a696
x86_64,riscv64: fix incorrect incoming_stack_alignment handling
The whole motivation behind this proposal in the first place was that
the LLVM backend disagrees with the self-hosted backends on what
`@setAlignStack` meant, so we can't just translate the old logic to the
new system! These backends can introduce support for overriding
`incoming_stack_alignment` later on.
2024-10-19 19:46:06 +01:00
mlugg
cf39652500
compiler_rt: remove bogus tests
These only worked before because our lowering of the `AAPCS` calling
convention was incorrect in a way which happened to match the ABI of
these functions. The tests aren't actually very helpful -- there are
already tests for `divmoddi4` etc -- so rather than using inline asm on
the caller side to match the ABI, we just delete these two tests.

We were for some reason missing a direct test for `__udivmodsi4`, so one
has been added.
2024-10-19 19:44:53 +01:00
mlugg
289b2f82c3
llvm: fix lowering arm_aapcs_vfp functions 2024-10-19 19:21:33 +01:00
mlugg
28cb887275
Zcu: correct callconvSupported for self-hosted aarch64 2024-10-19 19:21:33 +01:00
mlugg
04ffc1c963
langref: update enum_export_error.zig for callconv changes 2024-10-19 19:21:33 +01:00
mlugg
830230176d
std: update uses of .Inline callconv 2024-10-19 19:21:33 +01:00
mlugg
3ef8bb6354
llvn: fix incorrect mips64 callconv handling 2024-10-19 19:21:32 +01:00
mlugg
1d1e8e1105
link.Dwarf: handle avr_signal and avr_builtin callconvs 2024-10-19 19:21:32 +01:00
mlugg
bde68fdebc
std.Target: correct C callconv on hardfloat ARM 2024-10-19 19:21:32 +01:00
mlugg
1f11eed3d1
llvm: fix lowering of avr_interrupt and m68k_interrupt callconvs 2024-10-19 19:21:32 +01:00
mlugg
ed862b05ae
std.builtin.CallingConvention: remove deprecated RISC-V privilege mode
See b6cade0703
2024-10-19 19:21:32 +01:00
mlugg
0b786059b5
compiler: avoid unreasonable eval branch quotas
Using `@FieldType` (#21702).
2024-10-19 19:21:17 +01:00
mlugg
2319d62f21
std.builtin.CallingConvention: include exact architecture tags in comments 2024-10-19 19:15:24 +01:00
mlugg
d466c08e05
Sema: minor cleanup 2024-10-19 19:15:24 +01:00
mlugg
cb48376bec
cbe,translate-c: support more callconvs
There are several more that we could support here, but I didn't feel
like going down the rabbit-hole of figuring them out. In particular,
some of the Clang enum fields aren't specific enough for us, so we'll
have to switch on the target to figure out how to translate-c them. That
can be a future enhancement.
2024-10-19 19:15:24 +01:00
mlugg
67580ede5e
std.builtin.CallingConvention: RISC-V PrivilegeLevel -> PrivilegeMode
The RISC-V specification uses these terms a little interchangably, but
"mode" seems more correct here.
2024-10-19 19:15:24 +01:00
mlugg
a2c519ba67
link: add clarifying comment 2024-10-19 19:15:24 +01:00
mlugg
6657982e56
std.builtin.CallingConvention: don't provide bogus winapi value 2024-10-19 19:15:24 +01:00
mlugg
2d9a167cd2
std.Target: rename defaultCCallingConvention and Cpu.Arch.fromCallconv 2024-10-19 19:15:23 +01:00
mlugg
cbfe00b17d
std.zig.render: fix callconv(.Inline) -> inline fn promotion 2024-10-19 19:15:23 +01:00
mlugg
4be0cf30fc
test: update for CallingConvention changes
This also includes some compiler and std changes to correct error
messages which weren't properly updated before.
2024-10-19 19:15:23 +01:00
mlugg
ec19086aa0
compiler: remove @setAlignStack
This commit finishes implementing #21209 by removing the
`@setAlignStack` builtin in favour of `CallingConvention` payloads. The
x86_64 backend is updated to use the stack alignment given in the
calling convention (the LLVM backend was already updated in a previous
commit).

Resolves: #21209
2024-10-19 19:15:23 +01:00
mlugg
bc797a97b1
std: update for new CallingConvention
The old `CallingConvention` type is replaced with the new
`NewCallingConvention`. References to `NewCallingConvention` in the
compiler are updated accordingly. In addition, a few parts of the
standard library are updated to use the new type correctly.
2024-10-19 19:15:23 +01:00
mlugg
36405b9b43
stage1: update zig1.wasm
As well as being necessary for the `CallingConvention` changes, this
update includes the following notable changes:

* Fix unlabeled `break` targeting the wrong scope in the presence of
  labeled continue, unblocking #21422
* Implement `@FieldType`
* Implement `@splat` on arrays

Signed-off-by: mlugg <mlugg@mlugg.co.uk>
2024-10-19 19:13:41 +01:00