This adds support for the `-fno-entry` and `-fentry` flags respectively, for
zig build-{exe/lib} and the build system. For `zig cc` we use the `--no-entry`
flag to be compatible with clang and existing tooling.
In `start.zig` we now make the main function optional when the target is
WebAssembly, as to allow for the build-exe command in combination with
`-fno-entry`.
When the execution model is set, and is set to 'reactor', we now verify
when an entry name is given it matches what is expected. When no entry
point is given, we set it to `_initialize` by default. This means the user
will also be met with an error when they use the reactor model, but did
not provide the correct function.
SPARCs have delayed branches, that is, it will unconditionally
run the next instruction following a branch.
Slightly reorder the _start code sequence to prevent it from
accidentally executing stray instructions, which may result in odd
program behavior.
* Replaces the exit assembly with the function from std.
* Reads the top-of-stack struct at program startup that can get information
like the pid.
* Changes the read and write functions to use the Pread and Pwrite syscalls
instead of the depreciated _READ and _WRITE
* Changes the openat function to use flags instead of perms.
Plan9 does not support perms when opening, just when creating.
* Adds an errstr function to read the errstr buf created by the kernel
After fixing some issues with inline assembly in the C backend, the std
cleanups have the side effect of making these functions compatible with
the backend, allowing it to be used on linux without linking libc.
At main startup, if the ELF auxiliary vector contains a stacksize value,
use it as a hint for the minimum stacksize required by the executable.
1. Never lower the hard-limit. Once a hard-limit is lowered, then it can
never be increased (including child processes).
2. If hint exceeds hard-limit then clamp hint to hard-limit.
3. If soft-limit exceeds hint then do nothing.
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:
* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
The Wasm backend now supports all features required to use
the full `start.zig` logic, rather than the simplified version.
With this commit we remove all references to the simplified logic
for Wasm specifically.
For SPIR-V, only export the main function if it is actually declared. Kernel
entry points will often have parameters and more than one kernel declared.
In general, SPIR-V binaries should mostly be compiled as libraries and not as
executables. However, this start code is required so that we can build test
executables.
Note that a call to isSpirV() would emit the code for that function, even though
the call is at comptime. To save that function from being emitted the checks
are just inlined manually.
This was a poor naming choice; these are parameters, not arguments.
Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
This is not technically correct, but given that we are not yet able
to link against the CRT, it's a good default until then.
Add basic logging of generated symbol table in the linker.
Rename all references of sparcv9 to sparc64, to make Zig align more with
other projects. Also, added new function to convert glibc arch name to Zig
arch name, since it refers to the architecture as sparcv9.
This is based on the suggestion by @kubkon in PR 11847.
(https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)