From patchwork Tue Jan 16 19:02:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 861863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zLfjj4J3xz9sR8 for ; Wed, 17 Jan 2018 06:02:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2B513266DE; Tue, 16 Jan 2018 19:02:30 +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 BfU9SYD5P135; Tue, 16 Jan 2018 19:02:28 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 214482FFD6; Tue, 16 Jan 2018 19:02:28 +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 113E21C3F00 for ; Tue, 16 Jan 2018 19:02:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0E3FE870D7 for ; Tue, 16 Jan 2018 19:02:27 +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 QD2irAwvD+gt for ; Tue, 16 Jan 2018 19:02:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.synopsys.com (smtprelay.synopsys.com [198.182.60.111]) by whitealder.osuosl.org (Postfix) with ESMTPS id 7A6D088E0F for ; Tue, 16 Jan 2018 19:02:26 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id F0D2B10C0876; Tue, 16 Jan 2018 11:02:25 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id DCB27BB7; Tue, 16 Jan 2018 11:02:25 -0800 (PST) Received: from ru20arcgnu1.internal.synopsys.com (ru20arcgnu1.internal.synopsys.com [10.121.9.48]) by mailhost.synopsys.com (Postfix) with ESMTP id C0C5EBB5; Tue, 16 Jan 2018 11:02:24 -0800 (PST) From: Alexey Brodkin To: buildroot@busybox.net Date: Tue, 16 Jan 2018 22:02:11 +0300 Message-Id: <20180116190211.24901-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.11.0 Subject: [Buildroot] [PATCH] gcc: Build libgcc with BR2_TARGET_OPTIMIZATION flags X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , Alexey Brodkin MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" libgcc gets built very early and what's more it is built not by "normal" cross gcc later found in "output/host/usr/bin" but by gcc's own bare-minimal version: output/build/host-gcc-xxx/build/./gcc/xgcc. Which in the end means BR2_TARGET_OPTIMIZATION is not applied to cross-compiler via toolchain wrapper. But given libgcc is an essential target executable we may want it to be built with the same "optimization" flags as all other libs and binaries. Technically this is doable with TARGET_ABI which is added to TARGET_CFLAGS but user cannot [or at least is not supposed to] modify TARGET_ABI as it is used for tunign for a particular platform. But still there might be a need to compile everything for tha target with a special compiler option and this change allows for that. For eaxmple ARC still doesn't have properly working link-time relaxation which requires us to compile everything properly from the beginning, otherwise we may face a situation when huge apps/libs like Qt5WebKit might fail to pass the final linkage because some symbols might be too far from each other as by default gcc will try to use shorter relocations. Solution is as simple as rebuild of everything with "-mlong-calls" so that all the symbols are compiled with full 32-bit relocations. And now only libgcc causes problems because it contains quite a few symbols used widely by other binaries like millicode, some math stuff etc. Signed-off-by: Alexey Brodkin --- package/gcc/gcc.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk index 27fc1e987c..afe59986fe 100644 --- a/package/gcc/gcc.mk +++ b/package/gcc/gcc.mk @@ -109,7 +109,7 @@ HOST_GCC_COMMON_CONF_OPTS = \ HOST_GCC_COMMON_CONF_ENV = \ MAKEINFO=missing -GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) +GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) $(BR2_TARGET_OPTIMIZATION) GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS) # Propagate options used for target software building to GCC target libs