Commit graph

16176 commits

Author SHA1 Message Date
Andrew Kelley
a18bf7a7bf Release 0.9.0 2021-12-20 13:13:19 -07:00
joachimschmidt557
ecf0050a92 stage2 AArch64: Implement saving callee-saved registers 2021-12-19 23:24:44 -08:00
Kenta Iwasaki
5c7f2ab011 stage1: deal with BPF not supporting @returnAddress()
Make `@returnAddress()` return for the BPF target, as the BPF target for
the time being does not support probing for the return address. Stack
traces for the general purpose allocator for the BPF target is also set
to not be captured.
2021-12-19 23:22:05 -08:00
Lee Cannon
16b7535497
Allocator: allocBytes and reallocBytes (#10352)
Closes #10348
2021-12-19 01:58:13 -05:00
Andrew Kelley
80b21cef5a langref: fix tidy html error
regressed in 8468b544e8
2021-12-18 23:57:00 -07:00
Andrew Kelley
07c03f85a8 zig test: fix test runner detection of tty
Before, `std.Progress` was printing unwanted stuff to stderr. Now, the
test runner's logic to detect whether we should print each test as a
separate line to stderr is properly activated.
2021-12-18 23:45:32 -07:00
Isaac Freund
9f9f215305
stage1, stage2: rename c_void to anyopaque (#10316)
zig fmt now replaces c_void with anyopaque to make updating
code easy.
2021-12-19 00:24:45 -05:00
bnprks
8468b544e8
Add Vector documentation (#10303)
* Create Vector language documentation

Main changes to docs:
1. Create brief documentation on Zig vector types with code example
2. Get rid of the SIMD sub-heading under the main Vectors heading,
and update links accordingly
3. Add an example to the `@shuffle` docs
2021-12-18 23:40:57 -05:00
Jakub Konka
a08137330c macho: handle -install_name option for dylibs/MachO
The status quo for the `build.zig` build system is preserved in
the sense that, if the user does not explicitly override
`dylib.setInstallName(...);` in their build script, the default
of `@rpath/libname.dylib` applies. However, should they want to
override the default behaviour, they can either:

1) unset it with

```dylib.setIntallName(null);```

2) set it to an explicit string with

```dylib.setInstallName("somename.dylib");```

When it comes to the command line however, the default is not to
use `@rpath` for the install name when creating a dylib. The user
will now be required to explicitly specify the `@rpath` as part
of the desired install name should they choose so like so:

1) with `build-lib`

```
zig build-lib -dynamic foo.zig -install_name @rpath/libfoo.dylib
```

2) with `cc`

```
zig cc -shared foo.c -o libfoo.dylib -Wl,"-install_name=@rpath/libfoo.dylib"
```
2021-12-18 17:55:53 -08:00
Jacob G-W
9a8fdbe0a0 plan9 linker: fix off by 1 error 2021-12-18 17:54:20 -08:00
Andrew Kelley
6adecdc58a init-exe template: build.zig: setTarget on the tests 2021-12-18 17:29:46 -07:00
fubark
88ea2cb757 Make Builder.spawnChildEnvMap public 2021-12-18 15:25:09 -08:00
joachimschmidt557
9892684d35 stage2 ARM: spill insts currently in compare flags if necessary 2021-12-18 15:23:25 -08:00
Jens Goldberg
5b29b4ffa6 Fix MIPS inline assembly clobbers 2021-12-18 14:42:01 -08:00
Andrew Kelley
6d04de706a Revert "std: optimize hash_map probe loop condition"
This reverts commit 11803a3a56.

Observations from the performance dashboard:
 * strictly worse in terms of CPU instructions
 * slightly worse wall time (but this can be noisy)
 * sometimes better, sometimes worse for branch predictions

Given that the commit was introducing complexity for optimization's
sake, these performance changes do not seem worth it.
2021-12-17 16:56:43 -07:00
sentientwaffle
11803a3a56 std: optimize hash_map probe loop condition
See https://github.com/ziglang/zig/pull/10337 for context.

In #10337 the `available` tracking fix necessitated an additional condition on the probe loop in both `getOrPut` and `getIndex` to prevent an infinite loop. Previously, this condition was implicit thanks to the guaranteed presence of a free slot.

The new condition hurts the `HashMap` benchmarks (https://github.com/ziglang/zig/pull/10337#issuecomment-996432758).

This commit removes that extra condition on the loop. Instead, when probing, first check whether the "home" slot is the target key — if so, return it. Otherwise, save the home slot's metadata to the stack and temporarily "free" the slot (but don't touch its value). Then continue with the original loop. Once again, the loop will be implicitly broken by the new "free" slot. The original metadata is restored before the function returns.

`getOrPut` has one additional gotcha — if the home slot is a tombstone and `getOrPut` misses, then the home slot is is written with the new key; that is, its original metadata (the tombstone) is not restored.

