21093 Commits

Author SHA1 Message Date
Andrew Kelley
b57081f039 Release 0.10.1 0.10.1 2023-01-17 16:40:56 -07:00
Robert Burke
edd9d73b0d Fix buffer overflow in fmt when DAZ is set 2023-01-17 16:29:37 -07:00
praschke
0a03d68594 std.net: check for localhost names before asking DNS
the old implementation asks DNS before checking if it shouldn't.
additionally, it did not catch absolute 'localhost.' names.
2023-01-10 16:10:15 -07:00
Felix "xq" Queißner
c8a7dc22b1 Fixes bug in AVR codegen for llvm backend 2023-01-10 16:09:52 -07:00
Andrew Kelley
537618464a Revert "std.os: Fix std.os.chdir for WASI"
This reverts commit fff7f15fb88f6683f9d73565d8d59593ecf7461a.

This commit was not intended to be cherry-picked into the 0.10.x branch.
2023-01-10 00:45:09 -07:00
Andrew Kelley
b9ea086812 C ABI tests: fix merge conflict with x86/i386 2023-01-09 22:43:10 -07:00
Andrew Kelley
b2cf10c5d5 CI: disable windows testing
We never got this working on GitHub Actions with the 0.10.x branch.
2023-01-09 16:22:02 -07:00
Andrew Kelley
01a44e9aa4 CI: disable mips and powerpc
Tracking issue #13782
2023-01-09 16:21:25 -07:00
Andrew Kelley
7d4bc54277 work around stage1 limitations 2023-01-09 15:58:42 -07:00
Andrew Kelley
8583e88db5 CI: update to github actions in the 0.10.x branch 2023-01-09 15:48:02 -07:00
Michael Dusan
da96e7efcc stage3 bsd: support dynamic libstdc++/libc++
Currently llvm-linkage mode (static vs dynamic) decides linkage mode
for system libstdc++/libc++ .

A previous commit only tested static mode for *BSD and netbsd was
reported to not work in dynamic mode.

We now special-case freebsd, openbsd, netbsd and dragonfly for dynamic
linking too.
2023-01-09 15:16:38 -07:00
Eric Joldasov
6bb82dad43 cmake: move 'continue' statement to avoid cmake bug 2023-01-09 15:16:03 -07:00
Michael Dusan
86f4dfe5a8 llvm codegen: fix f16,f32,f64 nan bitcasts
@bitCast from integer NaN representation to float NaN resulted in
changed bits in float. This only happened with signaled NaN.

- added test for signaled NaN
- added tests for quiet NaN (for completeness)

