My OpenBSD/macppc machine has built devel/llvm 7.0.1p0, but a pair of bugs in clang 6 are still in clang 7. A moment ago, I reported these bugs to llvm:
- https://bugs.llvm.org/show_bug.cgi?id=40553 wrong sizeof(long double) in 32-bit PowerPC NetBSD, OpenBSD - https://bugs.llvm.org/show_bug.cgi?id=40554 misaligned float in PowerPC code causes SIGBUS in OpenBSD/macppc Each report includes an example program that reproduces the bug, and a patch that tries to fix it. The long double bug is breaking graphics/kdiagram on powerpc. (Most C++ ports use ports-gcc, but x11/qt5/qt5.port.mk prefers ports-clang before ports-gcc, so ports using Qt5 may suffer from clang bugs.) I am now using the attached diff in devel/llvm. I have packaged kdiagram with this. My REVISION-main bump (from 0 to 1) conflicts with recent changes in CVS. My patches might not be correct; someone who knows llvm might be able to write better patches. I am using lang/gcc/8 as my ports-gcc; I have edited - infrastructure/mk/gcc4.port.mk to use MODGCC4_VERSION?=8 - devel/llvm/Makefile to use GCC_VER = 8.2.0 These edits are not in the attached diff. -- George Koehler <kern...@gmail.com>
Index: Makefile =================================================================== RCS file: /cvs/ports/devel/llvm/Makefile,v retrieving revision 1.207 diff -u -p -r1.207 Makefile --- Makefile 28 Jan 2019 15:34:22 -0000 1.207 +++ Makefile 31 Jan 2019 22:16:07 -0000 @@ -20,7 +20,7 @@ PKGSPEC-main = llvm-=${LLVM_V} PKGNAME-main = llvm-${LLVM_V} PKGNAME-python = py-llvm-${LLVM_V} PKGNAME-lldb = lldb-${LLVM_V} -REVISION-main = 0 +REVISION-main = 1 CATEGORIES = devel DISTFILES = llvm-${LLVM_V}.src${EXTRACT_SUFX} \ cfe-${LLVM_V}.src${EXTRACT_SUFX} \ Index: patches/patch-lib_Target_PowerPC_PPCISelLowering_cpp =================================================================== RCS file: patches/patch-lib_Target_PowerPC_PPCISelLowering_cpp diff -N patches/patch-lib_Target_PowerPC_PPCISelLowering_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-lib_Target_PowerPC_PPCISelLowering_cpp 31 Jan 2019 22:16:07 -0000 @@ -0,0 +1,18 @@ +$OpenBSD$ + +[PowerPC] When optimizing, don't load or store a misaligned float. +Such misalignment causes SIGBUS in OpenBSD. + +Index: lib/Target/PowerPC/PPCISelLowering.cpp +--- lib/Target/PowerPC/PPCISelLowering.cpp.orig ++++ lib/Target/PowerPC/PPCISelLowering.cpp +@@ -13918,7 +13918,8 @@ bool PPCTargetLowering::allowsMisalignedMemoryAccesses + } + } + +- if (VT == MVT::ppcf128) ++ // f32 and f64 must have 4-byte alignment. ++ if (VT == MVT::f32 || VT == MVT::f64 || VT == MVT::ppcf128) + return false; + + if (Fast) Index: patches/patch-tools_clang_lib_Basic_Targets_PPC_h =================================================================== RCS file: patches/patch-tools_clang_lib_Basic_Targets_PPC_h diff -N patches/patch-tools_clang_lib_Basic_Targets_PPC_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-tools_clang_lib_Basic_Targets_PPC_h 31 Jan 2019 22:16:07 -0000 @@ -0,0 +1,24 @@ +$OpenBSD$ + +[PowerPC] sizeof(long double) should be 8, not 16. + +Index: tools/clang/lib/Basic/Targets/PPC.h +--- tools/clang/lib/Basic/Targets/PPC.h.orig ++++ tools/clang/lib/Basic/Targets/PPC.h +@@ -328,9 +328,15 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public + break; + } + +- if (getTriple().getOS() == llvm::Triple::FreeBSD) { ++ switch (getTriple().getOS()) { ++ case llvm::Triple::FreeBSD: ++ case llvm::Triple::NetBSD: ++ case llvm::Triple::OpenBSD: + LongDoubleWidth = LongDoubleAlign = 64; + LongDoubleFormat = &llvm::APFloat::IEEEdouble(); ++ break; ++ default: ++ break; + } + + // PPC32 supports atomics up to 4 bytes.