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.
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).
* 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...
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.
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.
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`.
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.
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
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.
* `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.
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>
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>
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>
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
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.
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.
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.