132 Commits

Author SHA1 Message Date
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
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
2023-06-24 16:56:39 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Jacob G-W
4dac9f54dd plan9: flesh out stdlib enough to allow not using simplified start logic 2023-06-16 08:34:30 -04:00
Jacob Young
10a4c2269d x86_64: enable normal start/test_runner logic on more targets 2023-05-01 19:22:52 -04:00
Luuk de Gram
d755f67b93
wasm: no longer use simplified start.zig
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.
2023-04-14 15:25:42 +02:00
Andrew Kelley
e2fe1907ec add c_char type
closes #875
2023-04-13 02:47:16 -04:00
Andrew Kelley
60bd13bdf2 never use C pointers!!
you maniacs, you absolute monsters. degenerates. hooligans. criminals.

issue #2984 is coming for you.
2023-04-12 15:21:03 -07:00
Robin Voetter
a7563e453d
spirv: minimal start code
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.
2023-04-09 01:51:55 +02:00
Jacob Young
c91929090d start: disable extra start logic on various x86_64 subtargets 2023-04-03 15:19:07 -04:00
Jacob Young
f0d13489f8 Elf: add program headers for the program header table 2023-04-03 17:45:17 +02:00
Jacob Young
83a208c355 x86_64: implement large cmp 2023-04-02 04:49:53 -04:00
Jonathan Marler
c02ced4d34 ignore SIGPIPE by default 2023-02-17 09:08:41 -07:00
Suirad
7f24993772 Add support for mips64/mips64el 2023-02-04 15:19:53 -05:00
Veikka Tuominen
f83834993e std: collect all options under one namespace 2023-01-05 02:31:29 -07:00
Jens Goldberg
b89158d6fd Don't initialize the static TLS area in single-threaded builds 2023-01-05 02:20:23 -07:00
r00ster91
7350ea3e2d std.builtin: rename Type.Fn's args to params
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.
2022-12-17 14:11:33 +01:00
r00ster91
20d3fd901e std.builtin: rename Type.Fn.Param's arg_type to type
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17 14:11:33 +01:00
Veikka Tuominen
08b2d491bc update usages of @call 2022-12-13 13:14:20 +02:00
Ali Chraghi
f5f1f8c666 all: rename i386 to x86 2022-11-04 00:09:27 +03:30
Jacob Young
b945d3eb90 cbe: improve support for non-native float types
* Fix _start on aarch64.
 * Add fallbacks when a float type is unsupported.

Fixes #13357
2022-10-31 20:18:15 -04:00
Jacob Young
e470cf361f cbe: update test cases 2022-10-25 05:11:29 -04:00
Jacob Young
15df64ade8 std: add cbe hacks to more targets
These are needed because clang doesn't support anything in naked
functions, not even assembly register inputs.
2022-10-25 05:11:29 -04:00
Jacob Young
4765294ca4 cbe: get enough things working to support basic programs
* Enable advanced start support.
 * Enable advanced test_runner support.
 * Zig Language Reference's Hello World now works.
2022-10-25 05:11:29 -04:00
Jakub Konka
a35f156cf6 coff: re-enable default entrypoint for Windows 2022-09-07 22:42:55 +02:00
Jakub Konka
db1a3bb0e7 coff: fallback to _start as default entry point for now
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.
2022-08-30 10:42:21 +02:00
Jakub Konka
30baba899c coff: add missing bits required for minimal PE example 2022-08-30 10:42:21 +02:00
Jakub Konka
06371950cf start: allow for explicitly defined entry point for Win 2022-08-30 10:42:21 +02:00
Meghan Denny
0879cbeed2 remove 'builtin.stage2_arch', Sema is smart enough now 2022-08-07 16:07:08 -07:00
Andrew Kelley
a127693f95 start code: enable segfault handler for stage2 2022-07-26 20:04:24 -07:00
Veikka Tuominen
d00da05ecb Sema: validate extern types 2022-07-11 18:47:29 +03:00
Yusuke Tanaka
f1da93af3c
Remove outdated TODO comment (#12053) 2022-07-09 13:05:41 +02:00
Koakuma
fb0692334e target: Rename sparcv9 -> sparc64
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)
2022-05-13 16:43:59 -04:00
Andrew Kelley
1a1f62a0ce std: enable real start code always for LLVM backend 2022-05-02 22:06:02 -07:00
Jakub Konka
1b5a43fdf7 start.zig: make sure macos uses full startup code 2022-04-16 12:07:34 +02:00
Koakuma
c07213269f stage2: zig fmt 2022-04-14 23:26:03 +07:00
Koakuma
43e69be196 stage2: sparcv9: Add exit2 implementation 2022-04-14 22:18:06 +07:00
Koakuma
1f63afa7c9 stage2: sparcv9: Register the backend in stdlib & driver 2022-04-14 22:18:06 +07:00
Andrew Kelley
0fb005d1d0 Sema: dummy implementation of @errorReturnTrace
Also update std/build.zig to use stage2 function pointer semantics.

