redhat-rpm-config/brp-strip-lto
Nikita Popov fed29a69be Use Fat LTO with Clang
Currently, when the clang toolchain is used, we use the
brp-llvm-compile-lto-to-elf script to post-process any shipped
object files or static libraries to convert the LLVM bitcode they
contain into ELF object code.

With LLVM 18, Clang has introduced support for fat LTO objects
(https://llvm.org/docs/FatLTO.html), which work essentially the
same way as with GCC: If `-ffat-lto-objects` is passed, then the
objects will contain both the ELF code, as well as the LLVM
bitcode in a special section.

This redhat-rpm-config change enables the use of fat LTO and
drops the brp-llvm-compile-lto-to-elf script. Instead, the
brp-strip-lto script used by GCC also strips the LLVM section
name now.

This is part of https://fedoraproject.org/wiki/Changes/LLVM-18.
2024-04-11 17:31:09 +09:00

19 lines
575 B
Bash
Executable File

#!/usr/bin/sh
# If using normal root, avoid changing anything.
if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then
exit 0
fi
STRIP=${1:-strip}
NCPUS=${RPM_BUILD_NCPUS:-1}
case `uname -a` in
Darwin*) exit 0 ;;
*) ;;
esac
# Strip ELF binaries
find "$RPM_BUILD_ROOT" -type f -name '*.[ao]' \! -regex "$RPM_BUILD_ROOT/*usr/lib/debug.*" -print0 | \
eu-elfclassify --not-program --not-library --not-linux-kernel-module --stdin0 --print0 | \
xargs -0 -r -P$NCPUS -n32 sh -c "$STRIP -p -R .gnu.lto_* -R .gnu.debuglto_* -R .llvm.lto -N __gnu_lto_v1 \"\$@\"" ARG0