16081 Commits

Author SHA1 Message Date
Andrew Kelley
01cb0bdb83
Merge pull request #10304 from ziglang/musl-stubgrade
Improve musl libc.so stubs
2021-12-09 14:12:51 -08:00
Andrew Kelley
f69f55c807 stage2: upgrade musl libc stub file
This is the result of the work on tools/gen_stubs.zig. It now uses the
preprocessor to emit different symbols and sizes depending on the
architecture. The data is collected directly from multiple libc.so files
on disk built with upstream musl.

Closes #8178
Addresses #8896 for musl

There is still room for further improvement to this, which is to
put `.ds` directives after symbols that are not followed by aliases, to
avoid the potential problem of a linker believing that all symbols are
aliases of each other.
2021-12-09 01:39:07 -07:00
Andrew Kelley
da9542c0af tools/gen_stubs: add aarch64 and output preprocessor directives
Now it outputs libc.S which can be assembled with zig, and the small
differences per-architecture are handled with preprocessor directives.

There is also now a set of blacklisted symbols which contains
compiler-rt.
2021-12-09 01:21:30 -07:00
Andrew Kelley
04d44db6cc tools/gen_stubs: consolidate symbol properties into MultiSym 2021-12-08 23:45:25 -07:00
Andrew Kelley
808b9239a3 improve musl dynamic stubs file libc.s
tools/gen_stubs.zig now cuts out the middle man and operates directly on
the libc.so ELF file. it outputs accurate .size directives for objects.

std.elf gains an STV enum.
2021-12-08 22:32:31 -07:00
Andrew Kelley
8031783539 stage1: fix regression of shift by negative value error
The previous commit (38b2d6209239f0dad7cb38e656d9d38506f126ca) regressed
the compile error test case for when doing saturating shift left of a
comptime-known negative RHS.

This commit additionally fixes the error for regular shifts in addition
to saturating shifts.
2021-12-08 19:09:37 -07:00
Andrew Kelley
38b2d62092 stage1: saturating shl operates using LHS type
Saturating shift left (`<<|`) previously used the `ir_analyze_bin_op_math`
codepath rather than the `ir_analyze_bit_shift` codepath, leading to it
doing peer type resolution (incorrect) instead of using the LHS type as
the number of bits to do the saturating against.

This required implementing SIMD vector support for `@truncate`.

Additionall, this commit adds a compile error for saturating shift left
on a comptime_int.

stage2 does not pass these new behavior tests yet.

closes #10298
2021-12-08 15:25:31 -07:00
Jakub Konka
64e2bfaa23 macho: write out LC_FUNCTION_START data 2021-12-08 23:24:40 +01:00
Jakub Konka
98e36ea6b9 macho: handle non-extern UNSIGNED relocs on arm64 2021-12-08 20:48:12 +01:00
Jakub Konka
f0ec70edd1 macho: do not write null symbols into undef symbols section
Also, skip creating stub entries for resolved globally defined
regular symbols.
2021-12-08 16:58:29 +01:00
Andrew Kelley
83a6681955 link: fix build for 32-bit targets
This wasn't caught by the CI checks because this function is is only
called for the `use_stage1` codepath.
2021-12-07 17:03:29 -07:00
Andrew Kelley
de81c504b1 CLI: allow -femit-implib when building .exe files too 2021-12-07 01:17:50 -07:00
Andrew Kelley
0812b57466
Merge pull request #10288 from SpexGuy/test-build
Add test executable builds to build.zig
2021-12-07 00:09:33 -08:00
Andrew Kelley
274555be21 stage2: improve handling of the generated file builtin.zig
All Zig code is eligible to `@import("builtin")` which is mapped to a
generated file, build.zig, based on the target and other settings.

Zig invocations which share the same target settings will generate the
same builtin.zig file and thus the path to builtin.zig is in a shared
cache folder, and different projects can sometimes use the same file.

Before this commit, this led to race conditions where multiple
invocations of `zig` would race to write this file. If one process
wanted to *read* the file while the other process *wrote* the file, the
reading process could observe a truncated or partially written
builtin.zig file.

This commit makes the following improvements:
 - limitations:
   - avoid clobbering the inode, mtime in the hot path
   - avoid creating a partially written file
   - builtin.zig needs to be on disk for debug info / stack trace purposes
   - don't mark the task as complete until the file is finished being populated
     (possibly by an external process)
 - strategy:
   - create the `@import("builtin")` `Module.File` during the AstGen
     work, based on generating the contents in memory rather than
     loading from disk.
   - write builtin.zig in a separate task that doesn't have
     to complete until the end of the AstGen work queue so that it
     can be done in parallel with everything else.
   - when writing the file, first stat the file path. If it exists, we are done.
   - otherwise, write the file to a temp file in the same directory and atomically
     rename it into place (clobbering the inode, mtime in the cold path).
 - summary:
   - all limitations respected
   - hot path: one stat() syscall that happens in a worker thread

This required adding a missing function to the standard library:
`std.fs.Dir.statFile`. In this commit, it does open() and then fstat()
which is two syscalls. It should be improved in a future commit to only
make one.

Fixes #9439.
2021-12-06 23:30:18 -08:00
Michael Dusan
a711fcbbfa ci: linux: supply on_master_sucess with VERSION
- move on_master_success to the package step
- add required secret availability for packaging

This replaces a1b79ea5857a52332d9da49d261a7fd04e52a466 .
2021-12-06 23:13:06 -08:00
Lee Cannon
7d1f47313d stage2: fix TracyAllocator bugs 2021-12-06 16:09:12 -08:00
Andrew Kelley
a3d9cd1c1d std.os: handle ETXTBSY from open() 2021-12-06 16:29:39 -07:00
Martin Wickham
5924994045 Fix run() for test_exe steps 2021-12-06 15:57:19 -06:00
Andrew Kelley
ca974de521 stage2: fix double-free when error reading cached ZIR
We already had a `keep_zir` flag. No need to call deinit manually.
2021-12-06 14:29:49 -07:00
Andrew Kelley
003bba47cc libunwind: patch to silence warning
Not sure why this warning is being emitted; let's reexamine it on the
next libunwind upgrade. I triggered it with this:

