9903 Commits

Author SHA1 Message Date
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 221bd829bcb4318be941a93029b9c12d8317845d 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
Andrew Kelley
1340565e22
Merge pull request #21654 from ziglang/embrace-path-abstraction
link: fix false positive crtbegin/crtend detection
2024-10-10 22:30:04 -07:00
Alex Rønne Petersen
2309d07e20 std.os.linux: Use the Thumb-specific syscall helpers for thumbeb too.
Fixes a "write to reserved register r7" compile error for thumbeb-linux-*.
2024-10-11 02:38:30 +02:00
Andrew Kelley
01aab9f6b3 std.Build.Step.CheckObject: display source file path
and upgrade to getPath3
2024-10-10 14:21:52 -07:00
Andrew Kelley
101d21a6dc std.Build.Cache.Path: fix single-quote escaping format 2024-10-10 14:21:52 -07:00
Andrew Kelley
14c8e270bb link: fix false positive crtbegin/crtend detection
Embrace the Path abstraction, doing more operations based on directory
handles rather than absolute file paths. Most of the diff noise here
comes from this one.

Fix sorting of crtbegin/crtend atoms. Previously it would look at all
path components for those strings.

Make the C runtime path detection partially a pure function, and move
some logic to glibc.zig where it belongs.
2024-10-10 14:21:52 -07:00
mlugg
c96f9a017a Sema: implement @splat for arrays
Resolves: #20433
2024-10-10 11:22:49 +01:00
Andrew Kelley
22661f3d67 link tests: add a way to check prefix and use it 2024-10-08 21:57:08 -07:00
Michael Dusan
e535e65eb3
freebsd posix: add SystemOutdated to MemFdCreateError 2024-10-07 13:19:33 -04:00
Michael Dusan
be91b68e66
dragonfly std: more std.c support 2024-10-07 13:19:33 -04:00
Alex Rønne Petersen
20e03beaef
Merge pull request #21611 from alexrp/target-abi-default
`std.Target`: Rewrite `Abi.default()` to have better defaults across the board.
2024-10-07 06:14:10 +02:00
Alex Rønne Petersen
cc79cc9f55
Merge pull request #21615 from linusg/panic-uefi
std.debug: Fix defaultPanic() uefi build
2024-10-07 03:38:41 +02:00
Alex Rønne Petersen
aa8f39e271
Merge pull request #21614 from alexrp/target-avr-align
`std.Target`: Fix `cTypePreferredAlignment()` to always return 1 for avr.
2024-10-07 01:56:42 +02:00
Alex Rønne Petersen
790fc8cd98
Merge pull request #21499 from alexrp/loongarch-gnusf
Add `loongarch64-linux-gnusf` target support
2024-10-07 01:24:00 +02:00
Alex Rønne Petersen
221bd829bc
std.Target: Rewrite Abi.default() to have better defaults across the board. 2024-10-06 23:28:21 +02:00
Andrew Kelley
d5c9d85295
Merge pull request #21597 from achan1989/issue_14324
Create/open file on WASI targets should have POLL_FD_READWRITE rights
2024-10-06 13:02:51 -07:00