richfelker / musl-cross-make

Simple makefile-based build for musl cross compiler
MIT License
1.31k stars 265 forks source link

Build failure: x86_64-apple-darwin18.7.0 -> mipsel-linux-muslsf #157

Open inferiorhumanorgans opened 2 years ago

inferiorhumanorgans commented 2 years ago
Checking multilib configuration for libgcc...
# If this is the top-level multilib, build all the other
# multilibs.
Mode = sf\|df
Suffix = si\|2\|3
/Users/alex/musl-cross-make/build/local/mipsel-linux-musl/obj_gcc/./gcc/xgcc -B/Users/alex/musl-cross-make/build/local/mipsel-linux-musl/obj_gcc/./gcc/ -B/mipsel-linux-musl/bin/ -B/mipsel-linux-musl/lib/ -isystem /mipsel-linux-musl/include -isystem /mipsel-linux-musl/sys-include --sysroot=/Users/alex/musl-cross-make/build/local/mipsel-linux-musl/obj_sysroot   -g -O2 -minterlink-mips16 -O2  -g -O2 -minterlink-mips16 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -DGTHREAD_USE_WEAK=0 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -DGTHREAD_USE_WEAK=0 -I. -I. -I../.././gcc -I../../../src_gcc/libgcc -I../../../src_gcc/libgcc/. -I../../../src_gcc/libgcc/../gcc -I../../../src_gcc/libgcc/../include  -DHAVE_CC_TLS  -o addsf3.o -MT addsf3.o -MD -MP -MF addsf3.dep addsf3 -c ../../../src_gcc/libgcc/config/hardfp.c -fvisibility=hidden -DHIDE_EXPORTS -Wno-missing-prototypes
xgcc: error: addsf3: No such file or directory
make[3]: *** [addsf3.o] Error 1
make[2]: *** [all-target-libgcc] Error 2
make[1]: *** [obj_gcc/mipsel-linux-musl/libgcc/libgcc.a] Error 2
make: *** [all] Error 2
$ git rev-parse head
fe915821b652a7fa37b34a596f47d8e20bc72338

Note: mips-linux-muslsf builds successfully.

rofl0r commented 2 years ago

what's gcc version, etc, you're building? best to paste entire config.

inferiorhumanorgans commented 2 years ago
$uname -sr
Darwin 18.7.0

$egrep -v '^#' config.mak

TARGET = mipsel-linux-musl

So whatever the current defaults are. Looks like gcc 9.4.0.

rofl0r commented 2 years ago

i tried default config with TARGET=mipsel-linux-muslsf on linux, and it builds without issue. so it appears to be a mac specific issue.

inferiorhumanorgans commented 2 years ago

Okay I'll try again and post the rest of the logs. It looks like this is a longstanding issue with gcc. Sigh.

https://www.spinics.net/lists/gcchelp/msg42102.html

https://devel.rtems.org/ticket/2300?cversion=0&cnum_hist=4

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62097

There's a patch here to use (GNU) awk instead of GNU sed:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66032

The next error is:

true  DO=all multi-do # /Applications/Xcode.app/Contents/Developer/usr/bin/make MULTILIB_OSDIRNAMES= INFO_DEPS= infodir= ac_cv_prog_lex_root=lex.yy MAKEINFO=false
Checking multilib configuration for libatomic...
Makefile:558: .deps/fenv.Plo: No such file or directory
Makefile:559: .deps/flag.Plo: No such file or directory
Makefile:560: .deps/gcas.Plo: No such file or directory
Makefile:561: .deps/gexch.Plo: No such file or directory
Makefile:562: .deps/glfree.Plo: No such file or directory
Makefile:563: .deps/gload.Plo: No such file or directory
Makefile:564: .deps/gstore.Plo: No such file or directory
Makefile:565: .deps/init.Plo: No such file or directory
Makefile:566: .deps/lock.Plo: No such file or directory
Makefile:867: warning: overriding commands for target `all-multi'
Makefile:861: warning: ignoring old commands for target `all-multi'
make[4]: *** No rule to make target `.deps/lock.Plo'.  Stop.
make[3]: *** [all-target-libatomic] Error 2
make[2]: *** [all] Error 2
make[1]: *** [obj_gcc/.lc_built] Error 2
make: *** [all] Error 2
inferiorhumanorgans commented 2 years ago

Correction, with that patch applied it's possible to build a mipsel cross toolchain on OSX so long as you don't try to parallelize the build.

rofl0r commented 2 years ago

does the patch require gawk, or does it work with posix awk too ?

so long as you don't try to parallelize the build.

this seems to suggest the patch didn't declare its prerequisites/dependencies in the Makefile right, as the build without works fine with multiple processes.

inferiorhumanorgans commented 2 years ago

It works with BSD awk (unsure if it deviates from the POSIX spec) since that's what Apple ships by default. Honestly I think the more elegant solution would be to parameterize sed and just set SED=gsed on OSX and require GNU sed to be installed.

I don't know enough about MIPS to say, but is there anything that could be taken from the big endian targets instead?

inferiorhumanorgans commented 2 years ago

I should also add I'm not 100% sure that the parallel build was the issue, but I can't think of how my build env would've gotten corrupted otherwise. At this point though it should be easy enough to test on a non-Mac.