Commit Graph

89 Commits

Author SHA1 Message Date
Andrew Kelley
af7b6713d9 update zig1.wasm 2024-07-22 14:26:17 -07:00
Jacob Young
4f742c4cfc dev: introduce dev environments that enable compiler feature sets 2024-07-19 22:35:33 -07:00
Andrew Kelley
d404d8a363
Merge pull request #20593 from jacobly0/more-races
InternPool: fix more races
2024-07-14 17:32:51 -07:00
kcbanner
c318710653 zig.h: expand zig_msvc_atomic_load_ into version for relaxed, acquire, and seq_cst 2024-07-13 19:45:45 -04:00
kcbanner
bc28454b43 zig.h: replace _InterlockedExchangeAdd with a plain volatile load
This was causing zig2.exe to crash during bootstrap, because there was an atomic
load of read-only memory, and the attempt to write to it as part of the (idempotent)
atomic exchange was invalid.

Aligned reads (of u32 / u64) are atomic on x86 / x64, so this is replaced with an
optimization-proof load (`__iso_volatile_load8*`) and a reordering barrier.
2024-07-13 17:46:24 -04:00
Jacob Young
d72a8db2db update zig1.wasm
This allows using atomics on packed structs in the compiler.
2024-07-13 04:47:38 -04:00
kcbanner
0d12caee29 - Fix ypedef -> typedef 2024-06-21 00:12:13 -04:00
Jonathan Marler
1165e13c25 wasm2c: avoid indexing null pointer triggering undefined behavior
Using zig cc to compile and run wasm2c on zig.wasm on Windows triggers
what appears to be a sanitizer crash.  The FuncGen reuse array pointer is
initialized to null and at some point it's resized to a length of zero,
which triggers this code to execute:

    memcpy(&self->reuse[self->reuse_i], &self->reuse[reuse_top], sizeof(uint32_t) * reuse_n);

Given the current values, this equates to:

    memcpy(&(NULL)[0], &(NULL)[0], 0);

Taking the address of the first element of a null pointer doesn't trigger
any actual runtime problem, since the pointer won't be dereferenced because
were passing 0 as the length to memcpy, however, it seems that the C spec
considers indexing a null pointer to be undefined behavior even if you
don't use the resulting value (or are just taking the address of an
indexed pointer).
2024-06-17 14:34:52 -04:00
Andrew Kelley
80f38c0cbb update zig1.wasm
In particular, contains fixes to the C backend that avoid tripping UBSAN
in clang 18.
2024-05-08 19:37:29 -07:00
Jacob Young
b66fd87a4c update zig1.wasm
Fixes cbe bugs affecting bootstrap.
2024-04-08 13:24:08 -04:00
Jacob Young
e5ba70bb5c update zig1.wasm
Removes the first argument of `@fieldParentPtr`.
2024-03-30 20:54:53 -04:00
Jacob Young
c011abc4dd wasm2c: fix allocation failure result 2024-03-23 11:32:37 +01:00
Jacob Young
edeed592ee update zig1.wasm
Removes `std.builtin.Type.Fn.alignment`.
2024-03-17 03:25:56 +01:00
Jacob Young
b60fc16b4f compiler: audit debug mode checks
* Introduce `-Ddebug-extensions` for enabling compiler debug helpers
 * Replace safety mode checks with `std.debug.runtime_safety`
 * Replace debugger helper checks with `!builtin.strip_debug_info`

Sometimes, you just have to debug optimized compilers...
2024-03-01 17:42:54 -08:00
Andrew Kelley
dff45c266e wasi.c: report no environment variables available
I moved part of the compiler that checks environment variables to the
standard library, so it doesn't have access to `build_options.only_c`
anymore, which means some environment variable checks are leaking into
the zig1.wasm build of zig. This logic still makes it return "no
environment variables found" though.
2024-02-27 22:55:00 -07:00
Andrew Kelley
0157e1196c compiler: JIT zig reduce
See #19063
2024-02-26 23:43:42 -07:00
cdrmack
d3cf911a80 remove unused local variables 2024-02-09 23:11:46 +02:00
Jacob Young
8fa7635419 stage1: implement fd_fdstat_get
I thought this might be needed, so may as well keep the implementation.
2024-02-04 03:48:29 +01:00
Andrew Kelley
5e2035da14 update zig1.wasm
Updates the way CLI parameters for modules and dependencies are
specified.

