dslm4515 / Musl-LFS

Linux From Scratch using Musl as Libc
GNU General Public License v3.0
167 stars 21 forks source link

Unable to Cross Compile Coreutils for Toolchain #4

Closed dslm4515 closed 5 years ago

dslm4515 commented 5 years ago

Compiler: GCC-9.1.0 Libc: Musl-1.1.22 Arch: i686 Building for: Toolchain in /tools Configures: Yes Compiles: No.

/mnt/sda4/cross-tools/bin/../lib/gcc/i686-mlfs-linux-musl/9.1.0/../../../../i686-mlfs-linux-musl/bin/ld: lib/libcoreutils.a(strtold.o):/mnt/sda4/sources/coreutils-8.31/lib/strtod.c:305: multiple definition of `minus_zero'; lib/libcoreutils.a(strtod.o):/mnt/sda4/sources/coreutils-8.31/lib/strtod.c:305: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:8537: src/od] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/mnt/sda4/sources/coreutils-8.31'
make[1]: *** [Makefile:12165: all-recursive] Error 1
make[1]: Leaving directory '/mnt/sda4/sources/coreutils-8.31'
make: *** [Makefile:6351: all] Error 2
dslm4515 commented 5 years ago

Tried to modify source after configure;

cp Makefile Makefile.orig
sed '/src_make_prime_list/d' Makefile.orig > Makefile
depbase=$(echo src/make-prime-list.o | sed 's|[^/]*$|.deps/&|;s|\.o$||');\
     cc -std=gnu99 -I. -I./lib -Ilib -I./lib -Isrc -I./src \
     -fdiagnostics-show-option -funit-at-a-time -g -O2 -MT \
     src/make-prime-list.o -MD -MP -MF $depbase.Tpo -c -o src/make-prime-list.o \
     src/make-prime-list.c &&
mv -f $depbase.Tpo $depbase.Po &&
cc -std=gnu99 -fdiagnostics-show-option -funit-at-a-time -g -O2 \
     -Wl,--as-needed -o src/make-prime-list src/make-prime-list.o &&
cp Makefile Makefile.bak
sed -e '/hostname.1/d' Makefile.bak > Makefile

Same error

dslm4515 commented 5 years ago

Looks like issue has been reported for NixOS:

coreutils-8.31 is broken on musl- https://github.com/NixOS/nixpkgs/issues/59934

dslm4515 commented 5 years ago

Patching lib/strtod.c allowed build to complete.

diff -uNr coreutils-8.31.orig/lib/strtod.c coreutils-8.31/lib/strtod.c
--- coreutils-8.31.orig/lib/strtod.c    2019-02-10 21:25:16.000000000 -0600
+++ coreutils-8.31/lib/strtod.c 2019-08-31 18:28:57.940216893 -0500
@@ -294,16 +294,15 @@
    ICC 10.0 has a bug when optimizing the expression -zero.
    The expression -MIN * MIN does not work when cross-compiling
    to PowerPC on Mac OS X 10.5.  */
-#if defined __hpux || defined __sgi || defined __ICC
 static DOUBLE
-compute_minus_zero (void)
+minus_zero (void)
 {
+#if defined __hpux || defined __sgi || defined __ICC
   return -MIN * MIN;
-}
-# define minus_zero compute_minus_zero ()
 #else
-DOUBLE minus_zero = -0.0;
+  return -0.0;
 #endif
+}

 /* Convert NPTR to a DOUBLE.  If ENDPTR is not NULL, a pointer to the
    character after the last one used in the number is put in *ENDPTR.  */
@@ -479,6 +478,6 @@
   /* Special case -0.0, since at least ICC miscompiles negation.  We
      can't use copysign(), as that drags in -lm on some platforms.  */
   if (!num && negative)
-    return minus_zero;
+    return minus_zero ();
   return negative ? -num : num;
 }

source: https://www.mail-archive.com/bug-gnulib@gnu.org/msg36503.html