113 Commits

Author SHA1 Message Date
Andrew Kelley 57caec8585 Merge pull request #13368 from jacobly0/fix-aarch64-c 2022-11-02 14:09:45 -07: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 1c24ef0d0b.
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
Andrew Kelley 5529febab0 stage2: implement Value.copy for structs and unions
The stage2_os hack inside `@import("builtin")` is no longer needed.
2021-09-13 20:11:35 -07:00
Andrew Kelley cca57042df std: fix regressions from this branch
Also move some usingnamespace test cases from compare_output to
behavior.
2021-09-01 17:54:07 -07:00
jdmichaud 49c9975484 zig fmt: respect trailing commas in inline assembly 2021-08-29 11:57:32 +02:00
Andrew Kelley d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Takeshi Yoneda 1e20a62126 WASI,libc: enable tests.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-07-27 09:01:00 +09:00
Jacob G-W 968d1ecf17 stage2 plan9: add aarch64 support 2021-07-11 01:58:26 -04:00
Jacob G-W 1c2facaf6b stage2: include enough inline asm support for more plan9 syscalls
Also make the exit more correct by exiting 0 rather than random
stuff on the stack.
2021-07-08 14:12:08 -07:00
Jacob G-W 72bb6bb143 plan9 linker: produce an object file that can actually work!!! 2021-07-08 14:10:49 -07:00
Andrew Kelley acf2e8fe64 fix start code for WebAssembly 2021-06-30 18:39:04 -07:00
Takeshi Yoneda bc7761d8e0 Add support for WASI reactor in pure Zig-exe. (#9178)
* Add command line help for "-mexec-model"
* Define WasmExecModel enum in std.builtin.
* Drop the support for the old crt1.o in favor of crt1-command.o

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-30 20:02:48 -04:00
LemonBoy fd6d5f1609 std: Fix PIE startup sequence
* Don't skip the TLS initialization (Fixes #9083)
* Add a test case where a PIE program is built and run
* Refactor the common initialization code in the Linux startup
  sequence.
2021-06-19 18:02:51 +02:00
Andrew Kelley 33a779c7f6 start.zig: intentional silent failure when cannot increase stack size 2021-05-28 13:17:04 -07:00
Isaac Freund 5b850d5c92 Run zig fmt on src/ and lib/std/
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-20 17:14:18 +02:00
Andrew Kelley 597082adf4 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * src/Compilation.zig
 * src/codegen/spirv/spec.zig
 * src/link/SpirV.zig
 * test/stage2/darwin.zig
   - this one might be problematic; start.zig looks for `main` in the
     root source file, not `_main`. Not sure why there is an underscore
     there in master branch.
2021-05-15 21:44:38 -07:00
Jakub Konka 1b222cb1ff start.zig: export main with strong linkage
Unmarks `_main` as weak symbol making it global (the entire linked
program) in scope.
2021-05-13 17:24:32 -04:00
Andrew Kelley b6bb0ee1ac Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * lib/std/os/linux/tls.zig
 * test/behavior/align.zig
 * test/behavior/atomics.zig
 * test/behavior/vector.zig
2021-05-08 10:53:22 -07:00
Andrew Kelley 6ec24a6502 std: start code on linux when -lc also expands stack size
See #8708
2021-05-07 21:34:53 -07:00
Andrew Kelley f69cf93064 std: start code increases stack size as appropriate on linux
closes #8708
2021-05-07 21:23:51 -07:00
Andrew Kelley a7221ef4e9 Sema: implement @typeInfo for functions
The goal is to get start code to be able to inspect the calling
convention of `main` in order to determine whether to export a main for
libc to call, or to allow the root source file to do it.
2021-05-06 22:30:44 -07:00