Index: llvm/lib/CodeGen/TargetLoweringBase.cpp =================================================================== --- llvm/lib/CodeGen/TargetLoweringBase.cpp +++ llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1964,10 +1964,14 @@ GlobalVariable::ExternalLinkage, nullptr, "__stack_chk_guard"); - // FreeBSD has "__stack_chk_guard" defined externally on libc.so + // XXX this is a workaround for FreeBSD PPC64 stack protector codegen and + // requires more investigation. For unknown reasons set dso_local here + // breaks PPC64 userland binaries (see bug #51590). + // However, FreeBSD amd64 kernel and modules are broken if dso_local + // is not set here, while PCC64 kernel and modules are fine without it. if (TM.getRelocationModel() == Reloc::Static && !TM.getTargetTriple().isWindowsGNUEnvironment() && - !TM.getTargetTriple().isOSFreeBSD()) + !(TM.getTargetTriple().isPPC64() && TM.getTargetTriple().isOSFreeBSD())) GV->setDSOLocal(true); } }