openbsd: link with required system libraries #7380
Conversation
…ss) when linking and while compiling zig stage2, use c++ and c++abi too
|
it adds linking for it also adds |
OpenBSD has no support for native TLS? Colour me surprised!
Unconditionally adding a dependency on the native |
|
I must confess that I have no real idea on why I will rework the PR to not include it. the rest of the code will be better upstreamed than in my local repo |
Hopefully the situation improved a bit in the past three years or so, can you check if that's the case? |
TLS support is still partial. so it might depend of type of relocations used:
I am unsure if it is need or not: the LLVM 11 libraries I am using are mostly upstream version (I only backported few required patches): so the default is still |
|
it seems some changes were backported. LLVM 11 upstream version has |
|
When the emulated TLS option is on LLVM won't even attempt to use the native relocations and friends, you may not even need the emulation at all. |
|
the current support of TLS seems enough at least for simple tests. I am able to build a zig stage1 compiler which generate code without using emutls and which is functional. does it makes sense to add proper code generation without emutls for OpenBSD in zig ? or should I keep that local for now ? |
|
@LemonBoy ping ? the PR should be fine as it. eventually I could add an additionnal commit to add explicit no-emulated-tls in stage1, but it isn't strictly necessary: diff 3f2389d807cd23104b653e88eabbda0884bacecc 13d8a1ac8eb044871e069aa72021d2e15083884e
blob - 9b1ab71e9a11a333a4830580651b3de10e84a9d1
blob + b26db72a77db6409bca190818baf243e614beed4
--- src/zig_llvm.cpp
+++ src/zig_llvm.cpp
@@ -99,7 +99,7 @@ static const bool assertions_on = true;
static const bool assertions_on = false;
#endif
-LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple,
+LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *TripleName,
const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
LLVMCodeModel CodeModel, bool function_sections, ZigLLVMABIType float_abi, const char *abi_name)
{
@@ -164,7 +164,14 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTa
opt.MCOptions.ABIName = abi_name;
}
- TargetMachine *TM = reinterpret_cast<Target*>(T)->createTargetMachine(Triple, CPU, Features, opt, RM, CM,
+ Triple triple(TripleName);
+ if ((ZigLLVM_OSType)triple.getOS() == ZigLLVM_OpenBSD) {
+ /* force to not use EmulatedTLS on OpenBSD */
+ opt.ExplicitEmulatedTLS = true;
+ opt.EmulatedTLS = false;
+ }
+
+ TargetMachine *TM = reinterpret_cast<Target*>(T)->createTargetMachine(TripleName, CPU, Features, opt, RM, CM,
OL, JIT);
return reinterpret_cast<LLVMTargetMachineRef>(TM);
} |
|
LGTM. I think we still need an emutls fallback to allow our compiler-rt to provide the required symbols in case a user is pulling in some object file compiled with system clang. |
and while compiling zig stage2, use c++ and c++abi too