13640 Commits

Author SHA1 Message Date
Robin Voetter
25329ca852 SPIR-V: Split out registry from gen_spirv_spec.zig 2021-05-14 19:49:32 +02:00
Robin Voetter
42f2ff6ec9 SPIR-V: Re-generate spec.zig 2021-05-14 19:49:32 +02:00
Robin Voetter
6d1a4c8b1e SPIR-V: Adapt spec generator to new render api 2021-05-14 19:49:32 +02:00
Robin Voetter
d45e7dfc24 SPIR-V: Begin generating types 2021-05-14 19:49:32 +02:00
Robin Voetter
fa3afede58 SPIR-V: Set default ofmt to spirv 2021-05-14 19:49:32 +02:00
Jakub Konka
00ebbe6df2 macho: require _main as global export in self-hosted
Clean up type and description flags generation for exports
in self-hosted MachO backend.
2021-05-14 13:08:56 +02:00
Jakub Konka
8eea5eddf7 macho: fix bug with symbol growth and realloc 2021-05-14 11:02:43 +02:00
Andrew Kelley
826179bff4 stage2: -lunwind is handled specially
* `-lc++` now implies `-lc`.
 * `-lunwind` is now pulled out into a separate `link_libunwind` flag in
   the frontend driver code. This allows a project to request zig to
   provide libunwind even if the default situation that causes it to be
   implicitly added, is not active.
 * build.zig: ask for -lunwind when building the self-hosted compiler on
   Linux. Otherwise we get linker errors with unresolved symbols to
   libunwind.
2021-05-13 22:42:57 -04:00
Andrew Kelley
76a259799d stage2: only build and link libunwind when linking libc++ 2021-05-13 17:40:39 -04:00
Andrew Kelley
173142cc36
Merge pull request #8611 from shachaf/precedence
parser: Use an operator precedence table
2021-05-13 17:40:03 -04:00
Jakub Konka
1b222cb1ff start.zig: export main with strong linkage
Unmarks `_main` as weak symbol making it global (the entire linked
program) in scope.
2021-05-13 17:24:32 -04:00
Jakub Konka
402264ab0e Add experimental Darling support for cross testing macOS
* for cross testing stage2 tests, we use `darling shell` command
  since the path to the tested binary is relative to cwd
* for the `zig test` command, we simply use `darling` since the
  path to the binary is absolute
2021-05-13 20:31:33 +02:00
Matthew Borkowski
e902c19c0e
std/json: Fix premature closing brace being considered valid JSON
return error from StreamingParser when reading closing brace when expecting value for an object key
2021-05-13 11:11:28 +02:00
Jakub Konka
4f71852c10 Merge branch 'streamline-stage2-build-script' 2021-05-13 08:24:46 +02:00
Jakub Konka
1aee896cae Merge branch 'master' into streamline-stage2-build-script 2021-05-13 08:24:21 +02:00
Jakub Konka
6c3050e3c3 macos: link static libc++ when building stage2
With this change, it is now possible to use zig-bootstrap as the
initial C/C++ compiler, and then build stage2 with the resultant
stage1 without the need to link any system libs!
2021-05-13 07:55:59 +02:00
Andrew Kelley
4b59f56434 stage2: build and provide libunwind when compiling for native libc
5ac91794cce8bd53916a378815be01e4365d53d9 made Zig link against the
system libc when targeting the native C ABI. However this made it stop
putting libunwind.a on the linker line when it needed to sometimes,
causing undefined symbols when linking against C++ code.
2021-05-12 22:29:21 -07:00
Isaac Freund
459c9f0535 stage2: fix build on OpenBSD/NetBSD
Apparently these systems do not provide libdl or librt.
2021-05-13 00:44:56 -04:00
Andrew Kelley
799d1f0d36 build system: fix wrong glibc dir passed to qemu for i386
Without this, and with `-Denable-qemu -Denable-foreign-glibc`,
i386-linux-gnu tests failed because the `-L` path passed to qemu
was "i386-linux-gnu" (nonexistent) rather than "i686-linux-gnu".

Fixes std lib and behavior tests when using these options to enable
test coverage with cross compiled glibcs.
2021-05-12 20:34:54 -07:00
Matthew Borkowski
40a47eae65 fix shrinkAndFree and remove shrinkRetainingCapacity in PriorityQueue and PriorityDequeue 2021-05-12 18:33:25 -04:00
Evan Haas
19aab5302c translate-c: Ensure extra_cflags are passed to clang
Additionally ensure that the Zig cache incorporates any extra cflags when
using translate-c.

Fixes the issue identified in #8662
2021-05-12 18:17:45 -04:00
Andrew Kelley
43da102920
Merge pull request #8698 from ifreund/scanZ
std/mem: add sliceTo(), deprecate spanZ(), lenZ()
2021-05-12 18:15:36 -04:00
LemonBoy
893a428656 stage2: Drop LLVM's host CPU detection method as fallback
The CPU detection code is nearly at feature parity, we do support
detecting the native CPU on Sparc systems and macos, our ARM/AArch64
model list is quite comprehensive and so is our PPC one.

The only missing pieces are:
- ARM32 detection on Darwin hosts (I don't think anybody is planning on
  running the compiler on a old-ass iPhone)
- s390x detection on Linux hosts, this can be easily added at a later
  stage.
