all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marek Benc <merkur32@gmail.com>
To: manolis837@gmail.com
Cc: guix-devel@gnu.org
Subject: Re: problem with building gcc-cross-4.8.3 for i686-pc-gnu
Date: Sat, 31 Jan 2015 23:13:06 +0100	[thread overview]
Message-ID: <54CD5372.5090103@gmail.com> (raw)
In-Reply-To: <54CCADF7.6090708@gmail.com>

[-- 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"

  reply	other threads:[~2015-01-31 22:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54CD5372.5090103@gmail.com \
    --to=merkur32@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=manolis837@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.