Commit Graph

6093 Commits

Author SHA1 Message Date
Andrew Kelley
68f2d6cb24 std: remove workaround for fixed bug
The miscompilation in question has been fixed upstream in LLVM 13.

closes #8117
2022-09-13 18:20:18 -07:00
Veikka Tuominen
349d78a443 validate number literals in AstGen 2022-09-13 20:26:04 -04:00
Andrew Kelley
0a4cfb81bc Merge remote-tracking branch 'origin/master' into llvm15 2022-09-13 13:50:25 -07:00
Andrew Kelley
7a941391d8 universal-libc: fix strncmp tests
The specification for this function is that it returns a positive value,
zero, or negative value, not that it returns the difference between
ascii values.
2022-09-12 22:32:15 -07:00
Andrew Kelley
f16855b9d7 remove pointless discards 2022-09-12 18:13:24 -07:00
Andrew Kelley
ab3ac291ac Merge remote-tracking branch 'origin/master' into llvm15 2022-09-11 20:26:53 -07:00
Shane Kennedy
c97d64b677 chore: Remove unused constants 2022-09-11 23:18:43 -04:00
Andrew Kelley
349df40d14
Merge pull request #12814 from ziglang/native-libc-integration
stage2: no condition on system libs to link native libc
2022-09-11 23:12:50 -04:00
Andrew Kelley
65bea514ae Compilation: handle system C compiler not found
When linking libc and compiling natively, Zig tries to integrate with
the system C compiler. However, this caused Zig to fail when no system C
compiler is installed, despite the fact that Zig is perfectly capable of
compiling & linking libc without one.

This commit makes Zig fall back to using its own ability to provide libc
in the case that no C compiler is installed. For glibc, it means
sometimes getting the warning "zig cannot build new glibc version abc,
providing instead xyz".

Ideally, Zig would do some more validation about the system libraries
being linked against, and report an error in case it could not provide
the exact correct libc version of the system libraries (or that the
system libraries themselves conflict with each other), however, I think
it is fair to call that a separate enhancement.
2022-09-11 16:37:03 -07:00
Loris Cro
60678f5baf autodoc: fix regression in frontend rendering of values 2022-09-11 23:45:18 +02:00
Loris Cro
2a96f80d03 autodoc: reduce json payload size
this commit removes whitespace and changes Decl, AstNode and Type to be
json arrays instead of json objects. This change reduces json payload
size for the stdlib from 25mb to < 10mb.
2022-09-11 21:35:01 +02:00
Andrew Kelley
37cdb5dbf9 Merge remote-tracking branch 'origin/master' into llvm15 2022-09-09 10:26:17 -07:00
Andrew Kelley
9e070b653c
Merge pull request #12788 from ziglang/detect-native-glibc
std.zig.system.NativeTargetInfo: improve glibc version and dynamic linker detection
2022-09-09 12:28:25 -04:00
Andrew Kelley
68e61bbc0c std.zig.system.NativeTargetInfo: more headroom for libc.so.6 .dynstr 2022-09-09 09:27:02 -07:00
Yusuf Bham
c9f145a50b std.os.uefi: mark BlockIoProtocol and EfiBlockMedia as public 2022-09-09 16:48:54 +03:00
Jakub Konka
56b96cd61b
Merge pull request #12772 from ziglang/coff-basic-imports
coff: implement enough of the incremental linker to pass behavior and incremental tests on Windows
2022-09-09 13:08:58 +02:00
Andrew Kelley
c7d6048081 std.zig.system.NativeTargetInfo: add fallback check
After failing to find RUNPATH in the ELF of /usr/bin/env, not finding
the answer in a symlink of the dynamic interpreter, and not finding
libc.so.6 in the same directory as the dynamic interpreter, Zig will
check `/lib/$triple`.

This fixes incorrect native glibc version detected on Debian bookworm.
2022-09-09 00:07:02 -07:00
Andrew Kelley
9f40f34501 std.zig.system.NativeTargetInfo: restore symlink logic
This is a partial revert of the previous commit, fixing a regression on
Debian. However, the commit additionally improves the
detectAbiAndDynamicLinker function to read more than 1 byte at a time
when detecting a shebang line.
2022-09-08 20:52:49 -07:00
Andrew Kelley
c668396941 std.zig.system.NativeTargetInfo: handle missing DT_RUNPATH
This commit removes the check that takes advantage of when the dynamic
linker is a symlink. Instead, it falls back on the same directory as the
dynamic linker as a de facto runpath. Empirically, this gives correct
results on Gentoo and NixOS.

Unfortunately it is still falling short for Debian, which has libc.so.6
in a different directory as the dynamic linker.
2022-09-08 20:52:49 -07:00
Andrew Kelley
1b6fa1965a stage2: fix building for 32-bit targets 2022-09-08 20:52:49 -07:00
Andrew Kelley
3ee01c14ee std.zig.system.NativeTargetInfo: detection ignores self exe
Before, native glibc and dynamic linker detection attempted to use the
executable's own binary if it was dynamically linked to answer both the
C ABI question and the dynamic linker question. However, this could be
problematic on a system that uses a RUNPATH for the compiler binary,
locking it to an older glibc version, while system binaries such as
/usr/bin/env use a newer glibc version. The problem is that libc.so.6
glibc version will match that of the system while the dynamic linker
will match that of the compiler binary. Executables with these versions
mismatching will fail to run.

