From patchwork Thu Jan 18 16:56:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 863021 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.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zMqql5K0rz9s74 for ; Fri, 19 Jan 2018 03:56:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 0A2A689C57; Thu, 18 Jan 2018 16:56:48 +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 2RIvUEhGaVTu; Thu, 18 Jan 2018 16:56:45 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 1B73689C3F; Thu, 18 Jan 2018 16:56:45 +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 AB2A41C21CE for ; Thu, 18 Jan 2018 16:56:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A6094894E9 for ; Thu, 18 Jan 2018 16:56:44 +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 YrjLCqeEc72g for ; Thu, 18 Jan 2018 16:56:44 +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 0017D894E8 for ; Thu, 18 Jan 2018 16:56:43 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 7B5FD10C158E; Thu, 18 Jan 2018 08:56:43 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 6B194B5C; Thu, 18 Jan 2018 08:56:43 -0800 (PST) Received: from ru20arcgnu1.internal.synopsys.com (ru20arcgnu1.internal.synopsys.com [10.121.9.48]) by mailhost.synopsys.com (Postfix) with ESMTP id 512BAB54; Thu, 18 Jan 2018 08:56:42 -0800 (PST) From: Alexey Brodkin To: buildroot@busybox.net Date: Thu, 18 Jan 2018 19:56:39 +0300 Message-Id: <20180118165639.2154-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.11.0 Subject: [Buildroot] [PATCH v2] 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 Cc: Thomas Petazzoni --- Changes v1 -> v2: * Strip quotes from BR2_TARGET_OPTIMIZATION Didn't notice a problem with 1 option in BR2_TARGET_OPTIMIZATION but if another one is added libgcc configuration fails because: CFLAGS_FOR_TARGET="-xxx "-yyy -zzz"" and thus /bin/sh: -zzz: command not found 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..431f534f56 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) $(call qstrip,$(BR2_TARGET_OPTIMIZATION)) GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS) # Propagate options used for target software building to GCC target libs