sdk: fix building external modules when CONFIG_STACK_VALIDATION=y
authorYousong Zhou <yszhou4tech@gmail.com>
Thu, 25 Apr 2019 05:26:23 +0000 (05:26 +0000)
committerYousong Zhou <yszhou4tech@gmail.com>
Fri, 26 Apr 2019 13:05:39 +0000 (13:05 +0000)
The option is at the moment enabled for x86/64.  The selection chain
should be

config RETPOLINE
  select STACK_VALIDATION if HAVE_STACK_VALIDATION
config x86
  select HAVE_STACK_VALIDATION            if X86_64

cryptdev-linux:

make[4]: Entering directory '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10'
make -C /store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/linux-4.14.113 M=/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10 ARCH=x86 CROSS_COMPILE=x86_64-openwrt-linux-musl- modules
make[5]: Entering directory '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/linux-4.14.113'
make[6]: *** No rule to make target '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/ioctl.o', needed by '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10/cryptodev.o'.  Stop.
Makefile:1533: recipe for target '_module_/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/cryptodev-linux-cryptodev-linux-1.10' failed

Open vSwitch intree kmods

make[7]: Entering directory '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/openvswitch-2.11.0/datapath/linux'
make -C /store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/linux-4.14.111 ARCH=x86 M=/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/openvswitch-2.11.0/datapath/linux modules
make[8]: Entering directory '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/linux-4.14.111'
make[9]: *** No rule to make target 'tools/objtool/objtool', needed by '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/openvswitch-2.11.0/datapath/linux/actions.o'.  Stop.
Makefile:1533: recipe for target '_module_/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/openvswitch-2.11.0/datapath/linux' failed
make[8]: *** [_module_/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/openvswitch-2.11.0/datapath/linux] Error 2
make[8]: Leaving directory '/store/buildbot/slave/x86_64/build/sdk/build_dir/target-x86_64_musl/linux-x86_64/linux-4.14.111'

Reference: builddeb: include objtool binary in headers package, https://patchwork.kernel.org/patch/9014071/
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
target/sdk/Makefile

index 95ac3be197588ff98c8c2b7daa8c8c850a91d22c..3b860db93a28f0a8aa1144443a6d65efda106c61 100644 (file)
@@ -94,6 +94,14 @@ $(BIN_DIR)/$(SDK_NAME).tar.xz: clean
        $(TAR) -cf - -C $(TOPDIR) $(KDIR_BASE)/tools/usb/usbip/ | \
                $(TAR) -xf - -C $(SDK_BUILD_DIR)
 
+       # Copy objtool executables.  They are required for building external
+       # modules if "Compile-time stack metadata validation" is enabled.
+       if grep -q '^CONFIG_STACK_VALIDATION=y' $(LINUX_DIR)/.config; then \
+               $(TAR) -cf - -C $(TOPDIR) \
+                               `cd $(TOPDIR); find $(KDIR_BASE)/tools/objtool -type f -executable` | \
+                       $(TAR) -xf - -C $(SDK_BUILD_DIR); \
+       fi
+
        (cd $(SDK_BUILD_DIR); find $(STAGING_SUBDIR_HOST)/bin $(STAGING_SUBDIR_HOST)/usr/bin \
                $(STAGING_SUBDIR_TOOLCHAIN)/bin $(STAGING_SUBDIR_TOOLCHAIN)/*/bin $(STAGING_SUBDIR_TOOLCHAIN)/libexec \
                -type f | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST))