Commit Graph

9918 Commits

Author SHA1 Message Date
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
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
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
ee25757245 Add support for specifying dll_storage_class in @extern 2024-10-22 12:41:35 -04: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
830230176d
std: update uses of .Inline callconv 2024-10-19 19:21:33 +01:00
mlugg
bde68fdebc
std.Target: correct C callconv on hardfloat ARM 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
2319d62f21
std.builtin.CallingConvention: include exact architecture tags in comments 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
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
51706af908
compiler: introduce new CallingConvention
This commit begins implementing accepted proposal #21209 by making
`std.builtin.CallingConvention` a tagged union.

The stage1 dance here is a little convoluted. This commit introduces the
new type as `NewCallingConvention`, keeping the old `CallingConvention`
around. The compiler uses `std.builtin.NewCallingConvention`
exclusively, but when fetching the type from `std` when running the
compiler (e.g. with `getBuiltinType`), the name `CallingConvention` is
used. This allows a prior build of Zig to be used to build this commit.
The next commit will update `zig1.wasm`, and then the compiler and
standard library can be updated to completely replace
`CallingConvention` with `NewCallingConvention`.

The second half of #21209 is to remove `@setAlignStack`, which will be
implemented in another commit after updating `zig1.wasm`.
2024-10-19 19:08:59 +01:00
mlugg
097766bba3 compiler: implement @FieldType
Resolves: #21702
2024-10-18 08:50:40 +01:00
Alex Rønne Petersen
ff594eae49 std.Target: Make Abi.default() more smarter.
This builds on 221bd829bc with more research I did
for test/llvm_targets.zig.
2024-10-18 00:10:43 +02:00
Alex Rønne Petersen
d38ed893c6
Merge pull request #21726 from alexrp/target-api
`std.Target`: Some miscellaneous API improvements
2024-10-17 02:49:34 +02:00
Justin Braben
4a2a0f50ca
fix compilation errors for fs and fs.Dir (#21643)
* fix compilation errors for fs and fs.Dir

* mem.span instead of mem.sliceTo

* Updating symLinkAbsoluteW function parameters

* Update with expected rename semantics
2024-10-17 01:08:58 +02:00
Alex Rønne Petersen
549a7eba40
std.Target: Rename OS version range functions to drop the "get" prefix. 2024-10-16 22:25:29 +02:00
Alex Rønne Petersen
55fe86c57e
std.Target: Remove isBpfFreestanding().
The only use of this has nothing to do with the OS tag.
2024-10-16 22:25:20 +02:00
Alex Rønne Petersen
140fb615a6
std.Target: Move isLib{C,Cxx}LibName() to std.zig.target.
These are really answering questions about the Zig compiler's capacity to
provide a libc/libc++ implementation. As such, std.zig.target seems like a more
fitting place for these.
2024-10-16 22:25:13 +02:00
Alex Rønne Petersen
bdb00b393e
std.Target: Only consider libxnet to be a libc library name for musl.
glibc has never had this.
2024-10-16 22:24:57 +02:00
Alex Rønne Petersen
879a39a700
std.Target: Ignore case for all Darwin platforms in isLibCLibName().
Matches isLibCxxLibName() behavior.
2024-10-16 22:24:52 +02:00
Alex Rønne Petersen
c76a98f28a
std.Target: Rename is_lib{c,cxx}_lib_name() to isLib{C,Cxx}LibName(). 2024-10-16 22:24:46 +02:00
Alex Rønne Petersen
482759079f
std.Target: Move the elfiamcu check under the x86 prong in toElfMachine(). 2024-10-16 22:24:38 +02:00
Alex Rønne Petersen
bdd3bc056e
Merge pull request #21715 from alexrp/loongarch-porting
Some miscellaneous LoongArch port work
2024-10-16 09:13:51 +02:00
Alex Rønne Petersen
ecd5878b74
Merge pull request #21714 from alexrp/target-cpu-baseline
`std.Target`: Make `Cpu.baseline()` take OS into consideration and pick a better CPU for Apple targets
2024-10-16 04:59:02 +02:00
Alex Rønne Petersen
95674fca0c
std.Thread: Use loongarch freeAndExit() implementation for loongarch32 too. 2024-10-16 01:10:36 +02:00
Alex Rønne Petersen
1cdb143af2
std.Target: Fix loongarch32 handling in C type alignment calculation. 2024-10-16 01:10:36 +02:00
Alex Rønne Petersen
a2c466220c
std.Target: Make Cpu.baseline() pick a better CPU for Apple targets. 2024-10-16 00:33:40 +02:00
Alex Rønne Petersen
1efc9c149c std.zig.target: Sort the target triple list in a more user-friendly way.
This order should be a bit closer to what a user would expect when running
`zig targets | jq -r .libc[]` or similar.
2024-10-16 00:33:23 +02:00
Alex Rønne Petersen
1bca53cc20
std.Target: Change Cpu.baseline() to also be able to take OS into consideration. 2024-10-16 00:33:10 +02:00
Andrew Kelley
9fd61f7460 std.MultiArrayList: add clear methods 2024-10-14 03:33:23 -07:00
Andrew Kelley
3bf89f55c2
Merge pull request #21682 from der-teufel-programming/remove-packedintarray
Remove PackedIntArray
2024-10-13 18:46:51 -07:00
tgschultz
ba569bb8e9
Rewrite bit_reader and bit_writer to take advantage of current zig semantics and enhance readability (#21689)
Co-authored-by: Tanner Schultz <tgschultz@tgschultz-dl.tail7ba92.ts.net>
2024-10-13 18:44:42 -07:00
DravenK
ba1331090c
std.Target.Query: fix compilation error (#21669)
closes #21668

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-10-12 23:15:11 +00:00
Krzysztof Wolicki
04c182274c Fix index calculation in WasmPageAllocator 2024-10-12 22:53:02 +02:00
Andrew Kelley
de04a8a1ef std.dynamic_library: update to new elf API 2024-10-12 10:44:17 -07:00
Andrew Kelley
1ba3fc90be link.Elf: eliminate an O(N^2) algorithm in flush()
Make shared_objects a StringArrayHashMap so that deduping does not
need to happen in flush. That deduping code also was using an O(N^2)
algorithm, which is not allowed in this codebase. There is another
violation of this rule in resolveSymbols but this commit does not
address it.

This required reworking shared object parsing, breaking it into
independent components so that we could access soname earlier.

Shared object parsing had a few problems that I noticed and fixed in
this commit:
* Many instances of incorrect use of align(1).
* `shnum * @sizeOf(elf.Elf64_Shdr)` can overflow based on user data.
* `@divExact` can cause illegal behavior based on user data.
* Strange versyms logic that wasn't present in mold nor lld. The logic
  was not commented and there is no git blame information in ziglang/zig
  nor kubkon/zld. I changed it to match mold and lld instead.
* Use of ArrayList for slices of memory that are never resized.
* finding DT_VERDEFNUM in a different loop than finding DT_SONAME.
  Ultimately I think we should follow mold's lead and ignore this
  integer, relying on null termination instead.
* Doing logic based on VER_FLG_BASE rather than ignoring it like mold
  and LLD do. No comment explaining why the behavior is different.
* Mutating the original ELF symbols rather than only storing the mangled
  name on the new Symbol struct.

I noticed something that I didn't try to address in this commit: Symbol
stores a lot of redundant information that is already present in the ELF
symbols. I suspect that the codebase could benefit from reworking Symbol
to not store redundant information.

Additionally:
* Add some type safety to std.elf.
* Eliminate 1-3 file system reads for determining the kind of input
  files, by taking advantage of file name extension and handling error
  codes properly.
* Move more error handling methods to link.Diags and make them
  infallible and thread-safe
* Make the data dependencies obvious in the parameters of
  parseSharedObject. It's now clear that the first two steps (Header and
  Parsed) can be done during the main Compilation pipeline, rather than
  waiting for flush().
2024-10-12 10:44:17 -07:00
Krzysztof Wolicki
b1eaed6c8d Remove packed_int_array usage from WasmPageAllocator and BigInt 2024-10-12 12:55:35 +02:00
Krzysztof Wolicki
ce27ae1c68 Remove packed_int_array.zig from std 2024-10-12 12:00:09 +02:00
poypoyan
0367f18cb9
std.mem.readVarInt: assert ReturnType is large enough (#20946)
Fixes #20521
2024-10-11 19:32:10 +00:00
Andrew Kelley
ec67d6e03a std.MultiArrayList: add empty initalizer value 2024-10-11 10:33:54 -07:00
Jean-Baptiste "Jiboo" Lepesme
901f344be2 IoUring: fix an issue in tests where InvalidVersion might get thrown by skipKernelLessThan, due to some kernel versions not being SemVer compliant. 2024-10-11 17:07:34 +02:00
YANG Xudong
a9a88aa428 add loongarch valist support 2024-10-11 02:49:00 -07:00