2021-05-12 14:03:59 -04:00
Jakub Konka
7b77246289 macho: allow overriding stack size in binary 2021-05-12 19:25:26 +02:00
Michael Dusan
fb8527b289 azure: bump timeout for macos-arm64 2021-05-12 06:38:01 -04:00
Isaac Freund
cd7b5a3718
std/mem: add sliceTo(), deprecate spanZ(), lenZ()
The current spanZ() function will not scan for a 0 terminator if the
type is not 0 terminated. This encourages using 0 terminated array
types to bind C arrays which hold 0 terminated strings. However, this is
a big footgun as nothing in the C type system guarantees there to be a
0 terminator at the end of the array and if there is none this becomes
Illegal Behavior in Zig.

To solve this, deprecate spanZ() and lenZ(), adding a new sliceTo()
function that always scans for the given terminator even if the type is
not sentinel terminated.
2021-05-12 11:24:49 +02:00
Jakub Konka
53acb54fad
Bump zig-bootstrap and wasmtime versions in linux CI (#8738)
* Bump zig-bootstrap and wasmtime versions in linux CI

* Revert wasm stage2 test fixup; point to issue
2021-05-12 09:56:55 +02:00
LemonBoy
e260cfae85 stage2: Add CPU feature detection for macos
This is mostly meant to detect the current and future AArch64 core types
as the x86 part is already taken care of with OS-independent machinery.
2021-05-12 09:43:49 +02:00
Michael Dusan
30ace64fc4 bsd: detect os version
- netbsd, dragonly: use sysctlbyname
- openbsd: use sysctl
- updated default semver ranges
2021-05-11 22:05:08 -04:00
Andrew Kelley
e3dd4dc91d
Merge pull request #8737 from ifreund/link-system-libc
stage2: use system libc when targeting the native OS/ABI
2021-05-11 20:28:14 -04:00
Isaac Freund
e6881d4373
std/json: fix previous commit for std.testing changes 2021-05-11 23:09:25 +02:00
Matthew Borkowski
1b87d45494 fix a double free in parse when duplicate_field_behavior is UseLast and a leak in parse when allocating a single item 2021-05-11 22:54:02 +02:00
Isaac Freund
c036957521
std.meta.Elem: support all optional types 2021-05-11 22:22:21 +02:00
Isaac Freund
f8cf106fc9
ci: unset CC/CXX before make install on macos arm64
Having these set causes zig's native libc detection code to fail.
2021-05-11 21:30:13 +02:00
Isaac Freund
3b2c9ef828
stage2: link all libc components if using system libc 2021-05-11 21:30:13 +02:00
Isaac Freund
01e30002c5
stage2: error if requested glibc version too high
Falling back to the max provided glibc version is insufficient as
linking to shared objects compiled against the requested version
will fail.
2021-05-11 21:30:13 +02:00
Isaac Freund
5ac91794cc
stage2: use system libc when targeting the native OS/ABI
Currently zig will always try to build its own libc and compile against
that. This of course makes sense for cross-compilation, but can cause
problems when targeting the native OS/ABI.

For example, if the system uses a newer glibc version than zig ships
zig will fall back to using the newest version it does ship. However
this causes linking system libraries to fail as they are built against a
different glibc version than the zig code is built against.

To remedy this, simply default to linking the system libc when targeting
the native OS/ABI.
2021-05-11 21:30:07 +02:00
Andrew Kelley
ace5714551
Merge pull request #8705 from LemonBoy/libc-fix
32bit glibc fixes
2021-05-11 15:15:00 -04:00
Andrew Kelley
c3d4733a00 test runner: avoid an "out of memory" error return trace entry
The long term solution to this will be #1923
2021-05-11 11:47:22 -07:00
Andrew Kelley
65d279bc05 test runner: print error return trace after failed test 2021-05-11 10:50:17 -07:00
LemonBoy
8bb58fb428 std: Fix offset param splitting for preadv/pwritev
The kernel interface expects the offset as a low+high pair even on BE
systems.
2021-05-11 15:49:53 +02:00
Matthew Borkowski
75ed835d08 fix AutoArrayHashMap's store_hash logic 2021-05-11 16:14:23 +03:00
LemonBoy
2bb8e1ff55 stage2: Change libc components' linking order
Use the same order as Clang (and, by extension, GCC) for the three most
important libc components: lm comes first, followed by lpthread and then
lc.
2021-05-11 12:43:58 +02:00
LemonBoy
780f510ac0 std: Fix fallocate offset type 2021-05-11 12:33:48 +02:00
LemonBoy
c065e12dbe std: Add more tests, fix broken code
It turns out that nothing in the test suite was exercising
preadv/pwritev and so the previous commits silently broke them.

Adding tests revealed readvAll and preadvAll were also broken and not
covered by any test.
2021-05-11 12:33:48 +02:00
LemonBoy
31f1cc9a0d std: Harmonize use of off_t between libc and Zig impls
Let's follow the libc/kernel convention and use an i64 for offsets, we
bitcast as needed and avoid the useless conditional casts.
2021-05-11 12:33:48 +02:00
LemonBoy
f4a05286d3 std: Fix cast that's sometimes invalid 2021-05-11 12:33:48 +02:00
LemonBoy
93f48189f1 test: Enable i386-linux-gnu test
This is needed to catch any possible problem with executables linking to
32bit glibc.
2021-05-11 12:33:48 +02:00
LemonBoy
679876ba72 c: Fix prototypes for bcmp and memcmp
They return c_int and not isize.
2021-05-11 12:33:47 +02:00
LemonBoy
a909db6aea std: Prefer 64bit libc functions where possible
While musl decided to hard-wire off_t to a 64bit quantity, glibc is much
older and defaults to 32bit offsets and offers some -64 suffixed
versions of I/O functions.

There's a weird mix-up of types: sometimes off_t is used, sometimes not,
sometimes it's defined as a signed quantity and sometimes as an unsigned
one, but we'll sort this problem later.
2021-05-11 12:33:47 +02:00