]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
livepatch: differentiate between old and new build systems
authorRoger Pau Monne <roger.pau@citrix.com>
Wed, 2 Mar 2022 14:27:11 +0000 (14:27 +0000)
committerRoss Lagerwall <ross.lagerwall@citrix.com>
Tue, 7 Feb 2023 11:36:39 +0000 (11:36 +0000)
Do not attempt to modify the build system if CFLAGS are not set in
Rules.mk, and instead rely on CONFIG_LIVEPATCH already setting
-f{function,data}-sections.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
livepatch-build

index 38a92bed5782d2bcede07e9b60554029eefbcf78..a3f311af2cfebb626885370c2c3978bb5d34f1c6 100755 (executable)
@@ -98,14 +98,20 @@ function build_special()
 
     # Build with special GCC flags
     cd "${SRCDIR}/xen" || die
-    sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk
-    cp -p arch/x86/Makefile arch/x86/Makefile.bak
-    sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' arch/x86/Makefile
-    # Restore timestamps to prevent spurious rebuilding
-    touch --reference=arch/x86/Makefile.bak arch/x86/Makefile
-    make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" || die
-    sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
-    mv -f arch/x86/Makefile.bak arch/x86/Makefile
+    if grep -q 'nostdinc' Rules.mk; then
+        # Support for old build system, attempt to set -f{function,data}-sections and rebuild
+        sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk
+        cp -p arch/x86/Makefile arch/x86/Makefile.bak
+        sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' arch/x86/Makefile
+        # Restore timestamps to prevent spurious rebuilding
+        touch --reference=arch/x86/Makefile.bak arch/x86/Makefile
+        make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" || die
+        sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
+        mv -f arch/x86/Makefile.bak arch/x86/Makefile
+    else
+        # -f{function,data}-sections set by CONFIG_LIVEPATCH
+        make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" || die
+    fi
 
     unset LIVEPATCH_BUILD_DIR
     unset LIVEPATCH_CAPTURE_DIR