When cross-building for 32-bit x86, we need to make aware the CHIPSEC driver that we intend to build the 32-bit version via the ARCH variable. A quick fix is to define an environment varialble, CHIPSEC_ARCH, that can be retrieved from setup.py and passed to the driver Makefile. We no longer the EXTRA_OEMAKE variable as we rely on Python setuptools to build CHIPSEC. Cc: Megha Dey Signed-off-by: Ricardo Neri --- ...ve-CPU-architecture-to-the-driver-s-Makef.patch | 40 ++++++++++++++++++++++ meta-luv/recipes-core/chipsec/chipsec_git.bb | 3 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 meta-luv/recipes-core/chipsec/chipsec/0001-setup.py-give-CPU-architecture-to-the-driver-s-Makef.patch diff --git a/meta-luv/recipes-core/chipsec/chipsec/0001-setup.py-give-CPU-architecture-to-the-driver-s-Makef.patch b/meta-luv/recipes-core/chipsec/chipsec/0001-setup.py-give-CPU-architecture-to-the-driver-s-Makef.patch new file mode 100644 index 0000000..4fe7f10 --- /dev/null +++ b/meta-luv/recipes-core/chipsec/chipsec/0001-setup.py-give-CPU-architecture-to-the-driver-s-Makef.patch @@ -0,0 +1,40 @@ +From 4df09a6f905c9e1cf8c65235ff309ac7bebcc6eb Mon Sep 17 00:00:00 2001 +From: Ricardo Neri +Date: Wed, 15 Mar 2017 12:00:57 -0700 +Subject: [PATCH] setup.py: give CPU architecture to the driver's Makefile + +Driver is built differently depending on whether it is built for +32-bit or 64-bit x86 archs. Thus, we need to pass the desired +CPU architecture. This can be done by reading the environment +variable CHIPSEC_ARCH. This could be done more nicely by adding +a new variable to build_ext, though. + +Signed-off-by: Ricardo Neri +--- + setup.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/setup.py b/setup.py +index fb0da43..e09eaa6 100644 +--- a/setup.py ++++ b/setup.py +@@ -68,13 +68,14 @@ class build_ext(_build_ext): + self.set_undefined_options("build", ("skip_driver", "skip_driver")) + + def _build_linux_driver(self): +- log.info("building the linux driver") ++ arch = os.environ["CHIPSEC_ARCH"] ++ log.info("building the linux driver for arch " + arch) + build_driver = os.path.join(self.real_build_lib, "drivers", "linux") + ko_ext = os.path.join(build_driver, "chipsec.ko") + # We copy the drivers extension to the build directory. + self.copy_tree(os.path.join("drivers", "linux"), build_driver) + # Run the makefile there. +- subprocess.check_output(["make", "-C", build_driver]) ++ subprocess.check_output(["make", "ARCH="+arch, "-C", build_driver]) + # And copy the resulting .ko to the right place. + # That is to the source directory if we are in "develop" mode, + # otherwise to the helper subdirectory in the build directory. +-- +2.9.3 + diff --git a/meta-luv/recipes-core/chipsec/chipsec_git.bb b/meta-luv/recipes-core/chipsec/chipsec_git.bb index 6c29231..1a209e7 100644 --- a/meta-luv/recipes-core/chipsec/chipsec_git.bb +++ b/meta-luv/recipes-core/chipsec/chipsec_git.bb @@ -11,6 +11,7 @@ SRC_URI = "git://github.com/chipsec/chipsec.git \ file://chipsec file://luv-parser-chipsec \ file://0001-chipsec-building-for-32-bit-systems.patch \ file://0001-chipsec-do-not-ship-manual.patch \ + file://0001-setup.py-give-CPU-architecture-to-the-driver-s-Makef.patch \ " SRCREV="2fbb7a4eeb3752998dfbcbdf771cd3f8ed1985ae" @@ -48,7 +49,7 @@ def get_target_arch(d): else: raise bb.parse.SkipPackage("TARGET_ARCH %s not supported!" % target) -EXTRA_OEMAKE += "ARCH="${@get_target_arch(d)}"" +export CHIPSEC_ARCH = "${@get_target_arch(d)}" DISTUTILS_INSTALL_ARGS = "--root=${D}${PYTHON_SITEPACKAGES_DIR} \ --install-data=${D}/${datadir}" -- 2.9.3