Old CLI: --mod a:a,b=c:d --deps a,b=c
New CLI: --dep a --dep b=c --mod a d
2024-01-01 19:49:07 -07:00
Jacob Young
0dbaa8d3ae zig.h: workaround for gcc f128 miscompilations 2023-11-12 17:30:24 -07:00
Andrew Kelley
2a81a0f388 stage1: we don't need have_stage1 config option anymore 2023-11-10 13:12:05 -07:00
Jacob Young
a67d378543 stage1: implement wasi seek shim 2023-11-09 20:12:47 -05:00
Andrew Kelley
6aedddf900 fix bootstrap 2023-11-03 20:53:38 -07:00
Xavier Bouchoux
69d6f2e1b8 build.zig: add support for using "zig c++" as the bootstrap c++ compiler
The build was previously failing with `error: unknown command: -print-file-name=libstdc++.a`
because the command invocation was
`zig -print-file-name=libstdc++.a`
instead of
`zig c++ -print-file-name=libstdc++.a`

note: .cxx_compiler_arg1 = "" instead of undefined to avoid breaking existing setups without requiring to run cmake again.
2023-10-16 23:07:04 +02:00
Andrew Kelley
9a09651019 update zig1.wasm
Notably, this contains bug fixes related to `@errorCast` which are
required by the changes to `std.io.Reader` in this branch, and the
compiler source code has a dependency on `std.io.Reader`.
2023-10-03 14:58:13 -07:00
Veikka Tuominen
0b1ba6eb52
update zig1.wasm 2023-10-01 17:16:34 +03:00
Andrew Kelley
9763573ebb
update zig1.wasm
Needed because the compiler used the now removed `@fabs` builtin and
instead depends on the new `@abs` builtin.
2023-09-27 11:30:02 -07:00
Andrew Kelley
6bd54a1d3e
update zig1.wasm
Notable changes in this update:

127198e58c fixes building zig2 artifact on
macOS Sonoma 14.0 (more specifically the SDK 14.0 linker).

a8d2ed8065 fixed some alignment edge
cases which is needed to do the store_hash=false change in the compiler
source code.

df5f0517b3 preserves result type
information through the address-of operator.
2023-09-24 15:54:33 -07:00
mlugg
ded628e4fa
update zig1.wasm
This is required for the compiler to make use of the new destructuring
syntax.

Signed-off-by: Andrew Kelley <andrew@ziglang.org>
2023-09-15 11:41:46 -07:00
Michael Dusan
3cf71580c4 build stage3: detect system libcxx
Detect system libcxx name with the CMake build system and convey that
information to build.zig via config.h so that the same system libcxx is
used for stage3.

This undoes the hacky search 901457d173 .

closes #17018
2023-09-03 08:38:03 +02:00
mlugg
3e1b676ac1
stage1: update zig1
This is necessary due to the CBE fixes in the previous commit.

Signed-off-by: Andrew Kelley <andrew@ziglang.org>
2023-08-20 12:40:10 -07:00
Andrew Kelley
47d5bf2616 update zig1.wasm
Needed due to the breaking changes to `@splat` which are used by the
self-hosted compiler.

This update also includes the improvement that allows casting builtins
to infer the result type through optionals and error unions.
2023-07-12 15:50:57 -07:00
Jacob Young
78eb3c5617 bootstrap: support aarch64 in 32-bit mode
* `CMakeLists.txt`: support the weird `uname -m` output.
 * `CMakeLists.txt`: detect and use the C compiler's default arm mode.
 * cbe: support gcc with both `f128` and `u128` emulated.
 * std.os.linux.thumb: fix incorrectly passed asm inputs.
2023-07-04 15:47:07 -07:00
mlugg
21ac0beb43 update zig1.wasm
Needed due to the breaking changes to casting builtins, which are used
by the compiler when building itself.

Note from Andrew: I re-ran update-zig1 on my PC and replaced this
commit.

Signed-off-by: Andrew Kelley <andrew@ziglang.org>
2023-06-24 16:56:54 -07:00
Eric Joldasov
a4d1edac8d stage1: update zig1.wasm after renaming "@XtoY" to "YfromX"
Note from Andrew: I re-ran update-zig1 on my pc and replaced this
commit.

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
Signed-off-by: Andrew Kelley <andrew@ziglang.org>
2023-06-19 12:45:01 -07:00
mlugg
22c6b6c9a9 Update zig1.wasm
This is needed in order to remove math.{min,max} from std in favour of
the builtins, since the builtins need the behavior fix from the previous
commit.

Note from Andrew: I updated this commit with zig1.wasm built by me.

Signed-off-by: Andrew Kelley <andrew@ziglang.org>
2023-06-16 13:43:32 -07:00
Andrew Kelley
f52189834c rename omit_pkg_fetching_code to only_core_functionality
No functional changes. This renames an internal build option to better
reflect how it is used.
2023-05-17 16:00:24 -07:00
Andrew Kelley
ab086b62cf update zig1.wasm
Looks like I might have messed up the wasm kernel in my recent branch causing some sporadic failures on the CI.

This file was built the following way:

1. check out d0311e28b3
2. do the cmake bootstrap
3. check out 57ea6207d3
4. `zig build update-zig1` and stash those modified files
5. check out 440b3df702 (master)
6. do the cmake bootstrap
7. `zig build update-zig1` to produce this commit
2023-04-30 10:54:20 -07:00
Andrew Kelley
fa200ca0ca update zig1.wasm
This is needed because bug fixes to the C backend are required in order
to actually update the standard library and compiler sources to use the
new `@memcpy` and `@memset` semantics.
2023-04-28 13:29:39 -07:00
Andrew Kelley
a8de15f66a update zig1.wasm
Needed due to the compiler depending on standard library APIs such as
ArrayList that contain `@memset` and `@memcpy` calls in them. The number
of parameters changed, so this is necessary for the compiler to build.
2023-04-25 11:23:41 -07:00
Andrew Kelley
3878586821 update zig1.wasm 2023-04-23 13:33:20 -07:00
Andrew Kelley
e2fe1907ec add c_char type
closes #875
2023-04-13 02:47:16 -04:00
Andrew Kelley
aa45854ec3 zig.h: fix typo for zig_trap definition 2023-04-08 09:54:32 -07:00
Andrew Kelley
ef5afbfcf4 zig.h: f16 fix for compiler_rt
See #15092
2023-04-06 08:40:02 -07:00
Andrew Kelley
eb19f73af5 update zig1.wasm 2023-04-05 23:27:50 -07:00
Andrew Kelley
1ed569e0b2 Merge remote-tracking branch 'origin/master' into llvm16 2023-03-16 17:33:24 -07:00
Lavt Niveau
5a26d1b426
Include signal.h to define SIGTRAP in Stage 1 compiler (#14867)
copy lib/zig.h to stage1/zig.h

In this case, it looks safe to backport over with no changes.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2023-03-10 13:36:43 +00:00
Jacob Young
e3cf9d1650 Module: rewrite zir caching logic
Multiple processes can sit waiting for the exclusive lock at the same
time, so we want to recheck whether it needs to be updated whenever
we get an exclusive lock.

This also fixes a race condition between one process truncating the
cache file and another process reading it without atomic locking.
2023-03-08 00:00:52 -05:00
Andrew Kelley
cdb9cc8f6b update zig1.wasm 2023-03-05 17:29:28 -07:00
Andrew Kelley
d399f8a489 Merge remote-tracking branch 'origin/master' into llvm16 2023-02-27 16:10:48 -07:00