From patchwork Tue Nov 23 21:22:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 34777 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C000627BBEA; Tue, 23 Nov 2021 22:48:32 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EA52C27BBE9 for ; Tue, 23 Nov 2021 22:48:31 +0000 (GMT) Received: from localhost ([::1]:33836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpeaV-0004Mu-4m for patchwork@mira.cbaines.net; Tue, 23 Nov 2021 17:48:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpea3-0004Mk-38 for guix-patches@gnu.org; Tue, 23 Nov 2021 17:48:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mpea2-0003cc-D6 for guix-patches@gnu.org; Tue, 23 Nov 2021 17:48:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mpea2-0000R1-4N for guix-patches@gnu.org; Tue, 23 Nov 2021 17:48:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52066] [PATCH, core-updates-frozen, RFC] Fix static guile on aarch64 Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 Nov 2021 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52066 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52066@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16377076341484 (code B ref -1); Tue, 23 Nov 2021 22:48:01 +0000 Received: (at submit) by debbugs.gnu.org; 23 Nov 2021 22:47:14 +0000 Received: from localhost ([127.0.0.1]:52436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mpeZG-0000Ns-0l for submit@debbugs.gnu.org; Tue, 23 Nov 2021 17:47:14 -0500 Received: from lists.gnu.org ([209.51.188.17]:35494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mpeZB-0000Nh-Ip for submit@debbugs.gnu.org; Tue, 23 Nov 2021 17:47:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpeZB-0004Kc-9f for guix-patches@gnu.org; Tue, 23 Nov 2021 17:47:09 -0500 Received: from mout.gmx.net ([212.227.17.20]:46577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpeZ8-0003ZE-Qf for guix-patches@gnu.org; Tue, 23 Nov 2021 17:47:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1637707623; bh=P3XNZtcTEzjpFZjlAiCWNkYwmaD5Bc0VlU0C8vicMWM=; h=X-UI-Sender-Class:From:To:Subject:Date; b=IMuVUoNi+JN8V5Dl1Ryp6pmTyoOH+72r8slGMlhus3Fhz1dKA9B788Vi8P0i6Soxw B0jFWnJoFz1QjVx7zLz/58kCs0Zc2NUooLsZTs1aT8ubgx/ULnoxFoDqQ3NJoXC+Wm Rozh0MgkZ484TUL41MwzYYiufyO3tAhiAojVoPoE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from labiere ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MyKHc-1mQQcE3lc4-00yenu for ; Tue, 23 Nov 2021 23:47:03 +0100 User-agent: mu4e 1.6.10; emacs 27.2 From: Pierre Langlois Date: Tue, 23 Nov 2021 21:22:31 +0000 Message-ID: <878rxeebh6.fsf@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:kJyZaaKbtMQ8oWXrfb2wRpp0sJjb7EKXp9eF6QgLD4kBK3AyEjZ SshzooRSocLtM1JybesaWu6TvRd/Vr7ZxM3P0WErnm4qWTPBC62CSpSeR6i5vRtO2ZXCBqX Y3lLFeIJxup/+53Yy9TNDBeZN3hXNgaMDzOHua1QjN39AKc83yRP/huI6DwBoExDffSF93y QhtH+mFYJ8z8A9Uig6TQA== X-UI-Out-Filterresults: notjunk:1;V03:K0:ID7vJ/sa7Y0=:ZznK03hwXFiNfZ5c8rBta6 5JylDDCVqTk5IG4GThLQI3vQn7p8t8H4xEzxidCC97PLTQvnmiWUJNEqHDosbRru7UM7lmLMe UfZmEwsGMTAbwkED/sDwNVsNoQsTVVdbZRwvhY95pR4n3ERnCLGPzq5ajQK3JH4sCWRaWVYiT MBIexX7d6TCEhTGlE38yVm0D+hiw13zJXAi1vz58w0wv4z5HtOyVxi+sPFDp1NwSv6+Yw0f8p dPMZ7G87LQ9YUr6lHSMep7CE7GPJuwoD8Md/h6CXiib5PhrGdPtncLjZTqVDqu2G4jpxBX74Y j7A1VeHFC8nDvS8ePwHRXMf5n6ZgAT1WeDj6ZMlnasK0iz/7UXjPY7/rlP3o4b7ln8ZXTlDO7 7Naf7fd6nSloEILWZPHfpGj45Qp59QGtUOG9Nb6SB+7dAPFlZ7m+VuRujnRM9ihDi8qvj3Kzm prwqcmxJpttlEv2rncXxeoX/hLYmw9fUo0OtHNOgXhTJLaR88sd6yyFM6KGOxA6aUBAY9yD/e pQTaZAm4KYjrxRy5y8VMjXDQU/1Tkkr+YI25Rj9MNjl13LjfU0Gabstxoa2kxJwHrc8wPXlQB cU+Z64qDWslt4bTbfzzOb+ETfyhgtNftUFQSLdEC61xAnxsP2fx03NuIRtUw+65VOrSGsqJJ8 f7uc4zN45WLHtDASe1yijDpnQedY6uIRtQg1PtohNrovI3dwQPG2dOlQn22dkskmTKxD+YbEs 46N/odpMats+5d1xtXu0Ll+03Bb5yQ4lb8adI/98Om4NTMjTE44P+iEmi1tzJXqIdJN12Vtco BW+ZLVzEKZxPWJW0sjJ7hy0SPrwi6bUx59tP2BV0ymiGPnIXt9nVW0781gKjgPIyG3CM3KZdV WCRA/um+NtDlOJ2WQQSHSJXi0pYDTshnKUAlcZsAJXrc1K5DCXFEw7HllLrQcmRlGK+MqJhBD 7HeDtgslIAGRb2FhB1JZ3AK+wCnHKrmbt8wG7CJ9kIwNE9xRUpL787SMqg5hGVJCjMzfZURHc X7ovA2mF+xRscV7YbkPmKKlBQOP2KIN2sEz99tiBnhBQ8ibFbGKxaML2pk2bv5GkIS1S8ADMZ iSSIFgYoQ3WQdc= Received-SPF: pass client-ip=212.227.17.20; envelope-from=pierre.langlois@gmx.com; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Guix! With the recent call for testing on core-updates-frozen I thought I'd test my router configuration on the RockPro64 and I saw that building the stripped static guile for initrd didn't build. I found a fix but I'm not 100% sure it's correct, so beware, here's my debugging session! %guile-static-stripped fails to build as such: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build -e '(@ (gnu packages make-bootstrap) %guile-static-stripped)' ... Backtrace: 1 (primitive-load "/gnu/store/gz31w23fjaipnm9c9hzw6p8s619?") In guix/build/utils.scm: 761:6 0 (invoke "/gnu/store/9rwp8z98xdllih5rzf2ncq25xhnkgcvq-g?" ?) guix/build/utils.scm:761:6: In procedure invoke: ERROR: 1. &invoke-error: program: "/gnu/store/9rwp8z98xdllih5rzf2ncq25xhnkgcvq-guile-static-stripped-3.0.7/bin/guile" arguments: ("--version") exit-status: 127 term-signal: #f stop-signal: #f --8<---------------cut here---------------end--------------->8--- The stripped guile crashes, and if we check it, it's actually not a static binary! So when stripping out store references we break it of course: --8<---------------cut here---------------start------------->8--- $ file /gnu/store/9rwp8z98xdllih5rzf2ncq25xhnkgcvq-guile-static-stripped-3.0.7/bin/guile /gnu/store/9rwp8z98xdllih5rzf2ncq25xhnkgcvq-guile-static-stripped-3.0.7/bin/guile: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /gnu/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.33/lib/ld-linux-aarch64.so.1, for GNU/Linux 2.6.32, stripped ^^^^^^^^ Oups :-) --8<---------------cut here---------------end--------------->8--- The root of the issue seems to be that the make-guile-static procedure isn't actually producing a static binary on aarch64. Digging into it more, we do pass the -all-static flag to libtool, but the gcc command doesn't actually do any static linking: --8<---------------cut here---------------start------------->8--- /tmp/guix-build-guile-static-3.0.7.drv-0/guile-3.0.7$ make V=1 ... ../libtool --tag=CC --mode=link gcc -std=gnu11 -pthread -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing -fwrapv -fvisibility=hidden -g -O2 -all-static -pthread -ldl -o guile guile-guile.o libguile-3.0.la -ldl -lcrypt -lm libtool: link: gcc -std=gnu11 -pthread -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing -fwrapv -fvisibility=hidden -g -O2 -pthread -o guile guile-guile.o ./.libs/libguile-3.0.a -L/gnu/store/3539zsmc939g1r9g3r02bpy0m1b9v9c8-libgc-8.0.4/lib -L/gnu/store/sn95w7yk9qwxhw74l590606y53pf5mkf-libffi-3.3/lib /gnu/store/3539zsmc939g1r9g3r02bpy0m1b9v9c8-libgc-8.0.4/lib/libgc.a -lpthread /gnu/store/sn95w7yk9qwxhw74l590606y53pf5mkf-libffi-3.3/lib/libffi.a -lunistring -ldl -lcrypt -lm -pthread --8<---------------cut here---------------end--------------->8--- And if we try and do a static link anyway, it doens't work because of missing references related to atomic ops. My guess is that libtool tried to statically link, and fell back to dynamic linking when that didn't work, I'm not so sure. --8<---------------cut here---------------start------------->8--- /tmp/guix-build-guile-static-3.0.7.drv-0/guile-3.0.7/libguile$ gcc -std=gnu11 -pthread -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing -fwrapv -fvisibility=hidden -g -O2 -pthread -o guile guile-guile.o ./.libs/libguile-3.0.a -L/gnu/store/3539zsmc939g1 r9g3r02bpy0m1b9v9c8-libgc-8.0.4/lib -L/gnu/store/sn95w7yk9qwxhw74l590606y53pf5mkf-libffi-3.3/lib /gnu/store/3539zsmc939g1r9g3r02bpy0m1b9v9c8-libgc-8.0.4/lib/libgc.a -lpthread /gnu/store/sn95w7yk9qwxhw74l590606y53pf5mkf-libffi-3.3/lib/libffi.a -lunistring -ldl -lcrypt -lm -p thread -static ld: ./.libs/libguile-3.0.a(libguile_3.0_la-dynl.o): in function `scm_dlopen': /tmp/guix-build-guile-static-3.0.7.drv-0/guile-3.0.7/libguile/dynl.c:78: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking ld: ./.libs/libguile-3.0.a(libguile_3.0_la-posix.o): in function `scm_tmpnam': /tmp/guix-build-guile-static-3.0.7.drv-0/guile-3.0.7/libguile/posix.c:1611: warning: the use of `tmpnam' is dangerous, better use `mkstemp' ld: /gnu/store/b05hb686wamq78d5jzpisns9xdx6nkp2-glibc-2.33-static/lib/libc.a(abort.o): in function `abort': (.text.unlikely+0x34): undefined reference to `__aarch64_cas4_acq' ld: (.text.unlikely+0xa0): undefined reference to `__aarch64_swp4_rel' ld: (.text.unlikely+0xe4): undefined reference to `__aarch64_cas4_acq' ld: /gnu/store/b05hb686wamq78d5jzpisns9xdx6nkp2-glibc-2.33-static/lib/libpthread.a(pthread_create.o):(.text+0x5c): undefined reference to `__aarch64_cas4_acq' ld: /gnu/store/b05hb686wamq78d5jzpisns9xdx6nkp2-glibc-2.33-static/lib/libpthread.a(pthread_create.o):(.text+0x1fc): undefined reference to `__aarch64_cas4_acq' ld: /gnu/store/b05hb686wamq78d5jzpisns9xdx6nkp2-glibc-2.33-static/lib/libpthread.a(pthread_create.o):(.text+0x29c): undefined reference to `__aarch64_cas4_acq' ... --8<---------------cut here---------------end--------------->8--- Doing more digging, I found a reference to a similar issue here: https://bugzilla.redhat.com/show_bug.cgi?id=1830472#c1, this looks related to the -moutline-atomics option that's enabled by default with GCC 10. But we're building guile with GCC 7 so it was a bit confusing. However, glibc here is actually built with the default GCC 10, and if we change that then it works! --8<---------------cut here---------------start------------->8--- --8<---------------cut here---------------end--------------->8--- I'm not 100% sure what's going on, there seems to be an incompatiblity between GCC 7 and 10, but I don't know if this is a bug or if it's working as intended. I have a feeling statically linking the libc with different compiler version might just not be supported, but it works in practise a lot of the time. Does this make sense? Do you think the following patch would be the right way to fix this? Thanks! Pierre From c1f61c161b3f5f7e8430c4925b0785d3819e255e Mon Sep 17 00:00:00 2001 From: Pierre Langlois Date: Tue, 23 Nov 2021 22:41:20 +0000 Subject: [PATCH] gnu: glibc-for-bootstrap: Build with GCC 7. * gnu/packages/make-bootstrap.scm (glibc-for-bootstrap)[native-inputs]: Add gcc-7. --- gnu/packages/make-bootstrap.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm index 267adde48c..d8f1f0eb1e 100644 --- a/gnu/packages/make-bootstrap.scm +++ b/gnu/packages/make-bootstrap.scm @@ -86,6 +86,12 @@ (define glibc-for-bootstrap "--enable-static-nss" ,flags)))) + ;; Make sure to build glibc with the same compiler version with the rest + ;; of the bootstrap. Otherwise it fails to statically link on aarch64. + (native-inputs + `(("gcc" ,gcc-7) + ,@(package-native-inputs base))) + ;; Remove the 'debug' output to allow bit-reproducible builds (when the ;; 'debug' output is used, ELF files end up with a .gnu_debuglink, which ;; includes a CRC of the corresponding debugging symbols; those symbols -- 2.34.0