From 14b094484e5660b9014780e73bd01517f3dd4afd Mon Sep 17 00:00:00 2001 From: Stefan Strogin Date: Wed, 31 Jul 2019 10:58:06 +0300 Subject: [PATCH] kpatch-build: check if gcc supports -gz=none The flag -gz[=type] was added in GCC 5. To support older GCC versions check if the flag is supported before adding it to KCFLAGS. Fixes: #1012 Signed-off-by: Stefan Strogin --- kpatch-build/kpatch-build | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 365655c..69c1301 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -50,6 +50,7 @@ DEBUG=0 SKIPCLEANUP=0 SKIPGCCCHECK=0 ARCH_KCFLAGS="" +DEBUG_KCFLAGS="" declare -a PATCH_LIST APPLIED_PATCHES=0 OOT_MODULE= @@ -205,7 +206,6 @@ gcc_version_check() { else kgccver="$(gcc_version_from_file "$VMLINUX")" fi - rm -f "$c" "$o" if [[ -n "$out" ]]; then warn "gcc >= 4.8 required for -pg -ffunction-settings" @@ -213,6 +213,12 @@ gcc_version_check() { return 1 fi + out="$(gcc -c -gz=none -o "$o" "$c" 2>&1)" + if [[ -z "$out" ]]; then + DEBUG_KCFLAGS="-gz=none" + fi + rm -f "$c" "$o" + # ensure gcc version matches that used to build the kernel if [[ "$gccver" != "$kgccver" ]]; then warn "gcc/kernel version mismatch" @@ -748,7 +754,8 @@ if [[ "$ARCH" = "ppc64le" ]]; then ARCH_KCFLAGS="-mcmodel=large -fplugin=$PLUGINDIR/ppc64le-plugin.so" fi -export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections -gz=none $ARCH_KCFLAGS" +export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections \ + $ARCH_KCFLAGS $DEBUG_KCFLAGS" echo "Reading special section data" find_special_section_data