From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Benc Subject: Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu Date: Sun, 01 Feb 2015 19:56:27 +0100 Message-ID: <54CE76DB.2040606@gmail.com> References: CAFtzXzN3Tu4+n5ku7wNqxKXm4e1D5O64OamZWN2-Gni8Aza_eA@mail.gmail.com <54CCADF7.6090708@gmail.com> <54CD5372.5090103@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050205070609000008050306" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHzhA-00069X-3f for guix-devel@gnu.org; Sun, 01 Feb 2015 13:56:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHzh5-0001mJ-42 for guix-devel@gnu.org; Sun, 01 Feb 2015 13:56:32 -0500 Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]:57539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHzh4-0001mB-OU for guix-devel@gnu.org; Sun, 01 Feb 2015 13:56:27 -0500 Received: by mail-we0-f181.google.com with SMTP id k48so35482537wev.12 for ; Sun, 01 Feb 2015 10:56:25 -0800 (PST) In-Reply-To: <54CD5372.5090103@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: manolis837@gmail.com Cc: guix-devel@gnu.org This is a multi-part message in MIME format. --------------050205070609000008050306 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 01/31/2015 11:13 PM, Marek Benc wrote: > > The current issue is that, when building cross-gcc, when it reaches > libgomp, configure fails when trying to create a dummy binary. For some > reason, the compiled cross-compiler needs --rpath to specify where > shared libraries are, as without it, it can't find libmachuser.so and > libhurduser.so, which causes it to fail. > Well, I figured out a way to solve it, however, I don't know if the change is acceptable, since it alters how cross-compilers work. In the attached patch, which builds upon the one from my previous email, I made cross compilers not use binutils' ld directly, but instead use the ld-wrapper script. This means that while the Hurd cross compiler now works, binaries made by cross compilers have their library paths hard-coded into their RPATH section, which means that they're less flexible, which might be a problem. For some reason, the hurd cross-linker can't find libraries without specifying a --rpath, which is strange imho. We'll have to ask Ludo whether we can do it this way, but for the time being, time to get to the fixing of actual Hurd portability issues :) -- Marek. --------------050205070609000008050306 Content-Type: text/x-patch; name="hurd-branch-cross-compiler-use-ld-wrapper.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hurd-branch-cross-compiler-use-ld-wrapper.patch" --- guix.old/gnu/packages/cross-base.scm 2015-02-01 13:52:32.657316282 +0100 +++ guix/gnu/packages/cross-base.scm 2015-02-01 19:42:12.563316282 +0100 @@ -33,6 +33,7 @@ #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:export (cross-binutils + cross-ld-wrapper cross-libc cross-gcc)) @@ -67,6 +68,46 @@ `(cons "--with-sysroot=/" ,flags))))))) (cross binutils target))) +(define (cross-ld-wrapper target binutils) + "Return a linker wrapper for BINUTILS of TARGET." + (package (inherit ld-wrapper) + (name (string-append (package-name ld-wrapper) "-cross-" target)) + (inputs '()) + (native-inputs `(("binutils" ,binutils) + ,@(fold alist-delete (package-inputs ld-wrapper) + '("binutils")))) + (arguments + `(#:modules ((guix build utils)) + #:builder (begin + (use-modules (guix build utils) + (system base compile)) + + (let* ((target ,target) + (out (assoc-ref %outputs "out")) + (bin (string-append out "/bin")) + (ld (string-append bin "/" target "-ld")) + (go (string-append bin "/" target "-ld.go"))) + + (setvbuf (current-output-port) _IOLBF) + (format #t "building ~s/bin/~s-ld wrapper in ~s~%" + (assoc-ref %build-inputs "binutils") + target out) + + (mkdir-p bin) + (copy-file (assoc-ref %build-inputs "wrapper") ld) + (substitute* ld + (("@GUILE@") + (string-append (assoc-ref %build-inputs "guile") + "/bin/guile")) + (("@BASH@") + (string-append (assoc-ref %build-inputs "bash") + "/bin/bash")) + (("@LD@") + (string-append (assoc-ref %build-inputs "binutils") + "/bin/" target "-ld"))) + (chmod ld #o555) + (compile-file ld #:output-file go))))))) + (define (cross-gcc-arguments target libc) "Return build system arguments for a cross-gcc for TARGET, using LIBC (which may be either a libc package or #f.)" @@ -112,17 +153,24 @@ `(alist-cons-after 'install 'make-cross-binutils-visible (lambda* (#:key outputs inputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (libexec (string-append out "/libexec/gcc/" - ,target)) - (binutils (string-append - (assoc-ref inputs "binutils-cross") - "/bin/" ,target "-"))) + (let* ((out (assoc-ref outputs "out")) + (libexec (string-append out "/libexec/gcc/" + ,target)) + (binutils (string-append + (assoc-ref inputs "binutils-cross") + "/bin/" ,target "-")) + (ld-wrapper (string-append + (assoc-ref inputs "ld-wrapper-cross") + "/bin/" ,target "-ld"))) (for-each (lambda (file) (symlink (string-append binutils file) (string-append libexec "/" file))) - '("as" "ld" "nm")) + '("as" "nm")) + ;; Use ld-wrapper instead of directly binutils ld. + (symlink ld-wrapper (string-append libexec "/ld")) + (symlink (string-append ld-wrapper ".go") + (string-append libexec "/ld.go")) #t)) ,phases))) (if libc @@ -207,7 +255,8 @@ ,@(cross-gcc-arguments target libc))) (native-inputs - `(("binutils-cross" ,xbinutils) + `(("ld-wrapper-cross" ,(cross-ld-wrapper target xbinutils)) + ("binutils-cross" ,xbinutils) ;; Call it differently so that the builder can check whether the "libc" ;; input is #f. --- guix.old/guix/build-system/gnu.scm 2015-01-31 11:06:42.067984113 +0100 +++ guix/guix/build-system/gnu.scm 2015-02-01 17:42:28.609316282 +0100 @@ -381,15 +381,18 @@ (lambda (target kind) "Return the list of name/package tuples to cross-build for TARGET. KIND is one of `host' or `target'." - (let* ((cross (resolve-interface '(gnu packages cross-base))) - (gcc (module-ref cross 'cross-gcc)) - (binutils (module-ref cross 'cross-binutils)) - (libc (module-ref cross 'cross-libc))) + (let* ((cross (resolve-interface '(gnu packages cross-base))) + (gcc (module-ref cross 'cross-gcc)) + (binutils (module-ref cross 'cross-binutils)) + (ld-wrapper (module-ref cross 'cross-ld-wrapper)) + (libc (module-ref cross 'cross-libc))) (case kind ((host) `(("cross-gcc" ,(gcc target (binutils target) (libc target))) + ("cross-ld-wrapper" ,(ld-wrapper target + (binutils target))) ("cross-binutils" ,(binutils target)) ,@(standard-packages))) ((target) --------------050205070609000008050306--