6728 Commits

Author SHA1 Message Date
Luuk de Gram
09d6938df9
wasm: add atomics opcodes and refactoring
This adds the atomic opcodes for the Threads proposal to the
WebAssembly specification: https://github.com/WebAssembly/threads

PrefixedOpcode has been renamed to MiscOpcode as there's multiple
types of prefixed opcodes. This naming is similar to other tools
such as LLVM. As we now use the 0xFE prefix, we moved the
function_index MIR instruction as it was occupying the same value.
This commit includes renaming all related opcodes.
2023-03-18 20:13:30 +01:00
Luuk de Gram
09abd53da7
wasm-linker: refactor Limits and add flags
Rather than adding the flags "on-demand" during limits writing,
we now properly parse them and store the flags within the limits
itself. This also allows us to store whether we're using shared-
memory or not. Only when the correct flag is set will we set the
max within `Limits` or else we will leave it `undefined`.
2023-03-18 20:13:29 +01:00
Nicolas Sterchele
49d37e2d17 build-step: remove latest LogStep ref
LogStep was removed during the build parallel enhancement made in this
commit 58edefc6d1716c0731ee2fe672ec8d073651aafb
2023-03-18 15:08:53 -04:00
hequn
f56f3c5824
Enable IPv4 mapped address conversion in linux version getAddressList (#14916)
It seems like the original code of setsockopt is not effective because
i catch the EINVAL branch when uncomment this code, it should call
setsockopt before the bind call.

This should fix issue #14900.

Co-authored-by: Qun He <hawkbee@qq.com>
2023-03-17 15:58:02 -04:00
Motiejus Jakštys
9f2aa3fbee Build.zig_exe: make it sentinel-aware
This is useful for tests that want to `execve` zig directly. The string
is already null-terminated, so this will just expose it as such,
removing an extra allocation from the test.

Will be used in #14462
2023-03-17 15:54:09 -04:00
Bas Westerbaan
2089b3f193
tls: use post-quantum secure key exchange (#14920) 2023-03-17 17:51:24 +01:00
Motiejus Jakštys
e0dd20b02e
add BoundedArrayAligned (#14580)
This is useful for creating byte buffers of actually-different-things.
Copied the argument order from `Allocator.alignedAlloc`

I noted that `ArrayListAligned` is going out of it's way to not set the
alignment at comptime when it is not specified. However, I was not able
to do that the same way here, and good people on IRC, @ifreund in
particular (thanks!) assured me that

    [N]T align(@alignOf(T))

is equivalent to

    [N]T
2023-03-17 17:50:25 +01:00
Jacob Young
cfcd6698cd main: add debug option to dump unoptimized llvm ir 2023-03-17 01:57:14 -04:00
Andrew Kelley
68c7261e1d disable bad std lib tests
see tracking issue #14968
2023-03-16 18:25:59 -07:00
Evin Yulo
b3af5d076c Fix #14901: parseFloat parsing 0x successfully 2023-03-16 19:36:06 +02:00
mllken
da0509750a std.os: handle EPERM errno for bind 2023-03-16 17:41:58 +02:00
Jakub Konka
e1e414e62a std: move os/darwin.zig and related to c/darwin.zig
Move to c/darwin.zig as they really are libSystem/libc imports/wrappers.

As an added bonus, get rid of the nasty `usingnamespace`s which are now
unneeded.

Finally, add `os.ptrace` but currently only implemented on darwin.
2023-03-16 11:42:30 +01:00
Andrew Kelley
cdda395590 std lib tests: avoid cwd races by using std.testing.tmpDir 2023-03-15 10:48:15 -07:00
Andrew Kelley
a1058dd27b fix std.fs unit test to not be racey 2023-03-15 10:48:15 -07:00
Andrew Kelley
4aa5895d32 std.Build: fix invalid assumption about fifos
Previously this code asserted that a fifo's readable length was greater
than or equal to the length of its readable slice, which was an invalid
assertion.

This code avoids making that assumption.
2023-03-15 10:48:15 -07:00
Andrew Kelley
4f1382e581 add std.LinearFifo.readableSliceOfLen 2023-03-15 10:48:15 -07:00
Andrew Kelley
6d6f6a4ac6 std.os.windows.OpenFile: handle DELETE_PENDING
This error means that there *was* a file in this location on the file
system, but it was deleted. However, the OS is not finished with the
deletion operation, and so this CreateFile call has failed. There is not
really a sane way to handle this other than retrying the creation after
the OS finishes the deletion.
2023-03-15 10:48:15 -07:00
Andrew Kelley
717e2c8718 std.Build.Cache: make unit tests not depend on cwd
This makes them more resilient to being run multiple times by multiple
different processes at the same time.
2023-03-15 10:48:15 -07:00
Andrew Kelley
363d4a107d add compile log output to build runner 2023-03-15 10:48:15 -07:00
Andrew Kelley
37a7d2c78d std.Build.RunStep: fix handling spawn failure
The error was caught and created a Step failure rather than bubbling up
so that the interpreter logic could handle it. Fixes hundreds of test
failures on Windows.
2023-03-15 10:48:15 -07:00
Andrew Kelley
11de55d0dd std.Build.Cache: handle ENOENT on createFile race
Companion commit to 628fec41593a2d2eca8b504e4fe90de9823aeded
2023-03-15 10:48:15 -07:00
Andrew Kelley
63bd0fe58e use DEC graphics instead of Unicode for box drawing 2023-03-15 10:48:15 -07:00
Andrew Kelley
3e328c89b7 std.Build.CompileStep: remove setNamePrefix and add setName 2023-03-15 10:48:15 -07:00
Andrew Kelley
22d94eaf32 disable std lib unit tests that hard code port numbers
See tracking issue #14907
2023-03-15 10:48:15 -07:00
Andrew Kelley
2b0929929d std.Build.Cache: handle ENOENT on createFile race
There are no dir components, so you would think that this was
unreachable, however we have observed on macOS two processes racing
to do openat() with O_CREAT manifest in ENOENT.
2023-03-15 10:48:15 -07:00
Andrew Kelley
0f88ad8c72 std.Build.CompileStep: proper step dependency on headers
Rather than calling make() from within make().
2023-03-15 10:48:15 -07:00
Andrew Kelley
e098b287e1 std.fs.File.writevAll: fix behavior for 0-length vectors
The OS layer expects pointer addresses to be inside the application's
address space even if the length is zero. Meanwhile, in Zig, slices may
have undefined pointer addresses when the length is zero. So this
function now modifies the iov_base fields when the length is zero.

This is a companion commit to b4893eb05565b2cb033c6ed88617d73faf878455.
2023-03-15 10:48:15 -07:00
Andrew Kelley
a26a2e1a17 build runner: fix compilation errors on windows 2023-03-15 10:48:15 -07:00
Andrew Kelley
149aa9afb7 add a workaround for miscompilation regarding alignment
See tracking issue #14904
2023-03-15 10:48:15 -07:00
Andrew Kelley
bc79328dcf fix endianness when using test-runner in qemu 2023-03-15 10:48:15 -07:00
Andrew Kelley
a0dd2919eb std.build.RunStep: clean up some leftover mess
* Remove some functions that are no longer needed since
   EmulateableRunStep is gone.
 * Add removeEnvironmentVariable function.
 * Support printing environment variables in --verbose mode.
2023-03-15 10:48:14 -07:00
Andrew Kelley
61d7e31078 remove bad unit test from std lib
This unit test tested the command line arguments which were passed to
the test runner, which is not really something that unit tests are
supposed to observe.

The proper way to test command line argument parsing is with a
standalone test, where the set of command line arguments being tested
for are also being controlled by the test itself.
2023-03-15 10:48:14 -07:00
Andrew Kelley
ede5dcffea make the build runner and test runner talk to each other
std.Build.addTest creates a CompileStep as before, however, this kind of
step no longer actually runs the unit tests. Instead it only compiles
it, and one must additionally create a RunStep from the CompileStep in
order to actually run the tests.

RunStep gains integration with the default test runner, which now
supports the standard --listen=- argument in order to communicate over
stdin and stdout. It also reports test statistics; how many passed,
failed, and leaked, as well as directly associating the relevant stderr
with the particular test name that failed.

This separation of CompileStep and RunStep means that
`CompileStep.Kind.test_exe` is no longer needed, and therefore has been
removed in this commit.

 * build runner: show unit test statistics in build summary
 * added Step.writeManifest since many steps want to treat it as a
   warning and emit the same message if it fails.
 * RunStep: fixed error message that prints the failed command printing
   the original argv and not the adjusted argv in case an interpreter
   was used.
 * RunStep: fixed not passing the command line arguments to the
   interpreter.
 * move src/Server.zig to std.zig.Server so that the default test runner
   can use it.
 * the simpler test runner function which is used by work-in-progress
   backends now no longer prints to stderr, which is necessary in order
   for the build runner to not print the stderr as a warning message.
2023-03-15 10:48:14 -07:00
Andrew Kelley
ef5f8bd7c6 getExternalExecutor: fix aarch64 windows
std.zig.system.NativeTargetInfo.getExternalExecutor previously would
incorrectly communicate that wine could be used to run aarch64-windows
binaries on x86_64-linux, and x86_64-windows binaries on aarch64-linux.
Neither of these things are true.
2023-03-15 10:48:14 -07:00
Andrew Kelley
98299e7787 add std.process.cleanExit 2023-03-15 10:48:14 -07:00
Andrew Kelley
53fb59ea9b std.fifo: make toOwnedSlice support head != 0 2023-03-15 10:48:14 -07:00
Andrew Kelley
f4428e5804 fix wasm bootstrapping compilation errors 2023-03-15 10:48:14 -07:00
Andrew Kelley
f829f848dd std.Build.InstallFileStep: add missing step dependencies
in the creation function, which had to change from init() to create().
2023-03-15 10:48:14 -07:00
Andrew Kelley
f31aeb0010 std.Build.WriteFileStep: add missing step dependencies 2023-03-15 10:48:14 -07:00
Andrew Kelley
a333bb91ff zig objcopy: support the compiler protocol
This commit extracts out server code into src/Server.zig and uses it
both in the main CLI as well as `zig objcopy`.

std.Build.ObjCopyStep now adds `--listen=-` to the CLI for `zig objcopy`
and observes the protocol for progress and other kinds of integrations.

This fixes the last two test failures of this branch when I run
`zig build test` locally.
2023-03-15 10:48:14 -07:00
Andrew Kelley
59f5df3af9 std.Build: use Cache hash helper for package prefix dirs
Previously this code used SipHash(1, 3) directly; now that we have the
cache system available in the build system, borrow the same
implementation as is being used everywhere else.
2023-03-15 10:48:14 -07:00
Andrew Kelley
7cc4a6965c build runner enhancements in preparation for test-cases
* std.zig.ErrorBundle: support rendering options for whether to include
   the reference trace, whether to include the source line, and TTY
   configuration.

 * build runner: don't print progress in dumb terminals

 * std.Build.CompileStep:
   - add a way to expect compilation errors via the new `expect_errors`
     field. This is an advanced setting that can change the intent of
     the CompileStep. If this slice has nonzero length, it means that
     the CompileStep exists to check for compile errors and return
     *success* if they match, and failure otherwise.
   - remove the object format parameter from `checkObject`. The object
     format is known based on the CompileStep's target.
   - Avoid passing -L and -I flags for nonexistent directories within
     search_prefixes. This prevents a warning, that should probably be
     upgraded to an error in Zig's CLI parsing code, when the linker
     sees an -L directory that does not exist.

 * std.Build.Step:
   - When spawning the zig compiler process, takes advantage of the new
     `std.Progress.Node.setName` API to avoid ticking up a meaningless
     number at every progress update.
2023-03-15 10:48:14 -07:00
Andrew Kelley
3186658e60 std.Build.CheckFileStep: add a way to expect exact
This is done in a bit of a haphazard way. Eventually the API needs to
break in favor of a "checks" system similar to how RunStep works.
2023-03-15 10:48:14 -07:00
Andrew Kelley
25c3878c00 std.fs.File.readvAll: fix behavior for 0-length vectors
The OS layer expects pointer addresses to be inside the application's
address space even if the length is zero. Meanwhile, in Zig, slices may
have undefined pointer addresses when the length is zero. So this
function now modifies the iov_base fields when the length is zero.
2023-03-15 10:48:14 -07:00
Andrew Kelley
7db74009db std.Progress.Node: add a setName method
This can be used to update an existing node's label rather than indicate
that more things have been accomplished.
2023-03-15 10:48:14 -07:00
Andrew Kelley
974a6fe757 std.Build.RunStep: support -fqemu solving bad dynamic linker 2023-03-15 10:48:14 -07:00
Andrew Kelley
9a9b008300 std.Build.CompileStep: add FileSource support to some paths
Library paths, RPaths, and framework paths now support being fulfilled
by FileSource arguments.
2023-03-15 10:48:14 -07:00
Andrew Kelley
f558c835a4 std.Build.CheckObjectStep: better error message
when reading the file fails
2023-03-15 10:48:14 -07:00
Andrew Kelley
3b06990730 std.Build.CompileStep: tweak the default step name 2023-03-15 10:48:14 -07:00
Andrew Kelley
8510f9e2bc std.Build: add addAnonymousDependency
This is for bypassing the package manager and directly depending on
another package via the build system. For this to work the anonymous
package must be found on the file system relative to the current
package's build.zig.
2023-03-15 10:48:14 -07:00