diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-11 00:04:42 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-11 00:04:42 -0700 |
| commit | 078037ab9b410fa13a86eabdfc30918fc83cdcf3 (patch) | |
| tree | b5e80992e82d015393872fcc57911b03ca7211fd /lib | |
| parent | b28b3f6f7b1dd4c3c8a0f3d3a6305a84daed8ead (diff) | |
| download | zig-078037ab9b410fa13a86eabdfc30918fc83cdcf3.tar.gz zig-078037ab9b410fa13a86eabdfc30918fc83cdcf3.zip | |
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.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/start.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 6e28ca61a3..3502645172 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -22,7 +22,16 @@ comptime { // The self-hosted compiler is not fully capable of handling all of this start.zig file. // Until then, we have simplified logic here for self-hosted. TODO remove this once // self-hosted is capable enough to handle all of the real start.zig logic. - if (builtin.zig_backend != .stage1) { + if (builtin.zig_backend == .stage2_wasm or + builtin.zig_backend == .stage2_c or + builtin.zig_backend == .stage2_x86_64 or + builtin.zig_backend == .stage2_x86 or + builtin.zig_backend == .stage2_aarch64 or + builtin.zig_backend == .stage2_arm or + builtin.zig_backend == .stage2_riscv64 or + (builtin.zig_backend == .stage2_llvm and native_os != .linux) or + (builtin.zig_backend == .stage2_llvm and native_arch != .x86_64)) + { if (builtin.output_mode == .Exe) { if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { @@ -399,6 +408,11 @@ fn posixCallMainAndExit() noreturn { // Initialize the TLS area. std.os.linux.tls.initStaticTLS(phdrs); + if (builtin.zig_backend == .stage2_llvm) { + root.main(); + exit2(0); + } + // The way Linux executables represent stack size is via the PT_GNU_STACK // program header. However the kernel does not recognize it; it always gives 8 MiB. // Here we look for the stack size in our program headers and use setrlimit |
