aboutsummaryrefslogtreecommitdiff
path: root/lib/std
AgeCommit message (Collapse)Author
2022-09-12remove pointless discardsAndrew Kelley
2022-09-11chore: Remove unused constantsShane Kennedy
2022-09-11Compilation: handle system C compiler not foundAndrew Kelley
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-09Merge pull request #12788 from ziglang/detect-native-glibcAndrew Kelley
std.zig.system.NativeTargetInfo: improve glibc version and dynamic linker detection
2022-09-09std.zig.system.NativeTargetInfo: more headroom for libc.so.6 .dynstrAndrew Kelley
2022-09-09std.os.uefi: mark BlockIoProtocol and EfiBlockMedia as publicYusuf Bham
2022-09-09Merge pull request #12772 from ziglang/coff-basic-importsJakub Konka
coff: implement enough of the incremental linker to pass behavior and incremental tests on Windows
2022-09-09std.zig.system.NativeTargetInfo: add fallback checkAndrew Kelley
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-08std.zig.system.NativeTargetInfo: restore symlink logicAndrew Kelley
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-08std.zig.system.NativeTargetInfo: handle missing DT_RUNPATHAndrew Kelley
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-08stage2: fix building for 32-bit targetsAndrew Kelley
2022-09-08std.zig.system.NativeTargetInfo: detection ignores self exeAndrew Kelley
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-08std.zig.system.NativeTargetInfo: improve glibc version detectionAndrew Kelley
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-08wasm: temporarily save curr file pointer before pwriting on WinJakub Konka
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-08NativeTargetInfo.zig: fix typoMartin Stuurwold
2022-09-07revert part of 945111ae92c28f8ad642a64af4dc83acd3bef4a5Jakub Konka
2022-09-07enable testing of x86_64-windows-gnu using self-hosted backend and linkerJakub Konka
2022-09-07libstd: use windows.GetStdHandle() with stage2_x86_64 backend for nowJakub Konka
2022-09-07x86_64: implement Windows x64 calling conventionJakub Konka
2022-09-07coff: re-enable default entrypoint for WindowsJakub Konka
2022-09-07std.simd: change T to u16Dan Ellis Echavarria
The `element_bit_size` would break if `T` was signed due to `ceilPowerOfTwo` only working on unsigned numbers.
2022-09-04Fix #12440: std.math.big.Rational order/orderAbsYujiri
2022-09-02zig fmt: don't delete container doc commentsyujiri8
Fixes #12617
2022-09-02zig fmt: remove trailing comma at the end of assembly clobberriChar
2022-09-01Add AFNOSUPPORT error to bind (#12560)John Schmidt
2022-08-31coff: add import table definitionsJakub Konka
2022-08-31Using `comptime level.asText()` in log exampleHashi364
Some recent change makes slice concatenation runtime (merge #12368), so the example needs to be explicitly made comptime.
2022-08-31translate-c: promote large integer macros to unsigned long long if necessaryEvan Haas
Closes #10793 Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-30std.Thread: fix freeAndExit on x86_64-linux (#12693)biexelar
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-30coff: add base relocation related typesJakub Konka
2022-08-30coff: move Symtab and Strtab out of coff.CoffJakub Konka
This should ease interfacing with different std.coff functionalities.
2022-08-30Merge pull request #12677 from ziglang/coff-linkerJakub Konka
coff: initial rewrite of the COFF/PE linker
2022-08-30Merge pull request #12662 from wsengir/coff-fixJakub Konka
coff: fix reading COFF header offset
2022-08-30std.rand: make weightedIndex proportions param a const sliceVeikka Tuominen
The function does not mutate the proportions and the signature should reflect that.
2022-08-30coff: fallback to _start as default entry point for nowJakub Konka
This is not technically correct, but given that we are not yet able to link against the CRT, it's a good default until then. Add basic logging of generated symbol table in the linker.
2022-08-30coff: add missing bits required for minimal PE exampleJakub Konka
2022-08-30coff: write headers to fileJakub Konka
2022-08-30coff: reorganize the linkerJakub Konka
2022-08-30start: allow for explicitly defined entry point for WinJakub Konka
2022-08-28coff: publicize and flesh out more image constantsWilliam Sengir
2022-08-28std.random: add weightedIndex functionJustin Whear
`weightedIndex` picks from a selection of weighted indices.
2022-08-28coff: fix reading COFF header offsetWilliam Sengir
2022-08-27Sema: add error for non-comptime param in comptime funcantlilja
Adds error for taking a non comptime parameter in a function returning a comptime-only type but not when that type is dependent on a parameter. Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-26openbsd: fix sigcontext struct and avoid defining fxsave64Sébastien Marie
`sc_fpstate` member of `struct sigcontext` is a `struct fxsave64 *`. use *anyopaque to represent it. avoid to defining `fxsave64` as it is a packed struct with some arrays.
2022-08-26coff: do not pull in std.log into coff.zig definitionsJakub Konka
2022-08-26copy_file_range: fix zigification of TXTBSYMotiejus Jakštys
From `copy_file_range(2)` errors: ETXTBSY Either fd_in or fd_out refers to an active swap file. Same error will be used in the upcoming `ioctl_ficlonerange(2)`: ETXTBSY One of the files is a swap file. Swap files cannot share storage.
2022-08-24stage2: explicitly tagged enums no longer have one possible valueAndrew Kelley
Previously, Zig had inconsistent semantics for an enum like this: `enum(u8){zero = 0}` Although in theory this can only hold one possible value, the tag `zero`, Zig no longer will treat the type this way. It will do loads and stores, as if the type has runtime bits. Closes #12619 Tests passed locally: * test-behavior * test-cases
2022-08-24docs: remove confusion about align[For|Back]wardJonas Gollenz
2022-08-24fix coff.zig with const qualifier convert problemmax
2022-08-24pthread_key_create: make it build with stage2Sébastien Marie