closes #14198
2023-01-09 15:15:42 -07:00
Casey Banner
dc18b8174a Fix another LockViolation case on Windows (#14162)
- Add an assert that an exclusive lock is help to writeManifest
- Only call writeManifest in updateCObject if an exclusive lock is held
- cache: fixup test to verify hits don't take an exclusive lock, instead of writing the manifest
2023-01-09 15:15:27 -07:00
Michael Dusan
7d538d6e53 stage3 macos: enable -headerpad_max_install_names
This pads the install names area in final (stage3) zig executable on
macos. The executable size grows by 4096 bytes, or roughly 0.002% .

closes #13388
2023-01-09 15:15:14 -07:00
Andrew Kelley
be6a81d3a7 Merge pull request #13699 from mikdusan/bsd
give BSDs some attention
2023-01-09 15:14:21 -07:00
Frank Denis
5572a83123 Happy new year! 🎉 (#14143) 2023-01-09 15:13:27 -07:00
Andrew Kelley
b19a29c70f mingw: add missing vscprintf.c file
closes #13733

Thanks to @kcbanner for finding this.
2023-01-09 15:12:47 -07:00
Andrew Kelley
55be10486e fix merge conflict with identifiers matching primitives 2023-01-09 15:12:10 -07:00
Andrew Kelley
5766c8ebc8 Merge pull request #14070 from jacobly0/issue/14032
Fix #14032
2023-01-09 15:11:19 -07:00
Jacob Young
4068fafcc6 Sema: fix missing struct layout for llvm backend
Closes #14063
2023-01-09 15:10:44 -07:00
Ryan Liptak
fe6fd0d541 Dir.openDirAccessMaskW: Add ACCESS_DENIED as a possible error
Can occur when trying to open a directory for iteration but the 'List folder contents' permission of the directory is set to 'Deny'.

This was found because it was being triggered during PATH searching in ChildProcess.spawnWindows if a PATH entry did not have 'List folder contents' permission, so this fixes that as well (note: the behavior on hitting this during PATH searching is to treat it as the directory not existing and therefore will fail to find any executables in a directory in the PATH without 'List folder contents' permission; this matches Windows behavior which also fails to find commands in directories that do not have 'List folder contents' permission).
2023-01-09 15:10:24 -07:00
Jakub Konka
433709a788 macho: add missing defs of compact unwind info records 2023-01-09 15:09:52 -07:00
Jakub Konka
0420ad0292 Add missing clang opts: -install_name and -undefined 2023-01-09 15:09:40 -07:00
shwqf
23c09598c7 Call ensureResultUsed before comptime .call is evaluated.
Fixes #12580
2023-01-09 15:09:40 -07:00
Ganesan Rajagopal
2acdea7dfd c.zig: Add definition for pthread_key_t
Add missing definition for pthread_key_t

Closes #13950
2023-01-09 15:06:13 -07:00
Motiejus Jakštys
c841f52fcb Elf: switch link order of libcompiler_rt and libc
Given `main.go`:

    package main
    import  _ "os/user"
    func main() {}

Compiling it to linux/arm64:

    $ CGO_CFLAGS='-O0' GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC="zig cc -target aarch64-linux-gnu.2.28" go build main.go

Results in this error:

    runtime/cgo(.text): unknown symbol memset in callarm64
    runtime/cgo(.text): unknown symbol memset in callarm64
    runtime/cgo(.text): relocation target memset not defined

In the midst of intermediate compilations files we can see this commmand:

    ld.lld -o _cgo_.o <...> /tmp/go-build206961058/b043/_x009.o <...> ~/.cache/zig/.../libcompiler_rt.a <...> ~/.cache/.../libc.so.6

`_x009.o` needs memset:

    $ readelf -Ws ./b043/_x009.o | grep memset
        22: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND memset

Both `libcompiler_rt.a` and `libc.so.6` provide it:

    $ readelf -Ws ~/.cache/zig/.../libcompiler_rt.a | grep memset
       870: 0000000000000000   318 FUNC    WEAK   DEFAULT  519 memset

    $ readelf -Ws ~/.cache/zig/.../libc.so.6 | grep -w memset
       476: 000000000001d34c     0 FUNC    GLOBAL DEFAULT    7 memset@@GLIBC_2.2.5

Since `libcompiler_rt.a` comes before libc in the linker line, the
resulting `_cgo_.o` still links to a weak, unversioned memset:

    $ readelf -Ws ./b043/_cgo_.o | grep -w memset
        40: 000000000022c07c   160 FUNC    WEAK   DEFAULT   14 memset
       719: 000000000022c07c   160 FUNC    WEAK   DEFAULT   14 memset

Since the final linking step is done by Golang's linker, it does not
know of `libcompiler_rt.a`, and fails to link with the error message
above. However, Go linker does recognize memset from glibc. If we
specify an `-lc` equivalent before the `libcompiler_rt.a`, it will link
to memset from libc:

    $ readelf -Wa ./b043/_x009.o |grep memset
        14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset@GLIBC_2.17 (2)
       157: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset@GLIBC_2.17

... and then `main.go` will compile+link successfully.

Why doesn't Go linker take memset from glibc? An educated guess: Go
determines whether to link with glibc from what the program asks (I
presume `.dynsym`). Since `memset` is no longer attributed to glibc, Go
skips linking to glibc altogether.

Bonus question: curious why `-O0` is necessary? Because when
optimizations are enabled (the default), the C compiler replaces
`memset` function call with plain `stp` instructions (on aarch64).
2023-01-09 15:06:07 -07:00
Andrew Kelley
bcc2fb66f3 std.debug: disable sporadically failing test
see tracking issue #13963
2023-01-09 15:05:51 -07:00
IntegratedQuantum
d6faa4e868 Fix tautological big_int tests. 2023-01-09 15:04:55 -07:00
Frechdachs
f8ea292d09 std: Fix update() method in PriorityQueue and PriorityDequeue (#13908)
Previously the update() method would iterate over its capacity, which may contain uninitialized memory or already removed elements.
2023-01-09 15:04:28 -07:00
Tom Maenan Read Cutting
b5222f86ee Add 0-length buffer checks to os.read & os.write
This helps prevent errors related to undefined pointers being passed
through to some OS apis when slices have 0 length.

Tests have also been added to catch these cases.
2023-01-09 15:04:10 -07:00
fsh
7d0d99aac0 std: fix bug in Pcg32 fill function (#13894)
The PCG32 fill function seems to have been copy-pasted from code using u64, so requesting `n` bytes where `(n & 7) > 4` bytes would cause the last few bytes to be all 0.
2023-01-09 15:04:04 -07:00
Jan Philipp Hafer
cdcb746cc2 std.os.linux: fix timerfd test
Remove timerfd timeout and fix timerfd_settime flag.
CI tests should not rely on timings to succeed.

Closes #13721.
2023-01-09 15:03:40 -07:00
Jakub Konka
3e2ddbfdd7 Remove incorrect assertion in readMachODebugInfo panicking during panic
This fixes a class of bugs on macOS where a segfault happening in
a loaded dylib with no debug info would cause a panic in the panic
handler instead of simply noting that the dylib has no valid debug
info via `error.MissingDebugInfo`. An example could be code linking
some system dylib and causing some routine to segfault on say invalid
pointer value, which should normally cause Zig to print an incomplete
stack trace anchored at the currently loaded image and backtrace all
the way back to the Zig binary with valid debug info. Currently, in
a situation like this we would trigger a panic within a panic.
2023-01-09 15:03:16 -07:00
Takeshi Yoneda
6f39ce93ce wasi: fixes os.isatty on type mismatch (#13813) 2023-01-09 15:03:00 -07:00
Andrew Kelley
07f6fc3000 Compilation: revert asking for exclusive locks on cache hits
We definitely want a shared lock on a cache hit. Without this, we get a
deadlock when Zig is asked to compile the same C source file multiple
times as part of the same compilation.

This is a partial revert of 8ccb9a6ad327a4d7fbc321b33d4aa66a27a1f5ee.

cc @kcbanner
2023-01-09 15:02:38 -07:00
Casey Banner
a4418a8fd6 cache: Fix LockViolation during C compilation paths (#13591)
- C compilation flows didn't hold an exclusive lock on the cache manifest file when writing to it in all cases
- On windows, explicitly unlock the file lock before closing it
2023-01-09 15:00:03 -07:00
Andrew Kelley
bb957a976d Sema: resolve elem type for non-default aligned ptrs
Before this commit, I observe a crash from this abiSize call because the
element type is a struct that is not yet resolved. This is triggered by
running the behavior tests with -ofmt=c -target x86_64-windows.
2023-01-09 14:59:28 -07:00
Andrew Kelley
f8f65aebe6 zig cc: fix wrong flag name from earlier commit
In dfe942024461a3598fc872ea79e7859a8744b550, I made a typo. This commit
corrects it. I tested this commit via a patch to zig-bootstrap.
2023-01-09 14:59:19 -07:00
Andrew Kelley
3bc70ea2dd compiler_rt: avoid using weak aliases
This is a partial revert of 0d533433e21621177fb291e2a4901bee11834501,
which regressed this behavior. The idea here is to avoid aliases, which
happens when the same function is exported with multiple names. The
problem with aliases is that weak aliases don't seem to work, causing
symbol collisions when multiple of the same symbol are provided, despite
the desired behavior that weak symbols are overridden.

In this case we export redundant functions with different names. Thanks
to -ffunction-sections, the unused functions will be garbage-collected
at link time. This leaves us with the best of both worlds: Zig's
compiler-rt will provide both sets of symbols, and it will be
binary-compatible with different compilers that expect different names,
while still resulting in binaries without garbage.
2023-01-09 14:58:38 -07:00
Andrew Kelley
9067daeb94 zig cc: support -stack in addition to --stack for linker arg 2023-01-09 14:58:22 -07:00
Andrew Kelley
290874a24e CI: adjust logic for cancelling workflows
This prevents clobbering when two contributors' PRs have the same head
ref.
2023-01-09 14:58:07 -07:00
nc
033dcf7811 std.atomic.Queue: fix unget implementation and add doc 2023-01-09 14:57:56 -07:00
Andrew Kelley
39c3889df1 CI: use cache directories local to the CI run
Override the cache directories because they won't actually help other CI
runs which will be testing alternate versions of zig, and ultimately
would just fill up space on the hard drive for no reason.

In practice we did see one of the CI servers fill up too many files
inside ~/.cache/zig, which caused certain file system operations to
start returning ENOSPC, despite the hard drive having plenty of space
left.
2023-01-09 14:57:31 -07:00
Veikka Tuominen
594158a692 Merge pull request #13142 from mllken/gzip-safety
gzip: add missing header fields and bounds for header parsing
2023-01-09 14:57:23 -07:00
Andrew Kelley
af958e95cc Merge pull request #13744 from Vexu/stage2-fixes
Improve error messages, fix dependency loops
2023-01-09 14:55:12 -07:00
Andrew Kelley
fd57487e35 CI: update tarballs to 0.11.0-dev.448+e6e459e9e
Notably this contains a fix to zig cc that enables the syntax
`-Wl,-z,stack-size=0x10000`.
2023-01-09 14:54:01 -07:00
Andrew Kelley
5fc7424a8d zig cc: detect -z stack-size arguments 2023-01-09 14:53:42 -07:00
Jakub Konka
ffb27a8bd0 Merge pull request #13725 from mathetake/fixreaddir
wasi: fixes IterableDir.nextWasi for large directory
2023-01-09 14:52:57 -07:00
Andrew Kelley
be5b1ab7ed Merge branch 'ci-add-debug-aarch64-linux' 2023-01-09 14:52:42 -07:00