Therefore, this commit changes the logic to be the same regardless of
whether the compiler binary is dynamically or statically linked. It
inspects `/usr/bin/env` as an ELF file to find the answer to these
questions, or if there is a shebang line, then it chases the referenced
file recursively. If that does not provide the answer, then the function
falls back to defaults.

This commit also solves a TODO to remove an Allocator parameter to the
detect() function.
2022-09-08 20:52:49 -07:00
Andrew Kelley
fa940bafa2 std.zig.system.NativeTargetInfo: improve glibc version detection
Previously, this code would fail to detect glibc version because it
relied on libc.so.6 being a symlink which revealed the answer. On modern
distros, this is no longer the case.

This new strategy finds the path to libc.so.6 from /usr/bin/env, then
inspects the .dynstr section of libc.so.6, looking for symbols that
start with "GLIBC_2.". It then parses those as semantic versions and
takes the maximum value as the system-native glibc version.

closes #6469
   see #11137
closes #12567
2022-09-08 20:52:49 -07:00
Jakub Konka
0ae2ea671b wasm: temporarily save curr file pointer before pwriting on Win
This is a temporary workaround to an unclear platform-dependence
behavior we have in libstd for `std.fs.File` abstraction. See
https://github.com/ziglang/zig/issues/12783 for more information.
2022-09-08 14:29:54 +02:00
Martin Stuurwold
a7661f115d NativeTargetInfo.zig: fix typo 2022-09-08 01:53:32 -04:00
Jakub Konka
b98b3252be revert part of 945111ae92 2022-09-07 23:18:57 +02:00
Jakub Konka
945111ae92 enable testing of x86_64-windows-gnu using self-hosted backend and linker 2022-09-07 22:42:58 +02:00
Jakub Konka
423f424c27 libstd: use windows.GetStdHandle() with stage2_x86_64 backend for now 2022-09-07 22:42:57 +02:00
Jakub Konka
3a4c69c018 x86_64: implement Windows x64 calling convention 2022-09-07 22:42:56 +02:00
Jakub Konka
a35f156cf6 coff: re-enable default entrypoint for Windows 2022-09-07 22:42:55 +02:00
Dan Ellis Echavarria
924679abc4
std.simd: change T to u16
The `element_bit_size` would break if `T` was signed due to `ceilPowerOfTwo` only working on unsigned numbers.
2022-09-07 15:22:30 +03:00
Andrew Kelley
b7900de168 Merge remote-tracking branch 'origin/master' into llvm15 2022-09-06 19:45:02 -07:00
Loris Cro
201dca323e autodoc: improve rendering of long fn signatures 2022-09-05 17:26:59 +02:00
Der Teufel
b8001335c4 autodoc: Opaque now handled like other container types 2022-09-04 22:47:58 +02:00
Loris Cro
dbd60e3d29 autodoc: add support for doc tests 2022-09-04 22:45:57 +02:00
Yujiri
ae3a5ff7f9 Fix #12440: std.math.big.Rational order/orderAbs 2022-09-04 18:45:20 +03:00
yujiri8
10e11b60e5
zig fmt: don't delete container doc comments
Fixes #12617
2022-09-02 20:12:20 +02:00
Loris Cro
907c60aaa7
Merge pull request #12705 from der-teufel-programming/autodoc-big-int
Autodoc big_int
2022-09-02 17:48:17 +02:00
Loris Cro
70b96169ae
Merge pull request #12709 from der-teufel-programming/autodoc-compare-operators
autodoc: Compare operators
2022-09-02 17:38:00 +02:00
Loris Cro
081d5a9690 autodoc: correct line number implementation
we also correctly take advantage of the starting byte offset of the
parent decl when calling `tree.tokenLocation()`!
2022-09-02 17:28:12 +02:00
riChar
0d96f1f4fb
zig fmt: remove trailing comma at the end of assembly clobber 2022-09-02 12:52:33 +03:00
Der Teufel
0d3c6b7aa8 autodoc: Added int_big support 2022-09-02 11:01:46 +02:00
John Schmidt
36f4f32fad
Add AFNOSUPPORT error to bind (#12560) 2022-09-01 15:13:07 -05:00
Der Teufel
3bbf08e98a autodoc: Compare operators 2022-09-01 15:17:14 +02:00
Jakub Konka
540d8cd809 coff: add import table definitions 2022-08-31 19:30:51 +02:00
Hashi364
973b440561 Using comptime level.asText() in log example
Some recent change makes slice concatenation runtime (merge #12368), so the example needs to be explicitly made comptime.
2022-08-31 16:01:35 +03:00
Evan Haas
fdb8870852 translate-c: promote large integer macros to unsigned long long if necessary
Closes #10793

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-31 15:52:53 +03:00
biexelar
59e33b447b
std.Thread: fix freeAndExit on x86_64-linux (#12693)
Previously, this function used incorrect registers for the munmap syscall, leading to detached threads not cleaning up.

closes #12690

Co-authored-by: bxlr <biexelar@diroot.org>
2022-08-30 22:31:47 -04:00
Andrew Kelley
20145016ac Merge remote-tracking branch 'origin/master' into llvm15 2022-08-30 19:12:05 -07:00
Jakub Konka
d3eaabd285 coff: add base relocation related types 2022-08-30 23:07:28 +02:00
Andrew Kelley
1e21876de2 Merge remote-tracking branch 'origin/master' into llvm15 2022-08-30 13:02:43 -07:00