dslm4515 / CMLFS

Clang-Built Musl Linux From Scratch
MIT License
105 stars 18 forks source link

LLVM12 :: cgnutools: Fail to build LLVM, cannot find libcurses #28

Closed dslm4515 closed 3 years ago

dslm4515 commented 3 years ago

On a musl host, LLVM fails to build due to liker not able to find -lcurses:

[  5%] Built target LLVMTableGenGlobalISel
make[2]: Entering directory '/mnt/cmlto/sources/llvm/build'
make[2]: Leaving directory '/mnt/cmlto/sources/llvm/build'
make[2]: Entering directory '/mnt/cmlto/sources/llvm/build'
[  5%] Linking CXX executable ../../bin/llvm-tblgen
/mnt/cmlto/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: error: cannot find -lcurses
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:336: error: undefined reference to 'setupterm'
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:354: error: undefined reference to 'tigetnum'
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:358: error: undefined reference to 'set_curterm'
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:359: error: undefined reference to 'del_curterm'
collect2: error: ld returned 1 exit status
make[2]: *** [utils/TableGen/CMakeFiles/llvm-tblgen.dir/build.make:192: bin/llvm-tblgen] Error 1
make[2]: Leaving directory '/mnt/cmlto/sources/llvm/build'
make[1]: *** [CMakeFiles/Makefile2:6927: utils/TableGen/CMakeFiles/llvm-tblgen.dir/all] Error 2
make[1]: Leaving directory '/mnt/cmlto/sources/llvm/build'
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/mnt/cmlto/sources/llvm/build'

Same issue on hosts running MLFS 9.0.0 and CMLFS 2.0.0 (with LTO)

First attempt was building cgnutools with LTO. Same error for LLVM. Then I tried again with out LTO: same error.

dslm4515 commented 3 years ago

Also caught another error:

[ 13%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o
/mnt/cmlto/sources/llvm/projects/libcxx/src/atomic.cpp:19:10: fatal error: linux/futex.h: No such file or directory
   19 | #include <linux/futex.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [projects/libcxx/src/CMakeFiles/cxx_static.dir/build.make:104: projects/libcxx/src/CMakeFiles/cxx_static.dir/atomic.cpp.o] Error 1
make[2]: Leaving directory '/mnt/cmlto/sources/llvm/build'

Not sure why suddenly build breaks on Musl. Was broken on Glibc hosts.

owl4ce commented 3 years ago

You need to build curses libraries, e.g GNU ncurses in every stage. I also experience that, as always.

owl4ce commented 3 years ago

Also caught another error:

[ 13%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o
/mnt/cmlto/sources/llvm/projects/libcxx/src/atomic.cpp:19:10: fatal error: linux/futex.h: No such file or directory
   19 | #include <linux/futex.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [projects/libcxx/src/CMakeFiles/cxx_static.dir/build.make:104: projects/libcxx/src/CMakeFiles/cxx_static.dir/atomic.cpp.o] Error 1
make[2]: Leaving directory '/mnt/cmlto/sources/llvm/build'

Not sure why suddenly build breaks on Musl. Was broken on Glibc hosts.

https://github.com/dslm4515/CMLFS/issues/11#issuecomment-869086030

dslm4515 commented 3 years ago

You need to build curses libraries, e.g GNU ncurses in every stage. I also experience that, as always.

I did try installing ncurses to cgnutools and same exact error. I would think setting the paths in /cgnutools/etc/ld-musl-x86_64.path would be enough.

Strange, when building under Ubuntu, I didn't have this issue

dslm4515 commented 3 years ago

Also caught another error:


[ 13%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o

/mnt/cmlto/sources/llvm/projects/libcxx/src/atomic.cpp:19:10: fatal error: linux/futex.h: No such file or directory

   19 | #include <linux/futex.h>

      |          ^~~~~~~~~~~~~~~

compilation terminated.

make[2]: *** [projects/libcxx/src/CMakeFiles/cxx_static.dir/build.make:104: projects/libcxx/src/CMakeFiles/cxx_static.dir/atomic.cpp.o] Error 1

make[2]: Leaving directory '/mnt/cmlto/sources/llvm/build'

Not sure why suddenly build breaks on Musl. Was broken on Glibc hosts.

https://github.com/dslm4515/CMLFS/issues/11#issuecomment-869086030

I tried that too and build still failed with missing libstd.h header...

dslm4515 commented 3 years ago

First I thought building cgnutools with LTO broke it but I did try again without LTO and same exact errors

dslm4515 commented 3 years ago

I rebuilt cgnutools. This time with no LTO for GCC static and GCC final. Now I can build file without --host=and --target... same error for missing libcurses. Installed libcurses to cgnutools as static library. Same error. Created a link:

ln -sv libncursesw.a /cgnutools/lib/libcurses.a

Now build proceeds!

dslm4515 commented 3 years ago

You need to build curses libraries, e.g GNU ncurses in every stage. I also experience that, as always.

I don;t know why, but in the past i never had to for cgnutools or cross-tools.... even under Ubuntu.

owl4ce commented 3 years ago

You need to build curses libraries, e.g GNU ncurses in every stage. I also experience that, as always.

I don;t know why, but in the past i never had to for cgnutools or cross-tools.... even under Ubuntu.

Hmm, I wonder too.