Other changes:

- Test hash map misses.
- Test using `getOrPutAssumeCapacity` to get keys at the end (along with `get`).
2021-12-17 15:21:41 -08:00
Andrew Kelley
e8b39960bb
Merge pull request #10342 from Arnavion/pq-comparefn-context
std.priority_{de,}queue: allow comparator to take context parameter
2021-12-17 14:34:32 -08:00
Felix "xq" Queißner
c1745b2896 Actually installs the implib for DLLs. 2021-12-17 14:31:59 -08:00
sentientwaffle
ef0566df78 std: count hash_map tombstones as available
When entries are inserted and removed into a hash map at an equivalent rate (maintaining a mostly-consistent total count of entries), it should never need to be resized. But `HashMapUnmanaged.available` does not presently count tombstoned slots as "available", so this put/remove pattern eventually panics (assertion failure) when `available` reaches `0`.

The solution implemented here is to count tombstoned slots as "available". Another approach (which hashbrown (b3eaf32e60/src/raw/mod.rs (L1455-L1542)) takes) would be to rehash all entries in place when there are too many tombstones. This is more complex but avoids an `O(n)` bad case when the hash map is full of many tombstones.
2021-12-16 19:11:53 -08:00
Lee Cannon
d54ba76e40 TracyAllocator: correct order of free and alloc 2021-12-16 19:09:57 -08:00
Samarth Hattangady
1fa5a1959d std.time.epoch: fix issue in documentation
std.time.epoch.DaySeconds.getHoursIntoDay said that hours goes from
0-11. should be 0-23.
2021-12-16 19:08:58 -08:00
Andrew Kelley
58f669dc8c
Merge pull request #10339 from ziglang/update-glibc
update glibc to 2.34
2021-12-16 13:16:14 -08:00
Andrew Kelley
9257669cd4 glibc: do not pass -DSHARED to any of the libc_nonshared.a sources
This essentially reverts 6a12dce207 but it
leaves breadcrumbs in the source explaining why things are the way they
are.
2021-12-16 03:34:20 -07:00
Andrew Kelley
1b0be5c1ce glibc: update libc-modules.h 2021-12-16 03:33:47 -07:00
Andrew Kelley
e03c951a79 glibc: libc_nonshared.a: add missing includes for inttypes.h
I don't know where glibc thinks uintptr_t is coming from, but here it
is.
2021-12-16 03:01:13 -07:00
Andrew Kelley
e1436873a3 glibc: don't pass -frounding-math
glibc wants this flag but clang (our C compiler) does not support it.
2021-12-16 03:01:13 -07:00
Andrew Kelley
37fa6f955d glibc: add stat_t64_cp.c to libnonshared.a
Fixes 32-bit architectures.
2021-12-16 03:01:13 -07:00
Andrew Kelley
afb1652c50 glibc: i386: make glibc not use invalid inline asm syntax 2021-12-16 03:01:13 -07:00
Andrew Kelley
bf2bd8e722 glibc: patches to make fstatat.c and fstatat64.c compile
instead of importing every header file under the sun, I copied a couple
inline functions into these files to make them work.
2021-12-16 03:01:13 -07:00
Andrew Kelley
6a12dce207 glibc: fix some inconsistent flags with upstream
This more correctly matches what glibc does to build the objects
inside libnonshared.a.
2021-12-16 03:01:13 -07:00
Andrew Kelley
1530203c80 glibc: update default cross-compile version to 2.19
This number tracks the glibc version in the oldest still-active LTS
version of Debian, which is Jessie, extended LTS expiring in June 2022,
at which point this number can be bumped again.
2021-12-16 03:01:13 -07:00
Andrew Kelley
c9863c0a0c CLI: helpful error message when libc requested but not provided 2021-12-16 03:01:13 -07:00
Andrew Kelley
c8af00c66e glibc: fix inconsistency of powerpc ABI mapping
See the commit message of 5b6d26e97b for
an explanation. This is the same thing but for powerpc instead of mips.
2021-12-16 03:01:13 -07:00
Andrew Kelley
5aeffab693 glibc: import sysdep.h from upstream
it's needed for mipsel-linux-gnueabihf
2021-12-15 19:12:24 -07:00
Andrew Kelley
5b6d26e97b glibc: fix inconsistency of mips ABI mapping
Before this commit, glibc headers did the following mapping:

 * (zig) mipsel-linux-gnu      => (glibc) mipsel-linux-gnu
 * (zig) mipsel-linux-gnu-soft => (glibc) (none)
 * (zig) mips-linux-gnu        => (glibc) mips-linux-gnu
 * (zig) mips-linux-gnu-soft   => (glibc) (none)

