mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-15 08:52:15 +03:00
Improve the (cross-)build experience especially with LLVM (#353)
* Suppress clang warnings caused by boost headers * Make binutils selectable via environment variables Some build environments specify what tools to use via environment variables. e.g. NM could be 'x86_64-unknown-linux-gnu-nm' when cross-compiling * Use llvm-nm friendly non-short format value LLVM's nm implementaion (llvm-nm) wants the entire string to match. It doesn't allow just 'p' it wants 'posix'. - https://github.com/llvm/llvm-project/blob/llvmorg-21.1.3/llvm/tools/llvm-nm/llvm-nm.cpp#L2435-L2448 The nm implementations from GNU binutils and FreeBSD parse the format argument value only by looking at the first character. They are accept both 'p' and 'posix'. - https://github.com/bminor/binutils-gdb/blob/binutils-2_45/binutils/nm.c#L410-L438 - https://github.com/freebsd/freebsd-src/blob/release/14.3.0/contrib/elftoolchain/nm/nm.c#L506-L529
This commit is contained in:
committed by
Konstantinos Margaritis
parent
f472bfee05
commit
44dc317d9d
@@ -5,6 +5,9 @@ cleanup () {
|
|||||||
rm -f ${SYMSFILE} ${KEEPSYMS}
|
rm -f ${SYMSFILE} ${KEEPSYMS}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NM="${NM:-nm}"
|
||||||
|
OBJCOPY="${OBJCOPY:-objcopy}"
|
||||||
|
|
||||||
PREFIX=$1
|
PREFIX=$1
|
||||||
KEEPSYMS_IN=$2
|
KEEPSYMS_IN=$2
|
||||||
shift 2
|
shift 2
|
||||||
@@ -25,12 +28,12 @@ if [ `uname` = "FreeBSD" ]; then
|
|||||||
fi
|
fi
|
||||||
cp ${KEEPSYMS_IN} ${KEEPSYMS}
|
cp ${KEEPSYMS_IN} ${KEEPSYMS}
|
||||||
# get all symbols from libc and turn them into patterns
|
# get all symbols from libc and turn them into patterns
|
||||||
nm ${NM_FLAG} p -g -D ${LIBC_SO} | sed 's/\([^ @]*\).*/^\1$/' >> ${KEEPSYMS}
|
${NM} ${NM_FLAG} posix -g -D ${LIBC_SO} | sed 's/\([^ @]*\).*/^\1$/' >> ${KEEPSYMS}
|
||||||
# build the object
|
# build the object
|
||||||
"$@"
|
"$@"
|
||||||
# rename the symbols in the object
|
# rename the symbols in the object
|
||||||
nm ${NM_FLAG} p -g ${OUT} | cut -f1 -d' ' | grep -v -f ${KEEPSYMS} | sed -e "s/\(.*\)/\1\ ${PREFIX}_\1/" >> ${SYMSFILE}
|
${NM} ${NM_FLAG} posix -g ${OUT} | cut -f1 -d' ' | grep -v -f ${KEEPSYMS} | sed -e "s/\(.*\)/\1\ ${PREFIX}_\1/" >> ${SYMSFILE}
|
||||||
if test -s ${SYMSFILE}
|
if test -s ${SYMSFILE}
|
||||||
then
|
then
|
||||||
objcopy --redefine-syms=${SYMSFILE} ${OUT}
|
${OBJCOPY} --redefine-syms=${SYMSFILE} ${OUT}
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -36,11 +36,9 @@ if(NETBSD)
|
|||||||
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -DHAVE_BUILTIN_POPCOUNT")
|
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -DHAVE_BUILTIN_POPCOUNT")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MACOSX)
|
# Boost headers cause such complains on MacOS or when building with LLVM toolchains
|
||||||
# Boost headers cause such complains on MacOS
|
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter")
|
||||||
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter")
|
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter")
|
||||||
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-parameter")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# these end up in the config file
|
# these end up in the config file
|
||||||
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAS_C_HIDDEN)
|
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAS_C_HIDDEN)
|
||||||
|
|||||||
Reference in New Issue
Block a user