Commit Graph

1484 Commits

Author SHA1 Message Date
Alex Rønne Petersen
624fa8523a std.os.linux: Unbreak the build
Happened because I wrote #20869 before #20870.
2024-08-01 13:05:26 +02:00
Andrew Kelley
8f7cbaa4c0
Merge pull request #20870 from alexrp/target-cleanup-3
`std.Target`: Remove more dead OS/architecture tags
2024-08-01 01:32:32 -07:00
Andrew Kelley
f17f73b4fa
Merge pull request #20869 from alexrp/linux-syscalls
`std.os.linux`: Add syscall enums for all remaining architectures
2024-08-01 01:21:10 -07:00
Andrew Kelley
91163b44dd
Merge pull request #20857 from alexrp/tls-porting
`std.os.linux.tls`: Refactor, improve documentation, fix a bug, and port to more architectures
2024-08-01 01:15:17 -07:00
Andrew Kelley
16dde6d260
Merge pull request #20772 from alexrp/linux-audit
`std.os.linux.AUDIT`: Rewrite ARCH in terms of std.elf.EM.
2024-08-01 01:09:22 -07:00
Alex Rønne Petersen
2e719f3239
std.os.linux.start_pie: Use a 64-bit displacement for s390x.
Not likely to be necessary ever, but might as well be 100% correct.
2024-07-30 18:02:40 +02:00
Alex Rønne Petersen
52519f79e0
std.os.linux.start_pie: Apply MIPS local GOT relocations. 2024-07-30 18:02:36 +02:00
Alex Rønne Petersen
c8ca05e93a
std.Target: Remove sparcel architecture tag.
What is `sparcel`, you might ask? Good question!

If you take a peek in the SPARC v8 manual, §2.2, it is quite explicit that SPARC
v8 is a big-endian architecture. No little-endian or mixed-endian support to be
found here.

On the other hand, the SPARC v9 manual, in §3.2.1.2, states that it has support
for mixed-endian operation, with big-endian mode being the default.

Ok, so `sparcel` must just be referring to SPARC v9 running in little-endian
mode, surely?

Nope:

* 40b4fd7a3e/llvm/lib/Target/Sparc/SparcTargetMachine.cpp (L226)
* 40b4fd7a3e/llvm/lib/Target/Sparc/SparcTargetMachine.cpp (L104)

So, `sparcel` in LLVM is referring to some sort of fantastical little-endian
SPARC v8 architecture. I've scoured the internet and I can find absolutely no
evidence that such a thing exists or has ever existed. In fact, I can find no
evidence that a little-endian implementation of SPARC v9 ever existed, either.
Or any SPARC version, actually!

The support was added here: https://reviews.llvm.org/D8741

Notably, there is no mention whatsoever of what CPU this might be referring to,
and no justification given for the "but some are little" comment added in the
patch.

My best guess is that this might have been some private exercise in creating a
little-endian version of SPARC that never saw the light of day. Given that SPARC
v8 explicitly doesn't support little-endian operation (let alone little-endian
instruction encoding!), and no CPU is known to be implemented as such, I think
it's very reasonable for us to just remove this support.
2024-07-30 06:30:25 +02:00
Alex Rønne Petersen
36332a4fdc
std.os.linux.tls: Add csky support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
9abe3aeeea
std.os.linux.tls: Add arc support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
e6fe7a329a
std.os.linux.tls: Add hexagon support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
d2b21d5823
std.os.linux.tls: Add s390x support. 2024-07-30 02:33:16 +02:00
Alex Rønne Petersen
9db992bd9b
std.os.linux.tls: Add loongarch support. 2024-07-30 02:33:15 +02:00
Alex Rønne Petersen
44d4656dfc
std.os.linux.tls: Add m68k support. 2024-07-30 02:32:55 +02:00
Alex Rønne Petersen
37275c0f69
std.os.linux.tls: Fix layout computation for the modified Variant I. 2024-07-30 02:32:32 +02:00
Alex Rønne Petersen
b52e054261
std.os.linux.tls: Refactor and improve documentation.
* Elaborate on the sub-variants of Variant I.
* Clarify the use of the TCB term.
* Rename a bunch of stuff to be more accurate/descriptive.
* Follow Zig's style around namespacing more.
* Use a structure for the ABI TCB.

No functional change intended.
2024-07-30 02:32:32 +02:00
Alex Rønne Petersen
876383cb2a
std.os.linux: Hook up newly added syscall enums. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
7e0f9c45f2
std.os.linux: Adjust for rename of mips syscall enums. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
e77b3ff74f
std.os.linux.syscalls: Regenerate based on Linux v6.7. 2024-07-30 01:32:48 +02:00
Alex Rønne Petersen
ce5063e188
std.os.linux.AUDIT: Rewrite ARCH in terms of std.elf.EM.
Closes #20743.
2024-07-30 01:30:35 +02:00
Alex Rønne Petersen
2386bfe854
std.os.linux.start_pie: Rewrite relocate() to avoid jump tables and libcalls.
The code would cause LLVM to emit a jump table for the switch in the loop over
the dynamic tags. That jump table was far enough away that the compiler decided
to go through the GOT, which would of course break at this early stage as we
haven't applied MIPS's local GOT relocations yet, nor can we until we've walked
through the _DYNAMIC array.

The first attempt at rewriting this used code like this:

    var sorted_dynv = [_]elf.Addr{0} ** elf.DT_NUM;

