Index: devel/llvm-devel/Makefile =================================================================== --- devel/llvm-devel/Makefile +++ devel/llvm-devel/Makefile @@ -66,7 +66,7 @@ .include "Makefile.snapshot" -OPTIONS_DEFINE= CLANG DOCS EXTRAS LIT LLD LLDB +OPTIONS_DEFINE= CLANG DOCS EXTRAS LIT LLD LLDB ELFV2 OPTIONS_DEFINE_amd64= COMPILER_RT GOLD OPENMP OPTIONS_DEFINE_i386= COMPILER_RT OPENMP OPTIONS_DEFAULT= CLANG EXTRAS LIT LLD LLDB @@ -130,6 +130,8 @@ GOLD_DESC= Build the LLVM Gold plugin for LTO GOLD_CMAKE_ON= -DLLVM_BINUTILS_INCDIR=${LOCALBASE}/include GOLD_BUILD_DEPENDS= ${LOCALBASE}/bin/ld.gold:devel/binutils +ELFV2_DESC= [PowerPC64] Use OpenPOWER ELF ABI v2 by default +ELFV2_EXTRA_PATCHES = ${PATCHDIR}/ppc64-elfv2 PLIST_SUB+= LLVM_MAJOR=${LLVM_MAJOR} \ LLVM_RELEASE=${LLVM_RELEASE} @@ -197,6 +199,12 @@ .include +# PPC_ABI variable is only defined after including bsd.port.options.mk +.if defined(PPC_ABI) && ${PPC_ABI} == ELFv2 +OPTIONS_DEFAULT_powerpc64= ELFV2 +.endif + + # keep in sync with /usr/src/lib/clang/clang.build.mk # ----------- start of sync block ------------------ # Armv6 and armv7 uses hard float abi, unless the CPUTYPE has soft in it. Index: devel/llvm-devel/files/ppc64-elfv2/patch-lib_Target_PowerPC_PPCTargetMachine.cpp =================================================================== --- /dev/null +++ devel/llvm-devel/files/ppc64-elfv2/patch-lib_Target_PowerPC_PPCTargetMachine.cpp @@ -0,0 +1,23 @@ +--- lib/Target/PowerPC/PPCTargetMachine.cpp.orig 2019-07-04 07:43:51 UTC ++++ lib/Target/PowerPC/PPCTargetMachine.cpp +@@ -209,6 +209,20 @@ static PPCTargetMachine::PPCABI computeTargetABI(const + if (TT.isMacOSX()) + return PPCTargetMachine::PPC_ABI_UNKNOWN; + ++ if (TT.isOSFreeBSD()) { ++ switch (TT.getArch()) { ++ case Triple::ppc64le: ++ case Triple::ppc64: ++ if (TT.getOSMajorVersion() >= 13) ++ return PPCTargetMachine::PPC_ABI_ELFv2; ++ else ++ return PPCTargetMachine::PPC_ABI_ELFv1; ++ case Triple::ppc: ++ default: ++ return PPCTargetMachine::PPC_ABI_UNKNOWN; ++ } ++ } ++ + switch (TT.getArch()) { + case Triple::ppc64le: + return PPCTargetMachine::PPC_ABI_ELFv2; Index: devel/llvm-devel/files/ppc64-elfv2/patch-tools_clang_lib_Basic_Targets_PPC.h =================================================================== --- /dev/null +++ devel/llvm-devel/files/ppc64-elfv2/patch-tools_clang_lib_Basic_Targets_PPC.h @@ -0,0 +1,34 @@ +--- tools/clang/lib/Basic/Targets/PPC.h.orig 2019-07-09 13:32:26 UTC ++++ tools/clang/lib/Basic/Targets/PPC.h +@@ -374,12 +374,29 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public + IntMaxType = SignedLong; + Int64Type = SignedLong; + ++ if (Triple.getEnvironment() != llvm::Triple::UnknownEnvironment) { ++ switch (Triple.getEnvironment()){ ++ case llvm::Triple::ELFv1: ++ ABI = "elfv1"; ++ break; ++ default: ++ ABI = "elfv2"; ++ break; ++ } ++ } else { ++ if ((Triple.getOS() == llvm::Triple::FreeBSD) && ++ (Triple.getOSMajorVersion() < 13)) { ++ ABI = "elfv1"; ++ } else { ++ ABI = "elfv2"; ++ } ++ } ++ ++ + if ((Triple.getArch() == llvm::Triple::ppc64le)) { + resetDataLayout("e-m:e-i64:64-n32:64"); +- ABI = "elfv2"; + } else { + resetDataLayout("E-m:e-i64:64-n32:64"); +- ABI = Triple.getEnvironment() == llvm::Triple::ELFv2 ? "elfv2" : "elfv1"; + } + + if (Triple.getOS() == llvm::Triple::AIX)