unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* problem with building gcc-cross-4.8.3 for i686-pc-gnu
@ 2014-12-30 14:28 Manolis Ragkousis
  2015-01-03 21:27 ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Manolis Ragkousis @ 2014-12-30 14:28 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 845 bytes --]

Hello guix, Hello Ludo

When trying to build coreutils for i686-pc-gnu, building
cross-gcc-4.8.3 with glibc-hurd fails with:

In unknown file:
   ?: 0 [string-append
"/gnu/store/1hl59s1pikplwfgclw4mlk38pkx3pc72-glibc-hurd-cross-i686-pc-gnu-2.18"
...]

ERROR: In procedure string-append:
ERROR: In procedure string-append: Wrong type (expecting string): #f

It shouldn't fail because glibc/hurd is in the path.

Checking the patch-source-shebangs phase, in the build log, shows that
the /bin/sh path is changed to use the native glibc, which I believe causes
the problem.

I am trying to understand and solve this, but I think I am
missing something from the building procedure of coreutils, so any
advice will be helpful. Why it doesn't use the glibc that it just cross-built?

I am attaching the build log and the env vars.

Thank you,
Manolis

[-- Attachment #2: 2macgcqsp2d760kyyxpfqx37kgi0ba-gcc-cross-i686-pc-gnu-4.8.3.drv.bz2 --]
[-- Type: application/x-bzip2, Size: 341717 bytes --]

[-- Attachment #3: environment-variables --]
[-- Type: application/octet-stream, Size: 4892 bytes --]

export CPATH="/gnu/store/3h38sfay2f02rk4i768ci8xabl706rf9-glibc-2.20/include:/gnu/store/rw5s9immq72plzajqm8g8i4sfg8z0kyc-linux-libre-headers-3.3.8/include:/gnu/store/1hl59s1pikplwfgclw4mlk38pkx3pc72-glibc-hurd-cross-i686-pc-gnu-2.18/include:/gnu/store/26wgqpd56vka6nvhq7qmb9wlm45n5dz7-hurd-minimal-cross-i686-pc-gnu-0.5/include:/gnu/store/57nflkf654zbc5wbsgkrvv3swqpnm4qz-hurd-headers-cross-i686-pc-gnu-0.5/include:/gnu/store/afz0x4z8vj4pimjkvjsbsy3dz3llsxkf-gnumach-headers-cross-i686-pc-gnu-1.4/include:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/include:/gnu/store/s0lg3f8wjdynln0086bqz7igsjmf5411-mpfr-3.1.2/include:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/include:/gnu/store/w87kcf7m1jh0jrl1kazbv7m2ldwybxq8-mpc-1.0.2/include:/gnu/store/s0lg3f8wjdynln0086bqz7igsjmf5411-mpfr-3.1.2/include:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/include:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/include:/gnu/store/ik0xxrzqgsz76gz3dbqcgfr5agl2khb9-isl-0.11.1/include:/gnu/store/c5cjz3qz09ayr6x742xhcf9zgyjymbv8-cloog-0.18.0/include:/gnu/store/2lg7wrqwvmmqh5vd8zvv1gwjfpbkgk38-libelf-0.8.13/include:/gnu/store/kmbdwpxvp4d5n7lm2j4829x7km8cyl1y-zlib-1.2.7/include:/gnu/store/nlns82dixqq4lkmpbvxg9crspihgrbf3-bzip2-1.0.6/include:/gnu/store/5s0minkxnzyazi4yra7p97g8dnfv4g16-xz-5.0.4/include:/gnu/store/9xdlrfvy2w3n24b7z22wd7dnjddxjndy-file-5.19/include:/gnu/store/2rmb78pg4nxc4dg4ffmm7qnar3j4am32-gawk-4.1.1/include:/gnu/store/qx2kk00lhmqsrickigdgi4kb733xgd2r-make-4.0/include:/gnu/store/45ki3bmjs5xchx071kq86542d5y2dfp2-binutils-2.24/include:/gnu/store/nmxfncmpj4ymdlr8d4k3lcdcc6mbwb6w-gcc-4.8.3/include"
export HOME="/homeless-shelter"
export LIBRARY_PATH="/gnu/store/3h38sfay2f02rk4i768ci8xabl706rf9-glibc-2.20/lib:/gnu/store/1hl59s1pikplwfgclw4mlk38pkx3pc72-glibc-hurd-cross-i686-pc-gnu-2.18/lib:/gnu/store/26wgqpd56vka6nvhq7qmb9wlm45n5dz7-hurd-minimal-cross-i686-pc-gnu-0.5/lib:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/lib:/gnu/store/s0lg3f8wjdynln0086bqz7igsjmf5411-mpfr-3.1.2/lib:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/lib:/gnu/store/w87kcf7m1jh0jrl1kazbv7m2ldwybxq8-mpc-1.0.2/lib:/gnu/store/s0lg3f8wjdynln0086bqz7igsjmf5411-mpfr-3.1.2/lib:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/lib:/gnu/store/9ia5ps6x1ir1hml58vvjyh1l7ww46gnk-gmp-6.0.0a/lib:/gnu/store/ik0xxrzqgsz76gz3dbqcgfr5agl2khb9-isl-0.11.1/lib:/gnu/store/c5cjz3qz09ayr6x742xhcf9zgyjymbv8-cloog-0.18.0/lib:/gnu/store/2lg7wrqwvmmqh5vd8zvv1gwjfpbkgk38-libelf-0.8.13/lib:/gnu/store/kmbdwpxvp4d5n7lm2j4829x7km8cyl1y-zlib-1.2.7/lib:/gnu/store/nlns82dixqq4lkmpbvxg9crspihgrbf3-bzip2-1.0.6/lib:/gnu/store/5s0minkxnzyazi4yra7p97g8dnfv4g16-xz-5.0.4/lib:/gnu/store/9xdlrfvy2w3n24b7z22wd7dnjddxjndy-file-5.19/lib:/gnu/store/2rmb78pg4nxc4dg4ffmm7qnar3j4am32-gawk-4.1.1/lib:/gnu/store/45ki3bmjs5xchx071kq86542d5y2dfp2-binutils-2.24/lib"
export NIX_BUILD_CORES="2"
export NIX_BUILD_TOP="/tmp/nix-build-gcc-cross-i686-pc-gnu-4.8.3.drv-0"
export NIX_STORE="/gnu/store"
export OLDPWD
export PATH="/gnu/store/bszwxw0d77f6mi3l8n5zn5v94306fziq-binutils-cross-i686-pc-gnu-2.24/bin:/gnu/store/3h38sfay2f02rk4i768ci8xabl706rf9-glibc-2.20/bin:/gnu/store/3h38sfay2f02rk4i768ci8xabl706rf9-glibc-2.20/sbin:/gnu/store/1hl59s1pikplwfgclw4mlk38pkx3pc72-glibc-hurd-cross-i686-pc-gnu-2.18/bin:/gnu/store/1hl59s1pikplwfgclw4mlk38pkx3pc72-glibc-hurd-cross-i686-pc-gnu-2.18/sbin:/gnu/store/c5cjz3qz09ayr6x742xhcf9zgyjymbv8-cloog-0.18.0/bin:/gnu/store/vzp9kx3qia35isi3isrmhr9klzd3wkp7-tar-1.28/bin:/gnu/store/q5dxwd523y0blylj3k2s5y4lr7llxc31-gzip-1.6/bin:/gnu/store/nlns82dixqq4lkmpbvxg9crspihgrbf3-bzip2-1.0.6/bin:/gnu/store/5s0minkxnzyazi4yra7p97g8dnfv4g16-xz-5.0.4/bin:/gnu/store/9xdlrfvy2w3n24b7z22wd7dnjddxjndy-file-5.19/bin:/gnu/store/l23x1c00415hpnnb8ilka3bv8xfv5qbn-diffutils-3.3/bin:/gnu/store/5b0sidpj18sys487b0n508rcjxmygwv2-patch-2.7.1/bin:/gnu/store/ai555s3wy50rsa74mlnw3jfbgj3fx9y1-sed-4.2.2/bin:/gnu/store/bna9rhyfz9ijl3hhgnmsywy4cld5fma9-findutils-4.4.2/bin:/gnu/store/2rmb78pg4nxc4dg4ffmm7qnar3j4am32-gawk-4.1.1/bin:/gnu/store/3hy722q3q4pd9mbk4jp2q3y1pb4mp4mv-grep-2.20/bin:/gnu/store/arvd1w0vywxdz8pir3cdagqg21lcrid0-coreutils-8.23/bin:/gnu/store/qx2kk00lhmqsrickigdgi4kb733xgd2r-make-4.0/bin:/gnu/store/3fd4cw58xy7k7sg6hj08b06vgk4qfhdv-bash-4.3.25/bin:/gnu/store/387mkhv1cnb6c4l54cky2l1ca9c9dxvi-ld-wrapper-0/bin:/gnu/store/45ki3bmjs5xchx071kq86542d5y2dfp2-binutils-2.24/bin:/gnu/store/nmxfncmpj4ymdlr8d4k3lcdcc6mbwb6w-gcc-4.8.3/bin"
export PWD="/tmp/nix-build-gcc-cross-i686-pc-gnu-4.8.3.drv-0/gcc-4.8.3"
export SHLVL="1"
export TEMP="/tmp/nix-build-gcc-cross-i686-pc-gnu-4.8.3.drv-0"
export TEMPDIR="/tmp/nix-build-gcc-cross-i686-pc-gnu-4.8.3.drv-0"
export TMP="/tmp/nix-build-gcc-cross-i686-pc-gnu-4.8.3.drv-0"
export TMPDIR="/tmp/nix-build-gcc-cross-i686-pc-gnu-4.8.3.drv-0"
export out="/gnu/store/a1a3z1avs14vm4xs8qsa4s8arlhbipx2-gcc-cross-i686-pc-gnu-4.8.3"

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
  2014-12-30 14:28 problem with building gcc-cross-4.8.3 for i686-pc-gnu Manolis Ragkousis
@ 2015-01-03 21:27 ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2015-01-03 21:27 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: Guix-devel

Manolis Ragkousis <manolis837@gmail.com> skribis:

> When trying to build coreutils for i686-pc-gnu, building
> cross-gcc-4.8.3 with glibc-hurd fails with:
>
> In unknown file:
>    ?: 0 [string-append
> "/gnu/store/1hl59s1pikplwfgclw4mlk38pkx3pc72-glibc-hurd-cross-i686-pc-gnu-2.18"
> ...]
>
> ERROR: In procedure string-append:
> ERROR: In procedure string-append: Wrong type (expecting string): #f
>
> It shouldn't fail because glibc/hurd is in the path.

From the log you sent, it’s the ‘set-cross-path’ phase (of the
cross-gcc) that’s failing.

In cross-base.scm (in master), one of them is like this:

                   (setenv "CROSS_CPATH"
                           (string-append libc "/include:"
                                          linux "/include"))

Could it be that in your case ‘linux’ above is #f, hence the error?

HTH,
Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
@ 2015-01-31 10:27 Marek Benc
  2015-01-31 22:13 ` Marek Benc
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Benc @ 2015-01-31 10:27 UTC (permalink / raw)
  To: manolis837; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

Could you try out the patch in this email?

Now, the problem is that GCC is configured with the native ld.so as the 
target system's dynamic linker.

I'm not sure what code is responsible for that, but on the wip-hurd 
branch, this exact same problem happens for other platforms as well.

In particular, it happened when I tried:
$ ./pre-inst-env guix build coreutils --target=i686-pc-linux-gnu -K
on an x86_64 box.

-- 
Marek.

[-- Attachment #2: set-cross-path-fix.patch --]
[-- Type: text/x-patch, Size: 2746 bytes --]

--- guix.old/gnu/packages/cross-base.scm	2015-01-31 11:06:42.025984113 +0100
+++ guix/gnu/packages/cross-base.scm	2015-01-31 10:37:35.290053633 +0100
@@ -151,21 +151,33 @@
                  `(alist-cons-before
                    'configure 'set-cross-path
                    (lambda* (#:key inputs #:allow-other-keys)
-                     ;; Add the cross Linux headers to CROSS_CPATH, and remove
+                     ;; Add the cross kernel headers to CROSS_CPATH, and remove
                      ;; them from CPATH.
                      (let ((libc  (assoc-ref inputs "libc"))
                            (linux (assoc-ref inputs
-                                             "libc/cross-linux-headers")))
+                                             "libc/cross-linux-headers"))
+                           (mach  (assoc-ref inputs
+                                             "libc/cross-gnumach-headers"))
+                           (hurd  (assoc-ref inputs
+                                             "libc/cross-hurd-headers"))
+                           (hurd-minimal (assoc-ref inputs
+                                             "libc/cross-hurd-minimal")))
                        (define (cross? x)
-                         ;; Return #t if X is a cross-libc or cross Linux.
+                         ;; Return #t if X is a cross-libc or a cross-kernel.
                          (or (string-prefix? libc x)
-                             (string-prefix? linux x)))
+                             (if linux        (string-prefix? linux x) #f)
+                             (if hurd         (string-prefix? hurd  x) #f)
+                             (if mach         (string-prefix? mach  x) #f)
+                             (if hurd-minimal (string-prefix? hurd-minimal x) #f)))
 
                        (setenv "CROSS_CPATH"
-                               (string-append libc "/include:"
-                                              linux "/include"))
+                               (string-append libc "/include"
+                                              (if linux (string-append ":" linux "/include") "")
+                                              (if hurd  (string-append ":" hurd "/include"
+                                                                       ":" mach "/include")  "")))
                        (setenv "CROSS_LIBRARY_PATH"
-                               (string-append libc "/lib"))
+                               (string-append libc "/lib"
+                                              (if hurd-minimal (string-append ":" hurd-minimal "/lib") "")))
 
                        (let ((cpath   (search-path-as-string->list
                                        (getenv "CPATH")))

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
  2015-01-31 10:27 problem with building gcc-cross-4.8.3 for i686-pc-gnu Marek Benc
@ 2015-01-31 22:13 ` Marek Benc
  2015-02-01 18:56   ` Marek Benc
  2015-02-05 12:38   ` Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: Marek Benc @ 2015-01-31 22:13 UTC (permalink / raw)
  To: manolis837; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]

Disregard the previous mail, I figured most of it out.

The attached patch does the following:
   1.) Adds the name of the dynamic linker to gnu/packages/bootstrap.scm
   2.) Adds code to gnu/package/gcc to substitute the default dynamic 
linker in gcc/config/arch/gnu.h for the one to be used.
   3.) Changes how the build system arguments for cross-gcc are created:
     A.) They're now in a separate procedure, reflecting how it's done 
in vanilla guix.
     B.) A bug is fixed that caused the native ld.so to be picked over 
the target one.
     C.) Fixed the 'set-cross-path phase so that it also checks for 
hurd-related packages, and checks package existence before passing 
anything to the string-handling functions.

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.

-- 
Marek.

[-- Attachment #2: hurd-branch-gcc-ld_so-fix.patch --]
[-- Type: text/x-patch, Size: 12685 bytes --]

--- guix.old/gnu/packages/bootstrap.scm	2015-01-31 11:06:42.020984113 +0100
+++ guix/gnu/packages/bootstrap.scm	2015-01-29 19:58:36.376427673 +0100
@@ -156,6 +156,7 @@
   (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
         ((string=? system "i686-linux") "/lib/ld-linux.so.2")
         ((string=? system "mips64el-linux") "/lib/ld.so.1")
+        ((string=? system "i686-gnu") "/lib/ld.so.1")
         (else (error "dynamic linker name not known for this system"
                      system))))
 
--- guix.old/gnu/packages/cross-base.scm	2015-01-31 11:06:42.025984113 +0100
+++ guix/gnu/packages/cross-base.scm	2015-01-31 12:16:33.365984113 +0100
@@ -67,6 +67,117 @@
                         `(cons "--with-sysroot=/" ,flags)))))))
     (cross binutils target)))
 
