Support use of LLVM's libunwind for exception unwinding
It is built in libgcc_s.so and libgcc_eh.a to simplify transition. It is enabled by default on arm64 (where we previously had no other unwinder) and may be enabled for testing on other platforms by setting WITH_LLVM_LIBUNWIND in src.conf(5). Also add compiler-rt's __gcc_personality_v0 implementation for use with the LLVM unwinder. Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D4787
This commit is contained in:
parent
1f17dba482
commit
b80f3546a8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=293450
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
GCCDIR= ${.CURDIR}/../../../contrib/gcc
|
GCCDIR= ${.CURDIR}/../../../contrib/gcc
|
||||||
GCCLIB= ${.CURDIR}/../../../contrib/gcclibs
|
GCCLIB= ${.CURDIR}/../../../contrib/gcclibs
|
||||||
|
COMPILERRTDIR= ${.CURDIR}/../../../contrib/compiler-rt
|
||||||
|
UNWINDINCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/include
|
||||||
|
UNWINDSRCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/src
|
||||||
|
|
||||||
SHLIB_NAME= libgcc_s.so.1
|
SHLIB_NAME= libgcc_s.so.1
|
||||||
SHLIBDIR?= /lib
|
SHLIBDIR?= /lib
|
||||||
@ -67,8 +70,37 @@ LIB2ADD = $(LIB2FUNCS_EXTRA)
|
|||||||
LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
|
LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
|
||||||
|
|
||||||
# Additional sources to handle exceptions; overridden by targets as needed.
|
# Additional sources to handle exceptions; overridden by targets as needed.
|
||||||
|
.if ${MK_LLVM_LIBUNWIND} != "no"
|
||||||
|
|
||||||
|
.PATH: ${COMPILERRTDIR}/lib/builtins
|
||||||
|
.PATH: ${UNWINDSRCDIR}
|
||||||
|
LIB2ADDEH = gcc_personality_v0.c \
|
||||||
|
int_util.c \
|
||||||
|
Unwind-EHABI.cpp \
|
||||||
|
Unwind-sjlj.c \
|
||||||
|
UnwindLevel1-gcc-ext.c \
|
||||||
|
UnwindLevel1.c \
|
||||||
|
UnwindRegistersRestore.S \
|
||||||
|
UnwindRegistersSave.S \
|
||||||
|
libunwind.cpp
|
||||||
|
|
||||||
|
CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR}
|
||||||
|
.if empty(CXXFLAGS:M-std=*)
|
||||||
|
CXXFLAGS+= -std=c++11
|
||||||
|
.endif
|
||||||
|
CXXFLAGS+= -fno-rtti
|
||||||
|
|
||||||
|
.else # MK_LLVM_LIBUNWIND
|
||||||
|
|
||||||
|
.if ${TARGET_CPUARCH} == "arm"
|
||||||
|
LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c
|
||||||
|
.else
|
||||||
LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \
|
LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \
|
||||||
unwind-c.c
|
unwind-c.c
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.endif # MK_LLVM_LIBUNWIND
|
||||||
|
|
||||||
LIB2ADDEHSTATIC = $(LIB2ADDEH)
|
LIB2ADDEHSTATIC = $(LIB2ADDEH)
|
||||||
LIB2ADDEHSHARED = $(LIB2ADDEH)
|
LIB2ADDEHSHARED = $(LIB2ADDEH)
|
||||||
|
|
||||||
@ -116,7 +148,6 @@ CFLAGS.clang+= -fheinous-gnu-extensions
|
|||||||
|
|
||||||
LIB1ASMSRC = lib1funcs.asm
|
LIB1ASMSRC = lib1funcs.asm
|
||||||
LIB1ASMFUNCS = _dvmd_tls _bb_init_func
|
LIB1ASMFUNCS = _dvmd_tls _bb_init_func
|
||||||
LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c
|
|
||||||
# Some compilers generate __aeabi_ functions libgcc_s is missing
|
# Some compilers generate __aeabi_ functions libgcc_s is missing
|
||||||
LIBADD+= compiler_rt
|
LIBADD+= compiler_rt
|
||||||
.endif
|
.endif
|
||||||
@ -160,7 +191,10 @@ LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g}
|
|||||||
.endfor
|
.endfor
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
COMMONHDRS= tm.h tconfig.h options.h unwind.h gthr-default.h
|
COMMONHDRS= tm.h tconfig.h options.h gthr-default.h
|
||||||
|
.if ${MK_LLVM_LIBUNWIND} == no
|
||||||
|
COMMONHDRS+= unwind.h
|
||||||
|
.endif
|
||||||
|
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -170,6 +204,9 @@ HIDE = -fvisibility=hidden -DHIDE_EXPORTS
|
|||||||
CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC
|
CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC
|
||||||
CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC
|
CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC
|
||||||
CC_S = ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED
|
CC_S = ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED
|
||||||
|
CXX_T = ${CXX} -c ${CXXFLAGS} ${HIDE} -fPIC
|
||||||
|
CXX_P = ${CXX} -c ${CXXFLAGS} ${HIDE} -p -fPIC
|
||||||
|
CXX_S = ${CXX} -c ${CXXFLAGS} ${PICFLAG} -DSHARED
|
||||||
|
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -284,16 +321,26 @@ EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/}
|
|||||||
EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN
|
EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN
|
||||||
SOBJS += ${EH_OBJS_S}
|
SOBJS += ${EH_OBJS_S}
|
||||||
|
|
||||||
.for _src in ${LIB2ADDEHSTATIC}
|
.for _src in ${LIB2ADDEHSTATIC:M*.c}
|
||||||
${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS}
|
${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS}
|
||||||
${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
||||||
${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS}
|
${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS}
|
||||||
${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
||||||
.endfor
|
.endfor
|
||||||
.for _src in ${LIB2ADDEHSHARED}
|
.for _src in ${LIB2ADDEHSTATIC:M*.cpp}
|
||||||
|
${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS}
|
||||||
|
${CXX_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
||||||
|
${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS}
|
||||||
|
${CXX_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
||||||
|
.endfor
|
||||||
|
.for _src in ${LIB2ADDEHSHARED:M*.c}
|
||||||
${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS}
|
${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS}
|
||||||
${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
||||||
.endfor
|
.endfor
|
||||||
|
.for _src in ${LIB2ADDEHSHARED:M*.cpp}
|
||||||
|
${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS}
|
||||||
|
${CXX_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
|
||||||
|
.endfor
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------
|
#-----------------------------------------------------------------------
|
||||||
|
@ -231,9 +231,9 @@ __DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
|
|||||||
# In-tree binutils/gcc are older versions without modern architecture support.
|
# In-tree binutils/gcc are older versions without modern architecture support.
|
||||||
.if ${__T} == "aarch64" || ${__T} == "riscv64"
|
.if ${__T} == "aarch64" || ${__T} == "riscv64"
|
||||||
BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
|
BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
|
||||||
__DEFAULT_YES_OPTIONS+=ELFCOPY_AS_OBJCOPY
|
__DEFAULT_YES_OPTIONS+=ELFCOPY_AS_OBJCOPY LLVM_LIBUNWIND
|
||||||
.else
|
.else
|
||||||
__DEFAULT_NO_OPTIONS+=ELFCOPY_AS_OBJCOPY
|
__DEFAULT_NO_OPTIONS+=ELFCOPY_AS_OBJCOPY LLVM_LIBUNWIND
|
||||||
.endif
|
.endif
|
||||||
.if ${__T} == "riscv64"
|
.if ${__T} == "riscv64"
|
||||||
BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V"
|
BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V"
|
||||||
|
2
tools/build/options/WITHOUT_LLVM_LIBUNWIND
Normal file
2
tools/build/options/WITHOUT_LLVM_LIBUNWIND
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.\" $FreeBSD$
|
||||||
|
Set to use GCC's stack unwinder (instead of LLVM's libunwind).
|
2
tools/build/options/WITH_LLVM_LIBUNWIND
Normal file
2
tools/build/options/WITH_LLVM_LIBUNWIND
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.\" $FreeBSD$
|
||||||
|
Set to use LLVM's libunwind stack unwinder (instead of GCC's unwinder).
|
Loading…
Reference in New Issue
Block a user