zig c++ -o hello hello.cpp -target x86_64-windows
2021-12-06 14:29:40 -07:00
Martin Wickham
3771e77667 Add test executable builds to build.zig 2021-12-06 14:55:35 -06:00
Jeremy Fillingim
fffa89700e Fix test label off-by-one error (#10277).
The console test# label [test#/#tests] was being generated inside
refreshWithHeldLock (in lib/std/Progress.zig), using the number of
completed items. This was being incremented by 1 when displayed,
which is not required.
2021-12-06 12:18:41 -08:00
Jakub Konka
933999dad1
Merge pull request #10280 from ziglang/zld-rel-code-path
macho: add preliminary non-prealloc path to the linker
2021-12-06 09:52:09 +01:00
Martin Wickham
2af94e76a3
Add emit path options to emit args in build.zig (#10278) 2021-12-05 19:54:33 -05:00
Jakub Konka
71d19318e7 macho: do not preserve temp symbol names
and do not write out local symbol in MachO's symbol table if global
symbol exists with the same name.
2021-12-06 00:09:51 +01:00
Jakub Konka
3ac973c706 macho: fix incremental codepath for linking objects 2021-12-06 00:00:50 +01:00
Andrew Kelley
a7828c261a
Merge pull request #10276 from tiehuis/musl-trig-reimpl
sin/cos/tan musl reimplementation
2021-12-05 14:49:04 -08:00
Jakub Konka
124e942714 macho: refactor logging and function names 2021-12-05 23:26:30 +01:00
Jakub Konka
397a11c107 macho: sort sections when linking stage1 binary 2021-12-05 22:46:53 +01:00
Jakub Konka
c86f2402d0 macho: don't prealloc sections when stage1 2021-12-05 22:46:46 +01:00
Luuk de Gram
9e03cf9489 wasm: Initial behavior tests succeeding
- Correctly load slice value on stack
- Implement WrapErrorUnionErr and payload
- Implement trunc, fix sliceLen and write undefined
- Implement slice as return type and argument

Note: This also fixes a memory leak for inferred error sets, and for usingnamespace
2021-12-05 12:19:01 -08:00
Marc Tiehuis
b02384e03d std/math: hide internal cos/tan functions 2021-12-06 01:17:01 +13:00
Marc Tiehuis
d28b445329 std/math: fix __rem_pio2 underflow
Error in translated code. Found by fuzzing.
2021-12-06 01:02:09 +13:00
Marc Tiehuis
149444723f std/math: Add test cases for #9901
Closes #9901.
Closes #9902.
2021-12-06 01:02:09 +13:00
Marc Tiehuis
e24398361d std/math: replace golang sin/cos/tan with musl sin/cos/tan 2021-12-06 01:02:09 +13:00
Michael Dusan
a1b79ea585 ci: linux: pass VERSION on_master_success
Cache the VERSION value for use with linux_on_mster_success.
This replaces 117c0460d3f5ff05d5e2c51c2aa376b56be13096 .
2021-12-05 00:31:59 -08:00
Andrew Kelley
f7cbd92e6c Revert "Merge pull request #10270 from Luukdegram/behaviour-tests"
This reverts commit 725267f7c20f0ba588b472048a8c1fe1a328c714, reversing
changes made to 2dae860de3494f97c9477af9282fe0131ff5c4cb.

This test is failing:

```zig
pub fn main() u8 {
    var e = foo();
    const i = e catch 69;
    return i;
}

fn foo() anyerror!u8 {
    return 5;
}
```

It's returning 69 instead of the expected value 5.
2021-12-04 21:55:50 -07:00
Michael Dusan
117c0460d3 ci: linux: pass VERSION on_master_success 2021-12-04 20:28:26 -08:00
joachimschmidt557
2f18c5955a stage2 ARM: Implement calling with stack parameters 2021-12-04 18:16:23 -08:00
Andrew Kelley
725267f7c2
Merge pull request #10270 from Luukdegram/behaviour-tests
Stage2: Initial behavior tests succeeding
2021-12-04 18:16:05 -08:00
Zapolsky Anton
2dae860de3
Added an explicit type for the termios constants (#10266)
Adds the `tcflag_t` type to the termios constants.
This is made to allow bitwise operations on the termios
constants without an integer cast, e.g.:

```zig
var raw = try std.os.tcgetattr(std.os.STDIN_FILENO);
raw.lflag &= std.os.linux.ECHO | std.os.linux.ICANON;
```
instead of

```zig
var raw = try std.os.tcgetattr(std.os.STDIN_FILENO);
raw.lflag &= ~@intCast(u32, std.os.linux.ECHO | std.os.linux.ICANON);
```

Contributes to #10181
2021-12-04 16:24:55 -05:00
matu3ba
282e2c714f
compiler_rt: add __ffssi2, __ffsdi2 and __ffsti2 (#10268)
See #1290
2021-12-04 16:23:33 -05:00
Andrew Kelley
daa3e0bbb4 ci: fix update-download-page and remove bashism 2021-12-04 14:20:46 -07:00
Luuk de Gram
74a5f4d848
wasm: Initial behavior tests succeeding
Note: This also fixes a memory leak for inferred error sets, and for usingnamespace
2021-12-04 21:17:17 +01:00
Luuk de Gram
b7fe958f44
wasm: Implement slice as return type and argument 2021-12-04 19:22:08 +01:00
Luuk de Gram
52fb044669
wasm: Implement trunc, fix sliceLen and write undefined 2021-12-04 19:22:08 +01:00
Luuk de Gram
96a4692f94
wasm: Correctly load slice value on stack 2021-12-04 19:22:08 +01:00
Luuk de Gram
1777fb25bc
wasm: Implement WrapErrorUnionErr(payload) 2021-12-04 19:22:07 +01:00
Andrew Kelley
e81fda9823 ci: make the on_master_success script fail on missing args 2021-12-03 20:34:54 -07:00
Michael Byrne
7e2fae10c9
Add documentation for sentinel-terminated slicing (#10010)
closes #9680
2021-12-03 20:37:48 -05:00