From patchwork Wed Oct 21 06:59:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 1385367 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=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=Kbhz53Ic; dkim-atps=neutral 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 4CGLvt2yG6z9sPB for ; Wed, 21 Oct 2020 17:59:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E512185868; Wed, 21 Oct 2020 06:59:34 +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 qPLxpinVWi1w; Wed, 21 Oct 2020 06:59:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5F8A385784; Wed, 21 Oct 2020 06:59:33 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id CC8E21BF29A for ; Wed, 21 Oct 2020 06:59:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C90E287215 for ; Wed, 21 Oct 2020 06:59:32 +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 uxqhY9aQ51PR for ; Wed, 21 Oct 2020 06:59:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.73.133]) by hemlock.osuosl.org (Postfix) with ESMTPS id CF6AA872DF for ; Wed, 21 Oct 2020 06:59:30 +0000 (UTC) Received: from mailhost.synopsys.com (mdc-mailhost2.synopsys.com [10.225.0.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id D9C01400A0; Wed, 21 Oct 2020 06:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1603263570; bh=N71Cx+ad2Nh9xwhlPfTclHni+CHTgzxcoIGb9q7jYUA=; h=From:To:Cc:Subject:Date:From; b=Kbhz53Ic6Sb6T9RBwDEbstE5uMyowQAEdwp/16tS8bste5iv6IFxOam0M6mIY6nPJ 9EbPk+ffUCX2E9atzot3PWh9Yg+QmZpvAm0R754fgGamLqFXKwPwvy1THkcj6kf6cJ GHwryRCOFDBIO4Pf7g60dxg7hUb/iI+2q6PeouPnYnmz0QqQXlRsCelmrrxSfnDwW4 80PT/sYx2jFgt5Kk/Hdus9LmRVD91nB2UMlJGZF12ejzarYHxcwcaIeHRNdp4ZTvml 1gH9uyfKeZmck5qF2qnR/9AToy6b4jrkc9AKTHoxuK5LpkC1tdNERH4qAYW47c2Fsh e9lOKym24dRAg== Received: from ru20arcgnu1.internal.synopsys.com (ru20arcgnu1.internal.synopsys.com [10.121.9.48]) by mailhost.synopsys.com (Postfix) with ESMTP id 3F6BDA01F0; Wed, 21 Oct 2020 06:59:25 +0000 (UTC) X-SNPS-Relay: synopsys.com From: Alexey Brodkin To: buildroot@buildroot.org Date: Wed, 21 Oct 2020 09:59:23 +0300 Message-Id: <20201021065923.22112-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.16.2 Subject: [Buildroot] [PATCH] package/gcc: Fix libs building on ARC700 with atomics 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: Peter Korsgaard , arc-buildroot@synopsys.com, Alexey Brodkin , Thomas Petazzoni , Romain Naour MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" As we many times by now discussed that - some ARC cores might not have atomic instructions implemented. Namely that's ARC700 w/o explicitly added atomics during design creation/configuration. Because of that when GCC gets configured for ARC700, i.e. via "--with-cpu=arc700" atomic ops are assumed disabled. Usually it's not a problem as we add "-matomics" in the wraper for building all packages if targets CPU has atomis (BR2_ARC_ATOMIC_EXT). But when bulding target's binaries which are essential parts of the GCC itself we don't use the wrapper. Instead xgcc is being used. That way we lose that important part of system's configuration about atomics and: 1. Atomic ops won't be used where otherwise they could have been used. 2. Some configuration checks might end-up thinking there're no atomics In particular (2) leads to pretty obscure failure on bulding of some packages which use C++, for example: log4cplus: http://autobuild.buildroot.net/results/a7732fdb2ba526a114d9fb759814236c5332f8d7 ------------------------>8-------------------- ./.libs/liblog4cplus.so: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)' collect2: error: ld returned 1 exit status ------------------------>8-------------------- bitcoin: http://autobuild.buildroot.net/results/f73/f73d4c77e5fd6223abdbc83e344addcfc93227b8 ------------------------>8-------------------- (.text+0x110c): undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_wait_until(unsigned int*, unsigned int, bool, std::chrono::duration >, std::chrono::duration >)' collect2: error: ld returned 1 exit status ------------------------>8-------------------- apcupsd: http://autobuild.buildroot.net/results/7a2/7a2cc7a4ac2237c185817f75e55e05d144efd100 ------------------------>8-------------------- /tmp/instance-0/output-1/host/lib/gcc/arc-buildroot-linux-uclibc/9.3.1/../../../../arc-buildroot-linux-uclibc/bin/ld: eh_throw.cc:(.text._ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception+0x24): undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)' collect2: error: ld returned 1 exit status ------------------------>8-------------------- ...and many more. Interesting enough that was not seen earlier because "-matomic" used to be added in TARGET_{C|CXX}FLAGS via TARGET_ABI, but later "-matomic" was moved to ARCH_TOOLCHAIN_WRAPPER_OPTS, see https://git.buildroot.org/buildroot/commit/?id=c568b4f37fa6d7f51e6d14d33d7eb75dfe26d7bf and since then we started to see that new breakage which we now attempt to fix right where it hapens on GCC configuration. In contrast ARC HS family has atomic ops enabled by default thus we never spotted that kind of problem for it. More datails with analysis of what really happens under the hodd and how do error messages above are related to libs of GCC configuration could be found here: http://lists.busybox.net/pipermail/buildroot/2020-October/293614.html Signed-off-by: Alexey Brodkin Cc: Thomas Petazzoni Cc: Arnout Vandecappelle Cc: Peter Korsgaard Cc: Romain Naour --- package/gcc/gcc.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk index 114c2887a0..48974de2fa 100644 --- a/package/gcc/gcc.mk +++ b/package/gcc/gcc.mk @@ -98,6 +98,14 @@ ifeq ($(BR2_ENABLE_DEBUG),y) GCC_COMMON_TARGET_CFLAGS += -Wno-error endif +# Make sure libgcc & libstdc++ always get built with -matomic on ARC700 +ifeq ($(GCC_TARGET_CPU),arc700) +ifeq ($(BR2_ARC_ATOMIC_EXT),y) +GCC_COMMON_TARGET_CFLAGS += -matomic +GCC_COMMON_TARGET_CXXFLAGS += -matomic +endif +endif + # Propagate options used for target software building to GCC target libs HOST_GCC_COMMON_CONF_ENV += CFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CFLAGS)" HOST_GCC_COMMON_CONF_ENV += CXXFLAGS_FOR_TARGET="$(GCC_COMMON_TARGET_CXXFLAGS)"