2022-02-05 14:23:32 +00:00
|
|
|
# Linker hash-style is set to gnu via gcc default
|
|
|
|
LD_OPTIM="-Wl,--as-needed"
|
|
|
|
|
|
|
|
TARGET_CPPFLAGS=""
|
2023-03-01 00:58:37 +00:00
|
|
|
TARGET_CFLAGS="${TARGET_CFLAGS} -Wall -pipe ${PROJECT_CFLAGS}"
|
2023-02-24 13:53:43 +00:00
|
|
|
TARGET_CXXFLAGS="${TARGET_CFLAGS}"
|
2023-03-01 00:58:37 +00:00
|
|
|
TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LD_OPTIM}"
|
2023-02-24 13:53:43 +00:00
|
|
|
TARGET_LIBDIR="${SYSROOT_PREFIX}/lib ${SYSROOT_PREFIX}/usr/lib"
|
|
|
|
TARGET_INCDIR="${SYSROOT_PREFIX}/include ${SYSROOT_PREFIX}/usr/include"
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
HOST_CPPFLAGS=""
|
2023-02-24 13:53:43 +00:00
|
|
|
HOST_CFLAGS="-march=native -O3 -Wall -pipe -I${TOOLCHAIN}/include"
|
|
|
|
HOST_CXXFLAGS="${HOST_CFLAGS}"
|
|
|
|
HOST_LDFLAGS="-Wl,-rpath,${TOOLCHAIN}/lib -L${TOOLCHAIN}/lib"
|
|
|
|
HOST_INCDIR="${TOOLCHAIN}/include /usr/include"
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# work around Ubuntu default C*FLAGS
|
|
|
|
# see https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-Wformat_-Wformat-security
|
2023-02-24 13:53:43 +00:00
|
|
|
HOST_CFLAGS="${HOST_CFLAGS} -Wno-format-security"
|
|
|
|
HOST_CXXFLAGS="${HOST_CXXFLAGS} -Wno-format-security"
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# lto flags
|
|
|
|
FLAGS_OPTIM_LTO_NO_PARALLEL="-flto"
|
|
|
|
FLAGS_OPTIM_LTO_PARALLEL="-flto=${CONCURRENCY_MAKE_LEVEL}"
|
|
|
|
FLAGS_OPTIM_LTO_NO_FAT="-fno-fat-lto-objects"
|
|
|
|
FLAGS_OPTIM_LTO_FAT="-ffat-lto-objects"
|
|
|
|
FLAGS_OPTIM_LTO_OFF="-fno-lto"
|
|
|
|
LDFLAGS_OPTIM_LTO_COMMON="-fuse-linker-plugin"
|
|
|
|
|
2023-03-01 00:58:37 +00:00
|
|
|
# linker specific flags
|
|
|
|
LDFLAGS_OPTIM_LINKER_COMPILER_DEFAULT=""
|
|
|
|
LDFLAGS_OPTIM_LINKER_BFD="-fuse-ld=bfd"
|
|
|
|
LDFLAGS_OPTIM_LINKER_GOLD="-fuse-ld=gold"
|
|
|
|
LDFLAGS_OPTIM_LINKER_MOLD="-fuse-ld=mold"
|
|
|
|
|
|
|
|
# default compiler optimization
|
|
|
|
CFLAGS_OPTIM_DEFAULT="-Ofast -fomit-frame-pointer -DNDEBUG"
|
|
|
|
CXXFLAGS_OPTIM_DEFAULT="${CFLAGS_OPTIM_DEFAULT}"
|
|
|
|
# speed flag
|
|
|
|
CFLAGS_OPTIM_SPEED="-Ofast -fomit-frame-pointer -DNDEBUG"
|
|
|
|
CXXFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED}"
|
|
|
|
# size flag
|
|
|
|
CFLAGS_OPTIM_SIZE="-Os -fomit-frame-pointer -DNDEBUG"
|
|
|
|
CXXFLAGS_OPTIM_SIZE="${CFLAGS_OPTIM_SIZE}"
|
|
|
|
# debug settings
|
|
|
|
CFLAGS_OPTIM_DEBUG="-ggdb -Og"
|
|
|
|
CXXFLAGS_OPTIM_DEBUG="${CFLAGS_OPTIM_DEBUG}"
|
|
|
|
LDFLAGS_OPTIM_DEBUG="-ggdb"
|
|
|
|
# split debug settings (requires gold)
|
|
|
|
CFLAGS_OPTIM_DEBUG_SPLIT="-gsplit-dwarf -Og"
|
|
|
|
CXXFLAGS_OPTIM_DEBUG_SPLIT="${CFLAGS_OPTIM_DEBUG_SPLIT}"
|
|
|
|
LDFLAGS_OPTIM_DEBUG_SPLIT="-Wl,--gdb-index"
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# position-independent code
|
|
|
|
CFLAGS_OPTIM_PIC="-fPIC -DPIC"
|
|
|
|
CXXFLAGS_OPTIM_PIC="-fPIC -DPIC"
|
|
|
|
LDFLAGS_OPTIM_PIC="-fPIC"
|
|
|
|
|
|
|
|
# hardening support
|
|
|
|
# TODO: basiclly copied from debian 9, should adjust for LE
|
|
|
|
CFLAGS_OPTIM_HARDENING="-fstack-protector-strong -Wformat -Werror=format-security -fPIE"
|
|
|
|
CXXFLAGS_OPTIM_HARDENING="-fstack-protector-strong -Wformat -Werror=format-security -fPIE"
|
|
|
|
CPPFLAGS_OPTIM_HARDENING="-D_FORTIFY_SOURCE=2"
|
|
|
|
LDFLAGS_OPTIM_HARDENING="-Wl,-z,relro -Wl,-z,now"
|
|
|
|
|
|
|
|
# add distro specific library dirs
|
2023-03-01 00:58:37 +00:00
|
|
|
if [ -z "${HOST_LIBDIR}" ]; then
|
2023-02-24 13:53:43 +00:00
|
|
|
HOST_LIBDIR="${TOOLCHAIN}/lib"
|
2022-02-05 14:23:32 +00:00
|
|
|
|
|
|
|
# ubuntu/debian specific "multiarch support"
|
|
|
|
export MACHINE_HARDWARE_NAME="$(uname -m)"
|
2023-03-01 00:58:37 +00:00
|
|
|
FAMILY_TRIPLET=$($LOCAL_CC -print-multiarch)
|
|
|
|
if [ -n "$FAMILY_TRIPLET" ]; then
|
|
|
|
if [ -d /lib/$FAMILY_TRIPLET ]; then
|
|
|
|
HOST_LIBDIR="${HOST_LIBDIR} /lib/$FAMILY_TRIPLET"
|
|
|
|
fi
|
|
|
|
if [ -d /usr/lib/$FAMILY_TRIPLET ]; then
|
|
|
|
HOST_LIBDIR="${HOST_LIBDIR} /usr/lib/$FAMILY_TRIPLET"
|
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# default multiarch support
|
|
|
|
case "${MACHINE_HARDWARE_NAME}" in
|
|
|
|
i*86)
|
|
|
|
if [ -d /lib32 ]; then
|
2023-03-01 00:58:37 +00:00
|
|
|
HOST_LIBDIR="${HOST_LIBDIR} /lib32"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
if [ -d /usr/lib32 ]; then
|
2023-03-01 00:58:37 +00:00
|
|
|
HOST_LIBDIR="${HOST_LIBDIR} /usr/lib32"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
x86_64)
|
|
|
|
if [ -d /lib64 ]; then
|
2023-03-01 00:58:37 +00:00
|
|
|
HOST_LIBDIR="${HOST_LIBDIR} /lib64"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
if [ -d /usr/lib64 ]; then
|
2023-03-01 00:58:37 +00:00
|
|
|
HOST_LIBDIR="${HOST_LIBDIR} /usr/lib64"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# default dirs
|
2023-03-01 00:58:37 +00:00
|
|
|
export HOST_LIBDIR="${HOST_LIBDIR} /lib /usr/lib"
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|