From patchwork Fri Jun 18 17:16:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 30437 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 33D7E27BC81; Fri, 18 Jun 2021 18:22:32 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9621D27BC78 for ; Fri, 18 Jun 2021 18:22:31 +0100 (BST) Received: from localhost ([::1]:54468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luICM-0002x1-8i for patchwork@mira.cbaines.net; Fri, 18 Jun 2021 13:22:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luIAF-0008E5-Tm for guix-patches@gnu.org; Fri, 18 Jun 2021 13:20:22 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luIAF-0004MN-IG for guix-patches@gnu.org; Fri, 18 Jun 2021 13:20:19 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1luIAF-0004vw-Fn for guix-patches@gnu.org; Fri, 18 Jun 2021 13:20:19 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49025] [PATCH v3 core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Jun 2021 17:20:19 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49025 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49025@debbugs.gnu.org Cc: othacehe@gnu.org, Maxime Devos Received: via spool by 49025-submit@debbugs.gnu.org id=B49025.162403680318701 (code B ref 49025); Fri, 18 Jun 2021 17:20:19 +0000 Received: (at 49025) by debbugs.gnu.org; 18 Jun 2021 17:20:03 +0000 Received: from localhost ([127.0.0.1]:58086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luI9t-0004qy-Ja for submit@debbugs.gnu.org; Fri, 18 Jun 2021 13:20:03 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:34862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luI9H-0004jA-Rg for 49025@debbugs.gnu.org; Fri, 18 Jun 2021 13:19:23 -0400 Received: from localhost.localdomain ([213.119.219.214]) by andre.telenet-ops.be with bizsmtp id JhK5250094e8Tal01hKKeh; Fri, 18 Jun 2021 19:19:19 +0200 From: Maxime Devos Date: Fri, 18 Jun 2021 19:16:30 +0200 Message-Id: <20210618171631.20534-36-maximedevos@telenet.be> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618171631.20534-1-maximedevos@telenet.be> References: <20210618171631.20534-1-maximedevos@telenet.be> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1624036759; bh=cL6/X82yxoqwh+DYMtBl3NVxy2HSHe9g4hdvR4Kv7Bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To; b=WQoO5oH7JUufqZdiA37OEnNqY+t00vKOX4hFYZlM56HQbXt5WraYlXqUp6DikKuBP hyLAiWQs2s8q/n+Sm4fz5LARiKsyNe0F6yH1YxUdZ0gHqALSympyPoVmyUDDcr1s0N JZTFgHfZKCdJoLDS2D2Vw5wnTrAEAirjVGnI2e/kpD1iFN1/sLRTRwT1Bmfp9/ULq5 ehJki+ahmH3GRaxnXxQcsx2ERmtl2FZefrdatj+ixcCaiFAS/+B5HBxsZvFbATAimK ENoGDqjM3FeH+6tgeGIZSwP42SnQbvMHT5j15QJ7lE6KsbKLTa+KFGGdqzl87I4EpS Bz99qFtq1tSqQ== 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: , Reply-To: 49025@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches GCC doesn't find libgcc_s.so anymore and looks in the wrong location. Fix this (well, more a work-around really). * gnu/packages/cross-base.scm (cross-gcc-arguments)<#:configure-flags>: Add --with-toolexecdir, such that libstdc++ ends up in the right place. Add --with-slibdir such that libgcc_s.so end up in the right place. (cross-gcc-arguments)<#:phases>{move-shared-libraries}: New phase, moving libraries in the correct place. Delete .la files, libasan.so and libusan.so to prevent circular references. Likewise, fix a reference in libstdc++.so.VERSION-gdb.py. --- gnu/packages/cross-base.scm | 63 +++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 9487ac9238..995b4ae065 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2019, 2020, 2021 Marius Bakke ;;; Copyright © 2019 Carl Dong ;;; Copyright © 2020 Mathieu Othacehe +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,6 +34,7 @@ #:use-module (guix packages) #:use-module (guix download) #:use-module (guix utils) + #:use-module (guix gexp) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:use-module (srfi srfi-1) @@ -169,9 +171,26 @@ base compiler and using LIBC (which may be either a libc package or #f.)" )) ;; Install cross-built libraries such as libgcc_s.so in - ;; the "lib" output. + ;; the "lib" output. At least for version 8.4.0, GCC + ;; will put libstdc++ in ${toolexecdir}/lib instead. + ;; (A bug?) So set --with-toolexecdir as well. + ,@(if libc - `((string-append "--with-toolexeclibdir=" + `((string-append "--with-toolexecdir=" + (assoc-ref %outputs "lib")) + (string-append "--with-toolexeclibdir=" + (assoc-ref %outputs "lib") + "/" ,target "/lib")) + '()) + ;; At least for GCC 8.0, libgcc_s.so and libstdc++.so + ;; are not installed in the location specified in + ;; --with-toolexeclibdir so GCC will not find it + ;; when cross-compiling, say, GNU Hello. + ;; + ;; Work-around by specifying slibdir. This is not + ;; sufficient, see move-shared-libraries below. + ,@(if (and libc (version>=? (package-version xgcc) "8.0")) + `((string-append "--with-slibdir=" (assoc-ref %outputs "lib") "/" ,target "/lib")) '()) @@ -193,7 +212,45 @@ base compiler and using LIBC (which may be either a libc package or #f.)" ,flags)) flags)) ((#:phases phases) - `(cross-gcc-build-phases ,target ,phases)))))) + (if (and libc (version>=? (package-version xgcc) "8.0")) + #~(modify-phases (cross-gcc-build-phases #$target #$phases) + (add-after 'install 'move-shared-libraries + (lambda _ + (let* ((slib (format #f "~a/~a/lib/" #$output:lib #$target)) + (badlib (format #f "~a/~a/lib/" #$output #$target)) + (libs (map basename (find-files badlib #:fail-on-error? #t)))) + (for-each + (lambda (lib) + (let ((from (string-append badlib lib)) + (to (string-append slib lib))) + (when (file-exists? to) + (error "~a was found twice, refusing to overwrite!" + lib)) + ;; The debugging script libstdc++.so.VERSION-gdb.py has + ;; reference to #$output. Correct it. + (when (string-suffix? "-gdb.py" lib) + (substitute* from + (("libdir = '(.*)'") + (string-append "libdir = '" slib "'"))) + (system* "cat" from)) + ;; The .la files have references to BADLIB, + ;; leading to cyclic references between + ;; the outputs of the package. Remove them + ;; and hope noone notices. + ;; + ;; Likewise, libasan.so.* and libubsan.so.* + ;; have references to #$output. + (if (or (string-suffix? ".la" lib) + (string-prefix? "libasan.so" lib) + (string-prefix? "libubsan.so" lib)) + (delete-file from) + (rename-file from to)))) + libs) + ;; If you have "cyclic references" problems, + ;; uncomment this and use --keep-failed to figure + ;; things out. + (copy-recursively #$output:lib "out-test"))))) + #~(cross-gcc-build-phases #$target #$phases))))))) (define (cross-gcc-patches xgcc target) "Return GCC patches needed for XGCC and TARGET."