+(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.)"
+  ;; Set the current target system so that 'glibc-dynamic-linker' returns the
+  ;; right name.
+  (parameterize ((%current-target-system target))
+    (substitute-keyword-arguments (package-arguments gcc-4.8)
+      ((#:configure-flags flags)
+       `(append (list ,(string-append "--target=" target)
+                      ,@(if libc
+                            '()
+                            `( ;; Disable features not needed at this stage.
+                              "--disable-shared" "--enable-static"
+
+                              ;; Disable C++ because libstdc++'s configure
+                              ;; script otherwise fails with "Link tests are not
+                              ;; allowed after GCC_NO_EXECUTABLES."
+                              "--enable-languages=c"
+
+                              "--disable-threads"  ;libgcc, would need libc
+                              "--disable-libatomic"
+                              "--disable-libmudflap"
+                              "--disable-libgomp"
+                              "--disable-libssp"
+                              "--disable-libquadmath"
+                              "--disable-decimal-float" ;would need libc
+                              )))
+
+                ,(if libc
+                     flags
+                     `(remove (cut string-match "--enable-languages.*" <>)
+                              ,flags))))
+      ((#:make-flags flags)
+       (if libc
+           `(let ((libc (assoc-ref %build-inputs "libc")))
+              ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
+              ;; the -Bxxx for the startfiles.
+              (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
+                    ,flags))
+           flags))
+      ((#:phases phases)
+       (let ((phases
+              `(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 "-")))
+                    (for-each (lambda (file)
+                                (symlink (string-append binutils file)
+                                         (string-append libexec "/"
+                                                        file)))
+                              '("as" "ld" "nm"))
+                    #t))
+                ,phases)))
+         (if libc
+             `(alist-cons-before
+               'configure 'set-cross-path
+               (lambda* (#:key inputs #:allow-other-keys)
+                 ;; Add the cross-kernel headers to CROSS_CPATH, and remove them
+                 ;; from CPATH.
+                 (let ((libc  (assoc-ref inputs "libc"))
+                       (linux (assoc-ref inputs
+                                         "libc/cross-linux-headers"))
+                       (mach  (assoc-ref inputs
+                                         "libc/cross-gnumach-headers"))
+                       (hurd  (assoc-ref inputs
+                                         "libc/cross-hurd-headers"))
+                       (hurd-minimal (assoc-ref inputs
+                                         "libc/cross-hurd-minimal")))
+
+                   (define (cross? x)
+                     ;; Return #t if X is a cross-libc or a cross-kernel.
+                     (or (string-prefix? libc x)
+                         (if linux        (string-prefix? linux x) #f)
+                         (if hurd         (string-prefix? hurd  x) #f)
+                         (if mach         (string-prefix? mach  x) #f)
+                         (if hurd-minimal (string-prefix? hurd-minimal x) #f)))
+
+                   (setenv "CROSS_CPATH"
+                           (string-append libc "/include"
+                                          (if linux (string-append ":" linux "/include") "")
+                                          (if hurd  (string-append ":" hurd  "/include"
+                                                                   ":" mach  "/include") "")))
+                   (setenv "CROSS_LIBRARY_PATH"
+                           (string-append libc "/lib"
+                                          (if hurd-minimal (string-append ":" hurd-minimal "/lib") "")))
+
+                   (let ((cpath   (search-path-as-string->list
+                                   (getenv "CPATH")))
+                         (libpath (search-path-as-string->list
+                                   (getenv "LIBRARY_PATH"))))
+                     (setenv "CPATH"
+                             (list->search-path-as-string
+                              (remove cross? cpath) ":"))
+                     (setenv "LIBRARY_PATH"
+                             (list->search-path-as-string
+                              (remove cross? libpath) ":"))
+                     #t)))
+               ,phases)
+             phases)))
+      ((#:strip-binaries? _)
+       ;; Disable stripping as this can break binaries, with object files of
+       ;; libgcc.a showing up as having an unknown architecture.  See
+       ;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html>
+       ;; for instance.
+       #f))))
+
 (define* (cross-gcc target
                     #:optional (xbinutils (cross-binutils target)) libc)
   "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
@@ -93,99 +204,7 @@
                   (srfi srfi-1)
                   (srfi srfi-26))
 
-       ,@(substitute-keyword-arguments (package-arguments gcc-4.8)
-           ((#:configure-flags flags)
-            `(append (list ,(string-append "--target=" target)
-                           ,@(gcc-configure-flags-for-triplet target)
-                           ,@(if libc
-                                 '()
-                                 `( ;; Disable features not needed at this stage.
-                                   "--disable-shared" "--enable-static"
-
-                                   ;; Disable C++ because libstdc++'s
-                                   ;; configure script otherwise fails with
-                                   ;; "Link tests are not allowed after
-                                   ;; GCC_NO_EXECUTABLES."
-                                   "--enable-languages=c"
-
-                                   "--disable-threads" ; libgcc, would need libc
-                                   "--disable-libatomic"
-                                   "--disable-libmudflap"
-                                   "--disable-libgomp"
-                                   "--disable-libssp"
-                                   "--disable-libquadmath"
-                                   "--disable-decimal-float" ; would need libc
-                                   )))
-
-                     ,(if libc
-                          flags
-                          `(remove (cut string-match "--enable-languages.*" <>)
-                                   ,flags))))
-           ((#:make-flags flags)
-            (if libc
-                `(let ((libc (assoc-ref %build-inputs "libc")))
-                   ;; FLAGS_FOR_TARGET are needed for the target libraries to
-                   ;; receive the -Bxxx for the startfiles.
-                   (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
-                         ,flags))
-                flags))
-           ((#:phases phases)
-            (let ((phases
-                   `(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 "-")))
-                         (for-each (lambda (file)
-                                     (symlink (string-append binutils file)
-                                              (string-append libexec "/"
-                                                             file)))
-                                   '("as" "ld" "nm"))
-                         #t))
-                     ,phases)))
-             (if libc
-                 `(alist-cons-before
-                   'configure 'set-cross-path
-                   (lambda* (#:key inputs #:allow-other-keys)
-                     ;; Add the cross Linux headers to CROSS_CPATH, and remove
-                     ;; them from CPATH.
-                     (let ((libc  (assoc-ref inputs "libc"))
-                           (linux (assoc-ref inputs
-                                             "libc/cross-linux-headers")))
-                       (define (cross? x)
-                         ;; Return #t if X is a cross-libc or cross Linux.
-                         (or (string-prefix? libc x)
-                             (string-prefix? linux x)))
-
-                       (setenv "CROSS_CPATH"
-                               (string-append libc "/include:"
-                                              linux "/include"))
-                       (setenv "CROSS_LIBRARY_PATH"
-                               (string-append libc "/lib"))
-
-                       (let ((cpath   (search-path-as-string->list
-                                       (getenv "CPATH")))
-                             (libpath (search-path-as-string->list
-                                       (getenv "LIBRARY_PATH"))))
-                         (setenv "CPATH"
-                                 (list->search-path-as-string
-                                  (remove cross? cpath) ":"))
-                         (setenv "LIBRARY_PATH"
-                                 (list->search-path-as-string
-                                  (remove cross? libpath) ":"))
-                         #t)))
-                   ,phases)
-                 phases)))
-           ((#:strip-binaries? _)
-            ;; Disable stripping as this can break binaries, with object files
-            ;; of libgcc.a showing up as having an unknown architecture.  See
-            ;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html>
-            ;; for instance.
-            #f))))
+       ,@(cross-gcc-arguments target libc)))
 
     (native-inputs
      `(("binutils-cross" ,xbinutils)
--- guix.old/gnu/packages/gcc.scm	2015-01-31 11:06:42.031984113 +0100
+++ guix/gnu/packages/gcc.scm	2015-01-31 13:51:30.949984113 +0100
@@ -186,6 +186,13 @@
                            suffix
                            (string-append libc ,(glibc-dynamic-linker)))))
 
+                (substitute* (find-files "gcc/config"
+                                         "^gnu(64|-elf)?\\.h$")
+                  (("#define GNU_USER_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
+                   (format #f "#define GNU_USER_DYNAMIC_LINKER~a \"~a\"~%"
+                           suffix
+                           (string-append libc ,(glibc-dynamic-linker)))))
+
                 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
                 ;; `crt{begin,end}.o', which come with GCC.
                 (substitute* (find-files "gcc/config"

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
  2015-01-31 22:13 ` Marek Benc
@ 2015-02-01 18:56   ` Marek Benc
  2015-02-05 12:44     ` Ludovic Courtès
  2015-02-05 12:38   ` Ludovic Courtès
  1 sibling, 1 reply; 10+ messages in thread
From: Marek Benc @ 2015-02-01 18:56 UTC (permalink / raw)
  To: manolis837; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]



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.

[-- Attachment #2: hurd-branch-cross-compiler-use-ld-wrapper.patch --]
[-- Type: text/x-patch, Size: 5921 bytes --]

--- 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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
  2015-01-31 22:13 ` Marek Benc
  2015-02-01 18:56   ` Marek Benc
@ 2015-02-05 12:38   ` Ludovic Courtès
  2015-02-05 16:22     ` [PATCH 0/4] gnu: Fix ld.so detection of cross-compilers for the GNU Hurd system Marek Benc
  1 sibling, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2015-02-05 12:38 UTC (permalink / raw)
  To: Marek Benc; +Cc: guix-devel

Marek Benc <merkur32@gmail.com> skribis:

> The attached patch does the following:
>   1.) Adds the name of the dynamic linker to gnu/packages/bootstrap.scm
>   2.) Adds code to gnu/package/gcc to substitute the default dynamic
> linker in gcc/config/arch/gnu.h for the one to be used.
>   3.) Changes how the build system arguments for cross-gcc are created:
>     A.) They're now in a separate procedure, reflecting how it's done
> in vanilla guix.
>     B.) A bug is fixed that caused the native ld.so to be picked over
> the target one.
>     C.) Fixed the 'set-cross-path phase so that it also checks for
> hurd-related packages, and checks package existence before passing
> anything to the string-handling functions.

This all looks good to me.  However, this should really be 5 different
patches so as to ease review, bisection, etc.  Could you do that?

Please prefer one message per patch, as with ‘git send-email’.

TIA!

Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
  2015-02-01 18:56   ` Marek Benc
@ 2015-02-05 12:44     ` Ludovic Courtès
       [not found]       ` <54D3A92A.6060209@gmx.com>
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2015-02-05 12:44 UTC (permalink / raw)
  To: Marek Benc; +Cc: guix-devel

Marek Benc <merkur32@gmail.com> skribis:

> 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.

Using RUNPATH is not a problem: it’s what we always do.  ;-)

That said, in practice we haven’t done anything special about it in
cross-compilation contexts and things have worked fine.  I believe this
is due to the fact that we’ve only built things that use Libtool, and
Libtool adds --rpath automatically.

Another thing I don’t understand is that we use "--disable-libgomp" in
‘cross-gcc-arguments’, which means that the first cross-gcc (sans libc)
does not build libgomp.  What are things going wrong here?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 0/4] gnu: Fix ld.so detection of cross-compilers for the GNU Hurd system.
  2015-02-05 12:38   ` Ludovic Courtès
@ 2015-02-05 16:22     ` Marek Benc
  0 siblings, 0 replies; 10+ messages in thread
From: Marek Benc @ 2015-02-05 16:22 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

On 02/05/2015 01:38 PM, Ludovic Courtès wrote:

>
> This all looks good to me.  However, this should really be 5 different
> patches so as to ease review, bisection, etc.  Could you do that?
>
> Please prefer one message per patch, as with ‘git send-email’.
>

Sure thing, just finished splitting/converting them, will post them 
right away.

Keep in mind, all of these patches are for the wip-hurd branch.

>
> Ludo’.
>

-- 
Marek.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
       [not found]         ` <87h9v014wk.fsf@gnu.org>
@ 2015-02-05 20:32           ` Marek Benc
  2015-02-07 23:24             ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Benc @ 2015-02-05 20:32 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel



On 02/05/2015 09:26 PM, Ludovic Courtès wrote:
> Marek Benc <dusxmt@gmx.com> skribis:
>
>> On 02/05/2015 01:44 PM, Ludovic Courtès wrote:
>>
>>>
>>> Another thing I don’t understand is that we use "--disable-libgomp" in
>>> ‘cross-gcc-arguments’, which means that the first cross-gcc (sans libc)
>>> does not build libgomp.  What are things going wrong here?
>>>
>>
>> I think it's because libgomp is a part of libgcc, and that needs the C
>> library, that's what the comments say at least.
>
> (Why off-list?)  Libgomp is the OpenMP run-time support library, which
> we don’t require when bootstrapping.
>

Sorry, I pressed the wrong button on my email client... silly me. I also 
might have not understood your question then...

Its build system tests whether the compiler works, and it does that by 
building a dummy binary. However, the binary fails to link as the linker 
can't find libmachuser and libhurduser, which are provided by libc, 
without --rpath. (If this is what you were asking about)

 >
> Ludo’.
>

-- 
Marek.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
  2015-02-05 20:32           ` Marek Benc
@ 2015-02-07 23:24             ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2015-02-07 23:24 UTC (permalink / raw)
  To: Marek Benc; +Cc: guix-devel

Marek Benc <dusxmt@gmx.com> skribis:

> On 02/05/2015 09:26 PM, Ludovic Courtès wrote:
>> Marek Benc <dusxmt@gmx.com> skribis:
>>
>>> On 02/05/2015 01:44 PM, Ludovic Courtès wrote:
>>>
>>>>
>>>> Another thing I don’t understand is that we use "--disable-libgomp" in
>>>> ‘cross-gcc-arguments’, which means that the first cross-gcc (sans libc)
>>>> does not build libgomp.  What are things going wrong here?
>>>>
>>>
>>> I think it's because libgomp is a part of libgcc, and that needs the C
>>> library, that's what the comments say at least.
>>
>> (Why off-list?)  Libgomp is the OpenMP run-time support library, which
>> we don’t require when bootstrapping.
>>
>
> Sorry, I pressed the wrong button on my email client... silly me. I
> also might have not understood your question then...
>
> Its build system tests whether the compiler works, and it does that by
> building a dummy binary. However, the binary fails to link as the
> linker can't find libmachuser and libhurduser, which are provided by
> libc, without --rpath. (If this is what you were asking about)

You’re talking about a ‘configure’ test in libgomp, right?

Could you post the config.log snippet that shows this problem?

Also, are you sure libgomp needs to be built at this stage?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-02-07 23:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-31 10:27 problem with building gcc-cross-4.8.3 for i686-pc-gnu Marek Benc
2015-01-31 22:13 ` Marek Benc
2015-02-01 18:56   ` Marek Benc
2015-02-05 12:44     ` Ludovic Courtès
     [not found]       ` <54D3A92A.6060209@gmx.com>
     [not found]         ` <87h9v014wk.fsf@gnu.org>
2015-02-05 20:32           ` Marek Benc
2015-02-07 23:24             ` Ludovic Courtès
2015-02-05 12:38   ` Ludovic Courtès
2015-02-05 16:22     ` [PATCH 0/4] gnu: Fix ld.so detection of cross-compilers for the GNU Hurd system Marek Benc
  -- strict thread matches above, loose matches on Subject: below --
2014-12-30 14:28 problem with building gcc-cross-4.8.3 for i686-pc-gnu Manolis Ragkousis
2015-01-03 21:27 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).