| author | |
| committer | |
| log | b5cc658ab4113b4db4f709dbec258910696990bd |
| tree | 7864e25eda40d6850582da4109e988b72df5bd2d |
| parent | c96c913bab00bcae42991244381ddcc8b2377552 |
Closes #24236.6 files changed, 22 insertions(+), 3 deletions(-)
src/codegen/llvm.zig+1| ... | @@ -1047,6 +1047,7 @@ pub const Object = struct { | ... | @@ -1047,6 +1047,7 @@ pub const Object = struct { |
| 1047 | comp.data_sections, | 1047 | comp.data_sections, |
| 1048 | float_abi, | 1048 | float_abi, |
| 1049 | if (target_util.llvmMachineAbi(&comp.root_mod.resolved_target.result)) |s| s.ptr else null, | 1049 | if (target_util.llvmMachineAbi(&comp.root_mod.resolved_target.result)) |s| s.ptr else null, |
| 1050 | target_util.useEmulatedTls(&comp.root_mod.resolved_target.result), | ||
| 1050 | ); | 1051 | ); |
| 1051 | errdefer target_machine.dispose(); | 1052 | errdefer target_machine.dispose(); |
| 1052 | 1053 |
src/codegen/llvm/bindings.zig+1| ... | @@ -79,6 +79,7 @@ pub const TargetMachine = opaque { | ... | @@ -79,6 +79,7 @@ pub const TargetMachine = opaque { |
| 79 | data_sections: bool, | 79 | data_sections: bool, |
| 80 | float_abi: FloatABI, | 80 | float_abi: FloatABI, |
| 81 | abi_name: ?[*:0]const u8, | 81 | abi_name: ?[*:0]const u8, |
| 82 | emulated_tls: bool, | ||
| 82 | ) *TargetMachine; | 83 | ) *TargetMachine; |
| 83 | 84 | ||
| 84 | pub const dispose = LLVMDisposeTargetMachine; | 85 | pub const dispose = LLVMDisposeTargetMachine; |
src/main.zig+1-1| ... | @@ -6324,7 +6324,7 @@ fn cmdDumpLlvmInts( | ... | @@ -6324,7 +6324,7 @@ fn cmdDumpLlvmInts( |
| 6324 | if (llvm.Target.getFromTriple(triple, &target, &error_message) != .False) @panic("bad"); | 6324 | if (llvm.Target.getFromTriple(triple, &target, &error_message) != .False) @panic("bad"); |
| 6325 | break :t target; | 6325 | break :t target; |
| 6326 | }; | 6326 | }; |
| 6327 | const tm = llvm.TargetMachine.create(target, triple, null, null, .None, .Default, .Default, false, false, .Default, null); | 6327 | const tm = llvm.TargetMachine.create(target, triple, null, null, .None, .Default, .Default, false, false, .Default, null, false); |
| 6328 | const dl = tm.createTargetDataLayout(); | 6328 | const dl = tm.createTargetDataLayout(); |
| 6329 | const context = llvm.Context.create(); | 6329 | const context = llvm.Context.create(); |
| 6330 | 6330 |
src/target.zig+13| ... | @@ -85,6 +85,19 @@ pub fn defaultSingleThreaded(target: *const std.Target) bool { | ... | @@ -85,6 +85,19 @@ pub fn defaultSingleThreaded(target: *const std.Target) bool { |
| 85 | return false; | 85 | return false; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | pub fn useEmulatedTls(target: *const std.Target) bool { | ||
| 89 | if (target.abi.isAndroid()) { | ||
| 90 | if (target.os.version_range.linux.android < 29) return true; | ||
| 91 | return false; | ||
| 92 | } | ||
| 93 | if (target.abi.isOpenHarmony()) return true; | ||
| 94 | return switch (target.os.tag) { | ||
| 95 | .openbsd => true, | ||
| 96 | .windows => target.abi == .cygnus, | ||
| 97 | else => false, | ||
| 98 | }; | ||
| 99 | } | ||
| 100 | |||
| 88 | pub fn hasValgrindSupport(target: *const std.Target, backend: std.builtin.CompilerBackend) bool { | 101 | pub fn hasValgrindSupport(target: *const std.Target, backend: std.builtin.CompilerBackend) bool { |
| 89 | // We can't currently output the necessary Valgrind client request assembly when using the C | 102 | // We can't currently output the necessary Valgrind client request assembly when using the C |
| 90 | // backend and compiling with an MSVC-like compiler. | 103 | // backend and compiling with an MSVC-like compiler. |
src/zig_llvm.cpp+5-1| ... | @@ -83,7 +83,7 @@ static const bool assertions_on = false; | ... | @@ -83,7 +83,7 @@ static const bool assertions_on = false; |
| 83 | LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, | 83 | LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, |
| 84 | const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, | 84 | const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, |
| 85 | LLVMCodeModel CodeModel, bool function_sections, bool data_sections, ZigLLVMFloatABI float_abi, | 85 | LLVMCodeModel CodeModel, bool function_sections, bool data_sections, ZigLLVMFloatABI float_abi, |
| 86 | const char *abi_name) | 86 | const char *abi_name, bool emulated_tls) |
| 87 | { | 87 | { |
| 88 | std::optional<Reloc::Model> RM; | 88 | std::optional<Reloc::Model> RM; |
| 89 | switch (Reloc){ | 89 | switch (Reloc){ |
| ... | @@ -149,6 +149,10 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri | ... | @@ -149,6 +149,10 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri |
| 149 | opt.MCOptions.ABIName = abi_name; | 149 | opt.MCOptions.ABIName = abi_name; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | if (emulated_tls) { | ||
| 153 | opt.EmulatedTLS = true; | ||
| 154 | } | ||
| 155 | |||
| 152 | TargetMachine *TM = reinterpret_cast<Target*>(T)->createTargetMachine(Triple, CPU, Features, opt, RM, CM, | 156 | TargetMachine *TM = reinterpret_cast<Target*>(T)->createTargetMachine(Triple, CPU, Features, opt, RM, CM, |
| 153 | OL, JIT); | 157 | OL, JIT); |
| 154 | return reinterpret_cast<LLVMTargetMachineRef>(TM); | 158 | return reinterpret_cast<LLVMTargetMachineRef>(TM); |
src/zig_llvm.h+1-1| ... | @@ -105,7 +105,7 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi | ... | @@ -105,7 +105,7 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi |
| 105 | ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, | 105 | ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, |
| 106 | const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, | 106 | const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, |
| 107 | LLVMCodeModel CodeModel, bool function_sections, bool data_sections, ZigLLVMFloatABI float_abi, | 107 | LLVMCodeModel CodeModel, bool function_sections, bool data_sections, ZigLLVMFloatABI float_abi, |
| 108 | const char *abi_name); | 108 | const char *abi_name, bool emulated_tls); |
| 109 | 109 | ||
| 110 | ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit); | 110 | ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit); |
| 111 | 111 |