But this is also problematic as it results in a memcpy() call. Instead, we
explicitly initialize it to undefined and use a loop of volatile stores to
clear it.
2024-07-30 01:26:10 +02:00
Alex Rønne Petersen
68cebde186
std.os.linux.start_pie: Inline the getDynamicSymbol() function.
On MIPS, this call will require a relocation, which we can't do until after PIE
relocations have been applied.
2024-07-30 01:26:10 +02:00
Alex Rønne Petersen
5633767b20
std.os.linux.start_pie: Add powerpc and powerpc64 support.
Closes #20305.
2024-07-30 01:26:09 +02:00
Alex Rønne Petersen
adfbd8a98b
std.os.linux.start_pie: Add mips and mips64 support. 2024-07-30 01:24:55 +02:00
Andrew Kelley
38e0f049c5
Merge pull request #20389 from alexrp/riscv32
Some `riscv32-linux` porting work
2024-07-29 16:13:35 -07:00
Ryan Liptak
efde3ed04a Fix compile error due to GetModuleFileNameW binding change
In https://github.com/ziglang/zig/pull/19641, this binding changed from `[*]u16` to `LPWSTR` which made it a sentinel-terminated pointer. This introduced a compiler error in the `std.os.windows.GetModuleFileNameW` wrapper since it takes a `[*]u16` pointer. This commit changes the binding back to what it was before instead of introducing a breaking change to `std.os.windows.GetModuleFileNameW`

Related: https://github.com/ziglang/zig/issues/20858
2024-07-29 16:06:36 -07:00
Alex Rønne Petersen
4e5068c35c
std: Stop supporting Linux/glibc versions older than declared in std.Target. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
6eb9cb6f28
std.os.linux.tls: Handle riscv32 in setThreadPointer(). 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
aeb3abc7e6
std.os.linux.start_pie: Handle riscv32 in getDynamicSymbol(). 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
43410cdfe9
std.os.linux: Remove the sparc64 workaround in fadvise().
This does not seem to be needed anymore, and it's unclear if it was ever truly
needed or if it was just there to deal with a QEMU/strace bug.

See: https://github.com/ziglang/zig/pull/8301#issuecomment-2184995749
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
890433e292
std.os.linux: Define timespec as kernel_timespec (64-bit) for riscv32.
This is kind of a hack because the timespec in UAPI headers is actually still
32-bit while __kernel_timespec is 64-bit. But, importantly, all the syscalls
take __kernel_timespec from the get-go (because riscv32 support is so recent).

Defining our timespec this way will allow all the syscall wrappers in
std.os.linux to do the right thing for riscv32. For other 32-bit architectures,
we have to use the 64-bit time syscalls explicitly to solve the Y2038 problem.
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
cafce8c767
std.os.linux.test: Partially skip statx() test on riscv32.
No fstatat(), so there's no point doing the rest of it.
2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
7532a8a584
std.os.linux: Add riscv32 support. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
2d1ee678eb
std.os.linux: Some adjustments after syscall generation strategy changes. 2024-07-29 09:50:41 +02:00
Alex Rønne Petersen
4e7c3cca91
std.os.linux.syscalls: Regenerate based on Linux v6.7.
loongarch64 syscalls not updated because it seems like that kernel port hasn't
been working for a year or so:

    In file included from arch/loongarch/include/uapi/asm/unistd.h:5:
    include/uapi/asm-generic/unistd.h:2:10: fatal error: 'asm/bitsperlong.h' file not found

That file is just missing from the tree. 🤷
2024-07-29 09:50:41 +02:00
matt ettler
ed7f11ffa7 chore: correct non-standard comments.
Comments throughout the codebase start with a space.
This commit corrects comments that do not adhere to this
norm.
2024-07-28 21:34:14 -07:00
Andrew Kelley
3a0da431db
Merge pull request #20667 from jayrod246/windows-watch
Build Runner: Initial Implementation for File System Watching on Windows
2024-07-28 20:35:18 -07:00
Matthew Ettler
d30d37e356
feat(std.os.uefi.protocol): add Serial IO 2024-07-28 12:37:53 +00:00
Jarrod Meyer
2de0e2eca3 Watch.zig: add initial windows implementation 2024-07-27 11:32:43 -04:00
Jarrod Meyer
2b8f444dde windows: reintroduce ReadDirectoryChangesW
- additionally, introduces FileNotifyChangeFilter to improve use/readability
2024-07-27 11:32:43 -04:00
Jarrod Meyer
9323a00067 windows: add Timeout status result for GetQueuedCompletionStatus 2024-07-27 11:32:43 -04:00
Jarrod Meyer
7434accc3d windows: make the WaitForMultipleObjectsEx assertion inclusive
- additionally, the parameter must be nonzero: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjects
2024-07-27 11:32:43 -04:00
Alex Rønne Petersen
66b71273a2 std.os.linux: Fix default value for perf_event_attr.clockid field.
Closes #20810.
2024-07-26 18:21:10 -07:00
Alex Rønne Petersen
38c492bb53
std.os.linux.start_pie: Add hexagon support. 2024-07-24 20:12:38 +02:00
Alex Rønne Petersen
a0b2b987c8
std.os.linux.start_pie: Add arc support. 2024-07-24 20:12:38 +02:00
Alex Rønne Petersen
bc054a713e
std.os.linux.start_pie: Add csky support. 2024-07-24 20:12:38 +02:00
Alex Rønne Petersen
2dabb7ec77
std.os.linux.start_pie: Handle armeb, thumb, thumbeb, and aarch64_be too. 2024-07-24 20:12:38 +02:00
Andrew Kelley
4de8bba648
Merge pull request #20749 from alexrp/start-pie
`std.os.linux.start_pie`: Implement `getDynamicSymbol()` for loongarch64, m68k, and s390x
2024-07-24 10:27:20 -07:00
Alex Rønne Petersen
1c6bee0834
std.os.linux.start_pie: Add s390x support. 2024-07-24 00:28:08 +02:00
Alex Rønne Petersen
6fac71ec74
std.os.linux.start_pie: Add m68k support. 2024-07-24 00:28:07 +02:00