This gets us a little bit closer to `zig build` working, although it is
now hitting a new crash in the compiler.
2022-03-21 19:08:30 -07:00
Andrew Kelley
078037ab9b stage2: passing threadlocal tests for x86_64-linux
* use the real start code for LLVM backend with x86_64-linux
   - there is still a check for zig_backend after initializing the TLS
     area to skip some stuff.
 * introduce new AIR instructions and implement them for the LLVM
   backend. They are the same as `call` except with a modifier.
   - call_always_tail
   - call_never_tail
   - call_never_inline
 * LLVM backend calls hasRuntimeBitsIgnoringComptime in more places to
   avoid unnecessarily depending on comptimeOnly being resolved for some
   types.
 * LLVM backend: remove duplicate code for setting linkage and value
   name. The canonical place for this is in `updateDeclExports`.
 * LLVM backend: do some assembly template massaging to make `%%`
   rendered as `%`. More hacks will be needed to make inline assembly
   catch up with stage1.
2022-03-11 00:04:42 -07:00
Luuk de Gram
f50203c836 wasm: update test runner
This updates the test runner for stage2 to emit to stdout with the passed, skipped and failed tests
similar to the LLVM backend.

Another change to this is the start function, as it's now more in line with stage1's.
The stage2 test infrastructure for wasm/wasi has been updated to reflect this as well.
2022-02-08 10:03:29 +01:00
vnc5
1adb6440db fix startup procedure for async WinMain 2022-01-27 19:49:12 +02:00
Sizhe Zhao
15ef251a15 Avoid duplicate TLS startup symbols 2022-01-24 20:26:29 +02:00
Andrew Kelley
4d05f2ae5f remove zig_is_stage2 from @import("builtin")
Instead use the standarized option for communicating the
zig compiler backend at comptime, which is `zig_backend`. This was
introduced in commit 1c24ef0d0b09a12a1fe98056f2fc04de78a82df3.
2022-01-17 21:55:49 -07:00
Luuk de Gram
adf059f272
wasm: Update wasm stage2 test backend to use 'main' 2021-11-29 08:05:51 +01:00
Luuk de Gram
dd49eca342
wasm: Implement 'zig test'
- This implements the required codegen for decl types such as pointers, arrays, structs and more.
- Wasm's start function can now use both a 'u8' and 'void' as return type. This will help us with writing tests
using the stage2 testing backend. (Until all tests of behavioural tests pass).
- Now correctly generates relocations for function pointers.
- Also implements unwrapping error union error, as well as return pointers.
2021-11-28 20:25:33 +01:00
Luuk de Gram
90d8544d40
wasm: Add temporary stage2 entrypoint for wasm 2021-11-27 21:34:48 +01:00
joachimschmidt557
e8112f7744 stage2 RISCV64: implement basic function prologue and epilogue 2021-11-20 19:25:59 +01:00
Martin Wickham
4782bededa Remove reference to stage2_os 2021-09-22 14:14:03 -05:00
Martin Wickham
d6e87da47b Make stage2 start.zig work on Windows 2021-09-22 13:58:49 -05:00
Andrew Kelley
dbe9a5114e stage2: implement @setAlignStack and 128-bit cmpxchg
* test runner is improved to respect `error.SkipZigTest`
 * start code is improved to `@setAlignStack(16)` before calling main()
 * the newly passing behavior test has a workaround for the fact that
   stage2 cannot yet call `std.Target.x86.featureSetHas()` at comptime.
   This is blocking on comptime closures. The workaround is that there
   is a new decl `@import("builtin").stage2_x86_cx16` which is a `bool`.
 * Implement `@setAlignStack`. This language feature should be re-evaluated
   at some point - I'll file an issue for it.
 * LLVM backend: apply/remove the cold attribute and noinline attribute
   where appropriate.
 * LLVM backend: loads and stores are properly annotated with alignment
   and volatile attributes.
 * LLVM backend: allocas are properly annotated with alignment.
 * Type: fix integers reporting wrong alignment for 256-bit integers and
   beyond. Once you get to 16 byte aligned, there is no further
   alignment for larger integers.
2021-09-16 21:03:55 -07:00