From patchwork Fri Oct 25 19:33:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matt Weber X-Patchwork-Id: 1184420 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rockwellcollins.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 470DmZ1ctZz9sPc for ; Sat, 26 Oct 2019 06:33:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C67B286205; Fri, 25 Oct 2019 19:33:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gg_wPdC65EcT; Fri, 25 Oct 2019 19:33:12 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 14B6985F19; Fri, 25 Oct 2019 19:33:12 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 21BE81BF2A6 for ; Fri, 25 Oct 2019 19:33:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 0294C20437 for ; Fri, 25 Oct 2019 19:33:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nxI7R3PBjgL0 for ; Fri, 25 Oct 2019 19:33:08 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from secvs05.rockwellcollins.com (unknown [205.175.225.131]) by silver.osuosl.org (Postfix) with ESMTPS id BCACE203AD for ; Fri, 25 Oct 2019 19:33:08 +0000 (UTC) IronPort-SDR: Mo3vbE3IxTIi7L9MIdNVBF89TxqIpdxQywPDPwVLBFussDUD3u3Rz0+Yps/oMsrkvYZJ+V5Vq6 0nibNKWxDR0hjtig4x5PPbMpI8PTWZDS03UWdKjfP2P9c0cXus7lFDB1zfrtIaexcBe3H8jAsl xiWO3T8ef8ktZhwwGmow7OsHAAdYMMdNwcP8WPb0FK5M01DVqIkgm/0+BIveAcbqqC/MmmQ8Ee UChXew0atve8jEalbOrW085GKNGxl0mGoKQTpFac4qCEqoA0REsO/jmUUCOpMcibL5fy7a5OrD KHA= Received: from ofwgwc03.rockwellcollins.com (HELO crulimr02.rockwellcollins.com) ([205.175.225.12]) by secvs05.rockwellcollins.com with ESMTP; 25 Oct 2019 14:33:07 -0500 X-Received: from biscuits.rockwellcollins.lab (biscuits.rockwellcollins.lab [10.148.119.137]) by crulimr02.rockwellcollins.com (Postfix) with ESMTP id 0729060257; Fri, 25 Oct 2019 14:33:07 -0500 (CDT) From: Matt Weber To: buildroot@buildroot.org Date: Fri, 25 Oct 2019 14:33:06 -0500 Message-Id: <20191025193306.16451-1-matthew.weber@rockwellcollins.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] toolchain-ext: rm shared libs for static builds X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E . MORIN" Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" For cases where Buildroot is generating a build with BR2_STATIC_LIBS=y and there is an external toolchain being used, the STAGING_DIR and HOSTDIR need to be scrubbed of shared library *.so*. This patch updates the toolchain-external staging step to first clean out all shared libraries before a sysroot is created. Before this patch, if shared libraries were found in the GCC library search path(s), build systems might still pick these up during build/link and fail with an error like "ld: attempted static link of dynamic object". NOTE: The Meson build system by default prefers external libraries to be shared libraries unless the developer has explicitly in their meson.build set each find_library() invocation to contain the static keyword (requires meson 0.51.0+).  One example where this was noticed was with iputils-20190709 where a link time dependency on libatomic occurred because the prebuilt toolchain had provided both a static and shared option.  Meson then generated a compile string including a fixed path to the toolchain's shared libatomic.so instead of static. Fixed: http://autobuild.buildroot.net/results/db1740b4777f436324218c52bc7b08e5c21b667d/ Cc: Yann E. MORIN Signed-off-by: Matthew Weber Reviewed-by: Yann E. MORIN --- .../toolchain-external/pkg-toolchain-external.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk index c00211d59c..64c681cc3e 100644 --- a/toolchain/toolchain-external/pkg-toolchain-external.mk +++ b/toolchain/toolchain-external/pkg-toolchain-external.mk @@ -444,6 +444,17 @@ define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS $(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR},$${SUPPORT_LIB_DIR}) endef +# NOTE: below the readlink call follows/builds each absolute path with any +# invalid paths failing (falling out of the list). Thus no checking of paths +# existing is required before doing the find. +ifeq ($(BR2_STATIC_LIBS),y) +define TOOLCHAIN_EXTERNAL_REMOVE_SHARED_LIBS + $(Q)$(call MESSAGE,"Removing shared libraries from toolchain...") + GCC_LIBRARY_PATHS=`$(TOOLCHAIN_EXTERNAL_CC) -print-search-dirs | sed -r -e '/libraries: =(.+)/!d; s//\1/; s/:/\n/g' | xargs readlink -f | grep -v 'gcc\|/[0-9.]\+$$'` ; \ + find $${GCC_LIBRARY_PATHS} -name *.so* -delete +endef +endif + # Create a symlink from (usr/)$(ARCH_LIB_DIR) to lib. # Note: the skeleton package additionally creates lib32->lib or lib64->lib # (as appropriate) @@ -565,6 +576,7 @@ $(2)_TOOLCHAIN_WRAPPER_ARGS += $$(TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS) $(2)_BUILD_CMDS = $$(TOOLCHAIN_WRAPPER_BUILD) define $(2)_INSTALL_STAGING_CMDS + $$(TOOLCHAIN_EXTERNAL_REMOVE_SHARED_LIBS) $$(TOOLCHAIN_WRAPPER_INSTALL) $$(TOOLCHAIN_EXTERNAL_CREATE_STAGING_LIB_SYMLINK) $$(TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS)