From 9488fbdbf829953cf7497d3284f77ca412f62f4c Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Thu, 29 Oct 2020 23:53:01 +0000 Subject: [PATCH] lang/luajit: switch to LLVM10 from ports for 12.1/amd64 12.1 shipped with LLVM 8.0.1 which links libluajit with a bogus (improperly aligned) TLS segment offset. Notably, this breaks under 12.2 rtld and causes a SIGBUS when an error is raised. Since the issue is technically a broken binary, the attached patch pins 12.1/amd64 builds of luajit to devel/llvm10 so that they can be rebuilt with a linker that will handle this properly and stop breaking luajit-dependant applications on 12.2 while the packages are still built on 12.1. This will naturally fall away when portmgr goes to axe conditionals solely for FreeBSD 12.1 after it goes EOL. The src/Makefile patch has been dropped in this version in favor of just supplying the variables it was unsetting via Make arguments as a minor cleanup. PR: 250707, 250726 Reported by: many Investigation by: Andrew Gierth Confirmation from: kib Approved by: osa (maintainer) MFH: 2020Q4 (blanket: runtime fix) --- lang/luajit/Makefile | 17 ++++++++++++++-- lang/luajit/files/patch-src_Makefile | 29 ---------------------------- 2 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 lang/luajit/files/patch-src_Makefile diff --git a/lang/luajit/Makefile b/lang/luajit/Makefile index ebbd457a6299..694d41a7f62f 100644 --- a/lang/luajit/Makefile +++ b/lang/luajit/Makefile @@ -3,7 +3,7 @@ PORTNAME= luajit DISTVERSION= 2.0.5 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= lang MASTER_SITES= https://luajit.org/download/ DISTNAME= LuaJIT-${DISTVERSION} @@ -23,7 +23,7 @@ CONFLICTS_INSTALL= luajit-openresty WRKSRC= ${WRKDIR}/LuaJIT-${DISTVERSION} USES= gmake USE_LDCONFIG= yes -MAKE_ARGS= CC=${CC} +MAKE_ARGS= CC=${CC} CCOPT= CCOPT_x86= PLIST_SUB+= VERSION=${DISTVERSION} @@ -31,6 +31,19 @@ PLIST_SUB+= VERSION=${DISTVERSION} .if ${ARCH:Mpowerpc*} || ${ARCH:Mmips*} || ${ARCH:Msparc*} USE_GCC=yes +.elif ${ARCH} == amd64 +# FreeBSD 12.1 shipped LLVM 8.0.1, which links libluajit with a TLS phdr that +# requests a 16-byte alignment but an offset that's 8 mod 16. This results in +# hilarity when an error is raised, as luajit raises an exception (stored in a +# static TLS variable) via libunwind. libunwind assumes proper alignment of +# the exception and uses a movaps instruction, which throws a SIGBUS when it +# encounters this misaligned TLS data. While the linker problem doesn't seem +# to be specific to amd64, the effect on luajit does seem to be. +.if ${OPSYS} == FreeBSD && ${OSVERSION} >= 1201000 && ${OSVERSION} < 1202000 +LLVM_MINIMUM= 10 +BUILD_DEPENDS+= llvm${LLVM_MINIMUM}>=10.0:devel/llvm${LLVM_MINIMUM} +CC= clang10 +.endif .endif post-install: diff --git a/lang/luajit/files/patch-src_Makefile b/lang/luajit/files/patch-src_Makefile deleted file mode 100644 index a8a8e81b3ae8..000000000000 --- a/lang/luajit/files/patch-src_Makefile +++ /dev/null @@ -1,29 +0,0 @@ ---- src/Makefile.orig 2017-05-03 11:08:48.482664000 -0400 -+++ src/Makefile 2017-05-03 11:09:44.473112000 -0400 -@@ -24,7 +24,7 @@ - # removing the '#' in front of them. Make sure you force a full recompile - # with "make clean", followed by "make" if you change any options. - # --DEFAULT_CC = gcc -+DEFAULT_CC = cc - # - # LuaJIT builds as a native 32 or 64 bit binary by default. - CC= $(DEFAULT_CC) -@@ -36,7 +36,7 @@ - # to slow down the C part by not omitting it. Debugging, tracebacks and - # unwinding are not affected -- the assembler part has frame unwind - # information and GCC emits it where needed (x64) or with -g (see CCDEBUG). --CCOPT= -O2 -fomit-frame-pointer -+#CCOPT= -O2 -fomit-frame-pointer - # Use this if you want to generate a smaller binary (but it's slower): - #CCOPT= -Os -fomit-frame-pointer - # Note: it's no longer recommended to use -O3 with GCC 4.x. -@@ -50,7 +50,7 @@ - # x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute - # the binaries to a different machine you could also use: -march=native - # --CCOPT_x86= -march=i686 -+#CCOPT_x86= -march=i686 - CCOPT_x64= - CCOPT_arm= - CCOPT_ppc=