While the glibc ABI stubs used the (zig) gnueabi and gnueabihf ABIs,
and the stage2 available_libcs array listed:

 * (zig) mipsel-linux-gnu
 * (zig) mips-linux-gnu

The problem is the mismatch between the ABI component of the headers and
the stubs.

This commit makes the following clarifications:

 * (zig) mips-linux-gnueabi     means soft-float
 * (zig) mipsel-linux-gnueabi   means soft-float
 * (zig) mips-linux-gnueabihf   means hard-float
 * (zig) mipsel-linux-gnueabihf means hard-float

Consequently, the glibc headers now do this mapping:

 * (zig) mips-linux-gnueabihf   => (glibc) mips-linux-gnu
 * (zig) mipsel-linux-gnueabihf => (glibc) mipsel-linux-gnu
 * (zig) mips-linux-gnueabi     => (glibc) mips-linux-gnu-soft
 * (zig) mipsel-linux-gnueabi   => (glibc) mipsel-linux-gnu-soft

The glibc ABI stubs are unchanged, and the stage2 available_libcs
array's 2 entries are modified and it gains 2 more:

 * (zig) mipsel-linux-gnueabi
 * (zig) mipsel-linux-gnueabihf
 * (zig) mips-linux-gnueabi
 * (zig) mips-linux-gnueabihf

Now everything is consistent. Zig no longer recognizes a `mips-linux-gnu`
triple; one must use `mips-linux-gnueabi` (soft float) or
`mips-linux-gnueabihf` (hard float).
2021-12-15 19:09:50 -07:00
Arnavion
22e1d92d3e std.priority_dequeue: allow comparator to take a context parameter 2021-12-15 17:46:10 -08:00
Arnavion
82e8930656 std.priority_queue: allow comparator to take a context parameter 2021-12-15 17:46:04 -08:00
Andrew Kelley
e977455f7c glibc: improve RISC-V support
* omit crti.o / crtn.o for this architecture
 * add missing entry.h header from upstream
2021-12-15 18:34:27 -07:00
Andrew Kelley
59a3a27a68 glibc: add missing riscv stubs headers 2021-12-15 18:34:27 -07:00
Andrew Kelley
21cffe22d4 glibc: remove duplicate files between generic-glibc/ and glibc/include/ 2021-12-15 18:34:27 -07:00
Andrew Kelley
4d48948b52 glibc: pass -D__GLIBC_MINOR__=XX
instead of hard-coding it. This means that C code has accurate glibc
version information in the preprocessor.
2021-12-15 17:52:27 -07:00
Andrew Kelley
694f424fc7 glibc: update abilists file
This one includes riscv32 and riscv64 targets.
2021-12-15 17:50:44 -07:00
Andrew Kelley
d9fe0d2d6b tools/update_glibc: ignore some more files 2021-12-15 15:28:37 -07:00
Andrew Kelley
3dcd3612dc glibc: use linux-specific files for nonshared
Upstream, some of the nonshared functions moved to be different for hurd
and for linux. Since our glibc is linux-only we update to use the
linux-specific files.

This fixes std lib tests for x86_64 when linking glibc.
2021-12-15 15:23:56 -07:00
Andrew Kelley
19ca2415f2 update glibc start files to 2.34
This commit introduces tools/update_glibc.zig to update the start files
for next time.

Some notable changes in recent glibc:

 * abi-note.S has been changed to abi-note.c but we resist the change to
   keep it easier to compile the start files.
 * elf-init.c has been deleted upstream. Further testing should be done
   to verify that binaries against glibc omitting elf-init.c still run
   properly on oldel glibc linux systems.

Closes #4926
2021-12-15 14:30:03 -07:00
Andrew Kelley
1edf8efa42 update glibc headers to 2.34
closes #10308
2021-12-15 14:30:03 -07:00
Andrew Kelley
877a1f2a29 std.os: fix error codes for execve
execve can return EBADLIB on Linux. I observed this when passing
an x86_64 interpreter path to qemu-i386.

This error code is Linux and Solaris-only. I came up with an improved
pattern for dealing with OS-specific error codes.
2021-12-15 14:23:32 -07:00
Andrew Kelley
3532abe0c6 compiler_rt: reorganize in a way that stage2 understands
Before this commit, stage2 behavior tests are regressed; it cannot build
compiler-rt.
2021-12-15 14:23:28 -07:00
Andrew Kelley
e45680cab5
Merge pull request #10341 from ziglang/stage2-tests
stage2: refactor x86_64 and macOS tests
2021-12-15 12:47:11 -08:00
Arnav Singh
09f70bdd91
std.bounded_array: support inserting a new value at the end (#10340)
Since `BoundedArray.insert` internally reserves space for the element
to be inserted, it can support inserting at the position that is
the current length of the array. Change the check for the insertion position
to allow this.
2021-12-15 20:10:34 +01:00