ossp-uuid, libffi, libgcrypt: Pass --tag=CC option to libtool
PATCH 1/6 ossp-uuid, libffi, libgcrypt: Pass --tag=CC option to libtool
libtool tries to guess the --tag value based on CC/CXX environment variables and the compile commandline generated by makefiles. This heuristics however fails when we construct CC variables in OE and add security flags to it, especially -fPIE -pie which are added by external compilers e.g. clang particularly. It fails because libtool removed PIE flags from compiler cmdline intelligently if it figures out that its building a library, which means that the CC variable passed from cmdline does not match with the compiler cmdline constructed by libtool and we end up with errors like
| arm-bec-linux-musleabi-libtool: compile: unable to infer tagged configuration
| arm-bec-linux-musleabi-libtool: error: specify a tag with '--tag'
This works with internal gcc toolchain because we configure gcc for PIE when hardening is selected and dont pass -fPIE -pie options explicitly but this is not an option for clang, and some external gcc toolchains using older gcc
This patch adds the --tag option to help libtool set correct tags in packages where it cant get it right via its heuristics
--- .../ossp-uuid/ossp-uuid/libtool-tag.patch | 21 +++++++++++++++++++++ meta/recipes-devtools/ossp-uuid/ossp-uuid_1.6.2.bb | 2 ++ meta/recipes-support/libffi/libffi_3.2.1.bb | 3 ++- meta/recipes-support/libgcrypt/libgcrypt_1.7.8.bb | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/ossp-uuid/ossp-uuid/libtool-tag.patch
meta/recipes-devtools/ossp-uuid/ossp-uuid/libtool-tag.patch new file +21 -0
@@ -0,0 +1,21 @@ +Repect LIBTOOLFLAGS + +This add a knob that can be controlled from env to set generic options +for libtool + +Upstream-Status: Pending +Signed-off-by: Khem Raj <[email protected]> + +Index: uuid-1.6.2/Makefile.in +=================================================================== +--- uuid-1.6.2.orig/Makefile.in ++++ uuid-1.6.2/Makefile.in +@@ -56,7 +56,7 @@ RM = rm -f + CP = cp + RMDIR = rmdir + SHTOOL = $(S)/shtool +-LIBTOOL = @LIBTOOL@ ++LIBTOOL = @LIBTOOL@ $(LIBTOOLFLAGS) + TRUE = true + POD2MAN = pod2man + PERL = @PERL@
meta/recipes-devtools/ossp-uuid/ossp-uuid_1.6.2.bb +2 -0
@@ -27,6 +27,7 @@ SRC_URI = "http://snapshot.debian.org/archive/debian/20160728T043443Z/pool/main/ file://uuid-nostrip.patch \ file://install-pc.patch \ file://ldflags.patch \ + file://libtool-tag.patch \ " SRC_URI[md5sum] = "5db0d43a9022a6ebbbc25337ae28942f" SRC_URI[sha256sum] = "11a615225baa5f8bb686824423f50e4427acd3f70d394765bdff32801f0fd5b0"
@@ -37,6 +38,7 @@ inherit autotools update-alternatives EXTRA_OECONF = "--without-dce --without-cxx --without-perl --without-perl-compat --without-php --without-pgsql" EXTRA_OECONF = "--includedir=${includedir}/ossp" +EXTRA_OEMAKE_class-target = "LIBTOOLFLAGS='--tag=CC'" do_configure_prepend() { # This package has a completely custom aclocal.m4, which should be acinclude.m4.
meta/recipes-support/libffi/libffi_3.2.1.bb +2 -1
@@ -19,7 +19,7 @@ SRC_URI[md5sum] = "83b89587607e3eb65c70d361f13bab43" SRC_URI[sha256sum] = "d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37" EXTRA_OECONF += "--disable-builddir" - +EXTRA_OEMAKE_class-target = "LIBTOOLFLAGS='--tag=CC'" inherit autotools texinfo FILES_${PN}-dev += "${libdir}/libffi-${PV}"
@@ -29,3 +29,4 @@ FILES_${PN}-dev += "${libdir}/libffi-${PV}" MIPS_INSTRUCTION_SET = "mips" BBCLASSEXTEND = "native nativesdk" +
meta/recipes-support/libgcrypt/libgcrypt_1.7.8.bb +1 -0
@@ -29,6 +29,7 @@ BINCONFIG = "${bindir}/libgcrypt-config" inherit autotools texinfo binconfig-disabled pkgconfig EXTRA_OECONF = "--disable-asm" +EXTRA_OEMAKE_class-target = "LIBTOOLFLAGS='--tag=CC'" PACKAGECONFIG ??= "capabilities" PACKAGECONFIG[capabilities] = "--with-capabilities,--without-capabilities,libcap"
Signature · 1 line
2.13.3
PATCH 2/6 db: Add --tag parameter to libtool invocation
Fixes errors like
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
--- ...dd-explicit-tag-options-to-libtool-invoca.patch | 42 ++++++++++++++++++++++ meta/recipes-support/db/db_5.3.28.bb | 23 ++++++++---- 2 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 meta/recipes-support/db/db/0001-configure-Add-explicit-tag-options-to-libtool-invoca.patch
meta/recipes-support/db/db/0001-configure-Add-explicit-tag-options-to-libtool-invoca.patch new file +42 -0
@@ -0,0 +1,42 @@ +From 32e5943a3c4637d39e4d65b544dcb99e280210e3 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 23 Jul 2017 10:54:26 -0700 +Subject: [PATCH] configure: Add explicit tag options to libtool invocation + +This helps cross compile when tag inference via heuristics +fail because CC variable is having -fPIE -pie and libtool +smartly removes it when building libraries + +Upstream-Status: Pending + +Signed-off-by: Khem Raj <[email protected]> +--- + dist/configure.ac | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/dist/configure.ac b/dist/configure.ac +index 689f3b8..9c14bdb 100644 +--- a/dist/configure.ac ++++ b/dist/configure.ac +@@ -366,12 +366,12 @@ LIBTOOL="./libtool" + + INSTALLER="\$(LIBTOOL) --mode=install cp -p" + +-MAKEFILE_CC="\$(LIBTOOL) --mode=compile ${MAKEFILE_CC}" +-MAKEFILE_SOLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CCLINK} -avoid-version" +-MAKEFILE_CCLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CCLINK}" +-MAKEFILE_CXX="\$(LIBTOOL) --mode=compile ${MAKEFILE_CXX}" +-MAKEFILE_XSOLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CXXLINK} -avoid-version" +-MAKEFILE_CXXLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CXXLINK}" ++MAKEFILE_CC="\$(LIBTOOL) --tag=CC --mode=compile ${MAKEFILE_CC}" ++MAKEFILE_SOLINK="\$(LIBTOOL) --tag=CC --mode=link ${MAKEFILE_CCLINK} -avoid-version" ++MAKEFILE_CCLINK="\$(LIBTOOL) --tag=CC --mode=link ${MAKEFILE_CCLINK}" ++MAKEFILE_CXX="\$(LIBTOOL) --tag=CXX --mode=compile ${MAKEFILE_CXX}" ++MAKEFILE_XSOLINK="\$(LIBTOOL) --tag=CXX --mode=link ${MAKEFILE_CXXLINK} -avoid-version" ++MAKEFILE_CXXLINK="\$(LIBTOOL) --tag=CXX --mode=link ${MAKEFILE_CXXLINK}" + + + case "$host_os" in +-- +2.13.3 +
meta/recipes-support/db/db_5.3.28.bb +17 -6
@@ -22,6 +22,7 @@ SRC_URI = "http://download.oracle.com/berkeley-db/db-${PV}.tar.gz" SRC_URI += "file://arm-thumb-mutex_db5.patch \ file://fix-parallel-build.patch \ file://0001-atomic-Rename-local-__atomic_compare_exchange-to-avo.patch \ + file://0001-configure-Add-explicit-tag-options-to-libtool-invoca.patch \ " # We are not interested in official latest 6.x versions; # let's track what debian is using.
@@ -76,22 +77,32 @@ MUTEX = "" MUTEX_arm = "${ARM_MUTEX}" MUTEX_armeb = "${ARM_MUTEX}" EXTRA_OECONF += "${MUTEX} STRIP=true" -EXTRA_OEMAKE_append_class-target = " LIBTOOL=${STAGING_BINDIR_CROSS}/${HOST_SYS}-libtool" +EXTRA_OEMAKE_append = " LIBTOOL=${HOST_SYS}-libtool" +EXTRA_AUTORECONF += "--exclude=autoheader -I ${S}/dist/aclocal -I${S}/dist/aclocal_java" AUTOTOOLS_SCRIPT_PATH = "${S}/dist" # Cancel the site stuff - it's set for db3 and destroys the # configure. CONFIG_SITE = "" -do_configure() { - cd ${B} - gnu-configize --force ${AUTOTOOLS_SCRIPT_PATH} - oe_runconf + +oe_runconf_prepend() { + . ${S}/dist/RELEASE + # Edit version information we couldn't pre-compute. + sed -i -e "s/__EDIT_DB_VERSION_FAMILY__/$DB_VERSION_FAMILY/g" \ + -e "s/__EDIT_DB_VERSION_RELEASE__/$DB_VERSION_RELEASE/g" \ + -e "s/__EDIT_DB_VERSION_MAJOR__/$DB_VERSION_MAJOR/g" \ + -e "s/__EDIT_DB_VERSION_MINOR__/$DB_VERSION_MINOR/g" \ + -e "s/__EDIT_DB_VERSION_PATCH__/$DB_VERSION_PATCH/g" \ + -e "s/__EDIT_DB_VERSION_STRING__/$DB_VERSION_STRING/g" \ + -e "s/__EDIT_DB_VERSION_FULL_STRING__/$DB_VERSION_FULL_STRING/g" \ + -e "s/__EDIT_DB_VERSION_UNIQUE_NAME__/$DB_VERSION_UNIQUE_NAME/g" \ + -e "s/__EDIT_DB_VERSION__/$DB_VERSION/g" ${S}/dist/configure } do_compile_prepend() { # Stop libtool adding RPATHs - sed -i -e 's|hardcode_into_libs=yes|hardcode_into_libs=no|' ${B}/libtool + sed -i -e 's|hardcode_into_libs=yes|hardcode_into_libs=no|' ${B}/${HOST_SYS}-libtool } do_install_append() {
Signature · 1 line
2.13.3
PATCH 3/6 libproxy: Remove PIE flags from SECURITY_PIE_CFLAGS
In reply to Khem RajExternal compilers will explicitly pass -fPIE -pie flags unlike internal toolchain which does not use them, so the build fails with external toolchains because, its passing these flags to linker when building shared library, which is not correct it should just use -fPIC
Fixes errors e.g.
| /mnt/a/oe/build/tmp/work/corei7-64-bec-linux/libproxy/0.4.14-r0/recipe-sysroot-native/usr/bin/x86_64-bec-linux/x86_64-bec-linux-ld: ../libmodman/libmodman.a(module_manager.cpp.o): relocation R_X86_64_PC32 against symbol `_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIPN9libmodman14base_extensionESaISB_EEESt10_Select1stISE_ESt4lessIS5_ESaISE_EE8_M_eraseEPSt13_Rb_tree_nodeISE_E' can not be used when making a shared object; recompile with -fPIC
--- meta/recipes-support/libproxy/libproxy_0.4.14.bb | 1 + 1 file changed, 1 insertion(+)
meta/recipes-support/libproxy/libproxy_0.4.14.bb +1 -0
@@ -32,6 +32,7 @@ EXTRA_OECMAKE += " \ -DLIB_INSTALL_DIR=${libdir} \ -DLIBEXEC_INSTALL_DIR=${libexecdir} \ " +SECURITY_PIE_CFLAGS_remove = "-fPIE -pie" FILES_${PN} += "${libdir}/${BPN}/${PV}/modules" FILES_${PN}-dev += "${datadir}/cmake"
Signature · 1 line
2.13.3
PATCH 4/6 libsdl: Pass --tag option to libtool invocation
In reply to Khem RajHelps in fixing errors when using external toolchain and hardening flags
--- ...-Pass-tag-CC-explictly-when-using-libtool.patch | 73 ++++++++++++++++++++++ meta/recipes-graphics/libsdl/libsdl_1.2.15.bb | 1 + 2 files changed, 74 insertions(+) create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/0001-build-Pass-tag-CC-explictly-when-using-libtool.patch
meta/recipes-graphics/libsdl/libsdl-1.2.15/0001-build-Pass-tag-CC-explictly-when-using-libtool.patch new file +73 -0
@@ -0,0 +1,73 @@ +From 44e4bb4cfb81024c8f5fd2e179e8a32c42756a2f Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 23 Jul 2017 16:52:43 -0700 +Subject: [PATCH] build: Pass --tag=CC explictly when using libtool + +Do not depend solely on libtool heuristics which fail +in OE case when building with external compiler and +hardening flags + +Upstream-Status: Pending + +Signed-off-by: Khem Raj <[email protected]> +--- + Makefile.in | 4 ++-- + build-scripts/makedep.sh | 8 ++++---- + 2 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/Makefile.in b/Makefile.in +index ab51035..743ce30 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -72,10 +72,10 @@ depend: + include $(depend) + + $(objects)/$(TARGET): $(OBJECTS) +- $(LIBTOOL) --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) ++ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) + + $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS) +- $(LIBTOOL) --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(SDLMAIN_LDFLAGS) ++ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(SDLMAIN_LDFLAGS) + + + install: all install-bin install-hdrs install-lib install-data install-man +diff --git a/build-scripts/makedep.sh b/build-scripts/makedep.sh +index 3b3863b..dba28f2 100755 +--- a/build-scripts/makedep.sh ++++ b/build-scripts/makedep.sh +@@ -51,19 +51,19 @@ do echo "Generating dependencies for $src" + case $ext in + c) cat >>${output}.new <<__EOF__ + +- \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ ++ \$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ + + __EOF__ + ;; + cc) cat >>${output}.new <<__EOF__ + +- \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ ++ \$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ + + __EOF__ + ;; + m) cat >>${output}.new <<__EOF__ + +- \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ ++ \$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ + + __EOF__ + ;; +@@ -75,7 +75,7 @@ __EOF__ + ;; + S) cat >>${output}.new <<__EOF__ + +- \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ ++ \$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ + + __EOF__ + ;; +-- +2.13.3 +
meta/recipes-graphics/libsdl/libsdl_1.2.15.bb +1 -0
@@ -17,6 +17,7 @@ PR = "r3" SRC_URI = "http://www.libsdl.org/release/SDL-${PV}.tar.gz \ file://libsdl-1.2.15-xdata32.patch \ file://pkgconfig.patch \ + file://0001-build-Pass-tag-CC-explictly-when-using-libtool.patch \ " UPSTREAM_CHECK_REGEX = "SDL-(?P<pver>\d+(\.\d+)+)\.tar"
Signature · 1 line
2.13.3
PATCH 5/6 kexec-tools: Remove -fPIE -pie from SECURITY_PIE_CFLAGS
In reply to Khem Raj--- meta/recipes-kernel/kexec/kexec-tools_2.0.14.bb | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-kernel/kexec/kexec-tools_2.0.14.bb +2 -0
@@ -26,6 +26,8 @@ SRC_URI += "${KERNELORG_MIRROR}/linux/utils/kernel/kexec/kexec-tools-${PV}.tar.g SRC_URI[md5sum] = "b2b2c5e6b29d467d6e99d587fb6b7cf5" SRC_URI[sha256sum] = "b3e69519d2acced256843b1e8f1ecfa00d9b54fa07449ed78f05b9193f239370" +SECURITY_PIE_CFLAGS_remove = "-fPIE -pie" + PACKAGES =+ "kexec kdump vmcore-dmesg" ALLOW_EMPTY_${PN} = "1"
Signature · 1 line
2.13.3
PATCH 6/6 go: Remove -fPIE -pie from SECURITY_PIE_CFLAGS
In reply to Khem RajExternal compilers will explicitly pass -fPIE -pie flags unlike internal toolchain which does not use them, so the build fails with external toolchains because, its passing these flags to linker when building with -r option and fails to link
| /mnt/a/oe/build/tmp/work/corei7-64-bec-linux/go/1.8.3-r0/recipe-sysroot-native/usr/bin/x86_64-bec-linux/x86_64-bec-linux-ld: -r and -pie may not be used together
--- meta/recipes-devtools/go/go_1.8.bb | 1 + 1 file changed, 1 insertion(+)
meta/recipes-devtools/go/go_1.8.bb +1 -0
@@ -1,3 +1,4 @@ require go-${PV}.inc require go.inc TUNE_CCARGS_remove = "-march=mips32r2" +SECURITY_PIE_CFLAGS_remove = "-fPIE -pie"
Signature · 1 line
2.13.3