From patchwork Sat Oct 17 22:17:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Lange X-Patchwork-Id: 1383793 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.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oOFFopGl; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CDHTZ3wfwz9sSf for ; Sun, 18 Oct 2020 09:18:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1129587818; Sat, 17 Oct 2020 22:18:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Txxw0VhovrGO; Sat, 17 Oct 2020 22:18:08 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 47B3887813; Sat, 17 Oct 2020 22:18:08 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 733791BF59D for ; Sat, 17 Oct 2020 22:18:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6A2158740A for ; Sat, 17 Oct 2020 22:18:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OnpPbISBNLzF for ; Sat, 17 Oct 2020 22:18:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 99F6E87406 for ; Sat, 17 Oct 2020 22:18:06 +0000 (UTC) Received: by mail-ej1-f65.google.com with SMTP id dt13so8592257ejb.12 for ; Sat, 17 Oct 2020 15:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gH5Pl09P9gwDNakh46VyDE6aCoM6WVNDxNG71Jr9BLI=; b=oOFFopGlp0702SJfltQ2ZIxZQTVb+ufsglIybsZmM0rIrEwr8VzkqDRxFJjK0xu1pC A2UIJSW6cFWuiQCxGAPj/gfjMpfmpeszJ4lB6bpQtKiGQGb93OVLby8jMYMWve3nBbNc E2Gjg/RIJTH6P4338z54pKLOEkEdPuuq5xSKVEyRsfGivRiTSTibWqb/gu+YALyu2pm4 dZmPzA1Dr8ZomxOQbIHIGeU3tsOm81VpQM96GJ7s8XA6qNFTWr6OasUzvMsHQ/+hCDHm 7mBnZJi+DKgtitw9xDZiXX1KU4DGA+DUctDLmD7ed05rqAwFDY1d9qA/yulNk2GuBgkP OL6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gH5Pl09P9gwDNakh46VyDE6aCoM6WVNDxNG71Jr9BLI=; b=ZnyjkSQ4q0RPpDWETVTainmcVvE2UrG2Lsfq/jTtdA0V2TBTZ8EdHBmLdlGuiUCqC0 HI5LR9MdFVBxcg6+g1nKzbfrP28LBweKbV8YAj3jMVaSC6YrvT7TZnB91gm9tygYt8F5 sdL1BGy4mtCufiD0csjuWFQHvW26pwspyyg4/ExkjwYYFTTcKlL/cFT21zBW2jnIuF6x UWmMu07jvAAM2vp99dwJNlQiMxratI9qvnjXkj8yUsxeDIi/2n6blVcQXA3IQtgr5+PF AFQBMw6Q9ZzPZ2UASNQqnq4E6xzUR9XF6Naqr9BfuTLvQcotW83R8aeveWuktm7OiNLr svyg== X-Gm-Message-State: AOAM530fuPcj0lqN9LlvY8/+QCfin5wVrFXW2VOybfsnACcBHByIsWTM L9u/pDtnR6beYNk7uTvJRRAFryPkTTVzbw== X-Google-Smtp-Source: ABdhPJzYvHcK99r6NcDHGhqf+AGLasz7IVXsOEuHrd5yS9VbY8DcHciOjKnC0ekq7ohlHJKbsMjkCA== X-Received: by 2002:a17:906:c1d4:: with SMTP id bw20mr10225491ejb.91.1602973084739; Sat, 17 Oct 2020 15:18:04 -0700 (PDT) Received: from localhost.localdomain (84-114-45-16.cable.dynamic.surfer.at. [84.114.45.16]) by smtp.gmail.com with ESMTPSA id a13sm5950524edx.53.2020.10.17.15.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Oct 2020 15:18:04 -0700 (PDT) From: Norbert Lange To: buildroot@buildroot.org Date: Sun, 18 Oct 2020 00:17:40 +0200 Message-Id: <20201017221743.160029-1-nolange79@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 1/4] package/Makefile.in: use gcc wrappers for binutils tools 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: Thomas Petazzoni , Romain Naour , Norbert Lange , yann.morin.1998@free.fr, Thomas De Schampheleire Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This will use gcc-ar, gcc-nm and gcc-ranlib instead of the normal binutils tools. The difference is that with the wrappers, gcc plugins will be automatically picked up. gcc 4.7 introduced these wrappers, to detect the prefix and keep gcc specifics out of Makefile.in, a new variable BR2_TOOLCHAIN_BUTILS_PREFIX will be used to carry the prefix on supported versions. Note that binutils added some automatic loading with the 'bfd-plugins' directory (somewhere around 2.28), but the first implementation had issues, and generally depends on correctly setup symlinks (often broken, may point to some other gcc's library). The wrappers always work painless. The original motivation (now ~2 years in use) was to add "-flto -ffat-lto-objects" to both BR2_TARGET_OPTIMIZATION and BR2_TARGET_LDFLAGS, and have target binaries lto optimized. Not all packages will compile with this option, further work could white/blacklist packages (adding -fno-lto to the options). Signed-off-by: Norbert Lange --- v1->v2: * support older gcc versions missing those wrappers --- package/Makefile.in | 6 +++--- toolchain/Config.in | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package/Makefile.in b/package/Makefile.in index 51f5cbce4f..665edec539 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -198,15 +198,15 @@ TARGET_CROSS = $(HOST_DIR)/bin/$(TOOLCHAIN_EXTERNAL_PREFIX)- endif # Define TARGET_xx variables for all common binutils/gcc -TARGET_AR = $(TARGET_CROSS)ar +TARGET_AR = $(TARGET_CROSS)$(call qstrip,$(BR2_TOOLCHAIN_BUTILS_PREFIX))ar TARGET_AS = $(TARGET_CROSS)as TARGET_CC = $(TARGET_CROSS)gcc TARGET_CPP = $(TARGET_CROSS)cpp TARGET_CXX = $(TARGET_CROSS)g++ TARGET_FC = $(TARGET_CROSS)gfortran TARGET_LD = $(TARGET_CROSS)ld -TARGET_NM = $(TARGET_CROSS)nm -TARGET_RANLIB = $(TARGET_CROSS)ranlib +TARGET_NM = $(TARGET_CROSS)$(call qstrip,$(BR2_TOOLCHAIN_BUTILS_PREFIX))nm +TARGET_RANLIB = $(TARGET_CROSS)$(call qstrip,$(BR2_TOOLCHAIN_BUTILS_PREFIX))ranlib TARGET_READELF = $(TARGET_CROSS)readelf TARGET_OBJCOPY = $(TARGET_CROSS)objcopy TARGET_OBJDUMP = $(TARGET_CROSS)objdump diff --git a/toolchain/Config.in b/toolchain/Config.in index db2ab0f059..7a2becc09a 100644 --- a/toolchain/Config.in +++ b/toolchain/Config.in @@ -732,4 +732,11 @@ config BR2_TOOLCHAIN_HAS_LIBQUADMATH bool default y if BR2_i386 || BR2_x86_64 +# gcc ships with wrappers that will automatically pass arguments +# to the binutils tools. +# So far, those are paths to necessary linker plugins +config BR2_TOOLCHAIN_BUTILS_PREFIX + string + default "gcc-" if BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 + endmenu