Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgnutools: 5-GCC-final broken libstdc++.so #8

Closed
owl4ce opened this issue Jun 10, 2021 · 43 comments
Closed

cgnutools: 5-GCC-final broken libstdc++.so #8

owl4ce opened this issue Jun 10, 2021 · 43 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@owl4ce
Copy link

owl4ce commented Jun 10, 2021

Hi, nice repository. I'm not sure what the problem is (the title). However, libstdc++ becomes like this:

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so
	ldd (0x7f16150ee000)
	libc.so => ldd (0x7f16150ee000)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so)
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetRegionStart: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetTextRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_RaiseException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume_or_Rethrow: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetIPInfo: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetDataRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetGR: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_DeleteException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: __popcountdi2: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetIP: symbol not found

So it can't build on step 8-clang

$ LD_LIBRARY_PATH=/cgnutools/lib:/cgnutools/${CMLFS_TARGET}/lib:/usr/lib:/lib ninja -C build
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: Relink `/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1' with `/lib64/libc.so.6' for IFUNC symbol `memset'
Segmentation fault

Though, libgcc_s.so.1 is fine.

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1
	ldd (0x7f04a7038000)
	libc.so => ldd (0x7f04a7038000)
@owl4ce
Copy link
Author

owl4ce commented Jun 10, 2021

When I use LD_PRELOAD:

$ LD_PRELOAD=/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1 LD_LIBRARY_PATH=/cgnutools/lib:/cgnutools/${CMLFS_TARGET}/lib:/usr/lib:/lib ninja -C build
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: Entering directory `build'
[11/3759] Linking CXX static library lib/libLLVMDemangle.a
FAILED: lib/libLLVMDemangle.a 
: && /usr/bin/cmake -E rm -f lib/libLLVMDemangle.a && /cgnutools/bin/x86_64-cmlfs-linux-musl-ar Dqc lib/libLLVMDemangle.a  lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangle.cpp.o lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangleNodes.cpp.o && /cgnutools/bin/x86_64-cmlfs-linux-musl-ranlib -D lib/libLLVMDemangle.a && :
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libjsoncpp.so.24)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libjsoncpp.so.24)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libjsoncpp.so.24)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libjsoncpp.so.24)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libjsoncpp.so.24)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libjsoncpp.so.24)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libicuuc.so.69)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libicuuc.so.69)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libicuuc.so.69)
/usr/bin/cmake: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by /usr/lib64/libicuuc.so.69)
/usr/bin/cmake: Relink `/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1' with `/lib64/libc.so.6' for IFUNC symbol `memset'
[16/3759] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o
ninja: build stopped: subcommand failed

@dslm4515
Copy link
Owner

to be honest, LLVM can be a pain to configure/build in this repo.

I found patchelf very helpful to fix library dependency issues as a quick fix

@dslm4515
Copy link
Owner

Instead of ldd, try readelf -d to see where that library is expecting it's dependancies

@dslm4515 dslm4515 self-assigned this Jun 10, 2021
@dslm4515 dslm4515 added the invalid This doesn't seem right label Jun 10, 2021
@dslm4515
Copy link
Owner

Using LD_PRELOAD doesn't work too well with ninja or make

@owl4ce
Copy link
Author

owl4ce commented Jun 11, 2021

Now libstdc++ solved by using patchelf.

$ patchelf --replace-needed libgcc_s.so.1 /cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1 libstdc++.so.6.0.28
$ readelf -d /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so
Dynamic section at offset 0x1ef328 contains 27 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x0000000000000001 (NEEDED)             Shared library: [/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1]
 0x000000000000000e (SONAME)             Library soname: [libstdc++.so.6]
 0x000000000000000c (INIT)               0xb4000
 0x000000000000000d (FINI)               0x198fe1
 0x0000000000000019 (INIT_ARRAY)         0x1e7010
 0x000000000000001b (INIT_ARRAYSZ)       80 (bytes)
 0x0000000000000004 (HASH)               0x24d8f0
 0x000000006ffffef5 (GNU_HASH)           0x8c90
 0x0000000000000005 (STRTAB)             0x257000
 0x0000000000000006 (SYMTAB)             0x13400
 0x000000000000000a (STRSZ)              350500 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000003 (PLTGOT)             0x1f0518
 0x0000000000000002 (PLTRELSZ)           29616 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0xac998
 0x0000000000000007 (RELA)               0x93db0
 0x0000000000000008 (RELASZ)             101352 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x0000000000000018 (BIND_NOW)           
 0x000000006ffffffb (FLAGS_1)            Flags: NOW
 0x000000006ffffffe (VERNEED)            0x93d60
 0x000000006fffffff (VERNEEDNUM)         1
 0x000000006ffffff0 (VERSYM)             0x90868
 0x000000006ffffff9 (RELACOUNT)          661
 0x0000000000000000 (NULL)               0x0

However, ninja still expect Host's libc (glibc)

ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: Relink `/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1' with `/lib64/libc.so.6' for IFUNC symbol `memset'
Segmentation fault

@dslm4515
Copy link
Owner

dslm4515 commented Jun 11, 2021

if your host is musl-based, check /etc/ld-musl-x86_64.path and make sure GCC libraries are listed. If glibc host, check /etc/ld.so.conf.

That issue of ninja looking for GCC libraries looks familiar. Hopefully I remembered correctly.

@dslm4515
Copy link
Owner

If you just patched with patchelf you must restart your build... Either ninja clean or if building in a separate build directory, empty it. Then re-run the cmake command then run ninja once more

@owl4ce
Copy link
Author

owl4ce commented Jun 11, 2021

If you just patched with patchelf you must restart your build... Either ninja clean or if building in a separate build directory, empty it. Then re-run the cmake command then run ninja once more

Its already clean

@dslm4515
Copy link
Owner

dslm4515 commented Jun 11, 2021

To be honest, I've been using a musl-libc system for 4 years... I haven't tested this repo on a Glibc system.

I don't have any glibc systems running :P

@owl4ce
Copy link
Author

owl4ce commented Jun 11, 2021

Seems like, I must bootstrap ninja or samurai with musl-libc firstly.

@owl4ce
Copy link
Author

owl4ce commented Jun 11, 2021

Nah, finally I got this. Did you know how to solve? ltinfo seems like ncurses

ninja: entering directory 'build'
[1/2810] Linking CXX executable bin/split-file
[2/2810] Linking CXX executable bin/llvm-undname
[3/2810] Linking CXX executable bin/llvm-cxxfilt
[4/2810] Linking CXX executable bin/llvm-config
[5/2810] Linking CXX executable bin/yaml-bench
[6/2810] Linking CXX executable bin/not
ninja: job failed: : && /cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -g -g1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Os -DNDEBUG -Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1    -Wl,-rpath-link,/media/Heiwa/sources/llvm/build/./lib  -Wl,-O3 -Wl,--gc-sections tools/llvm-cxxfilt/CMakeFiles/llvm-cxxfilt.dir/llvm-cxxfilt.cpp.o -o bin/llvm-cxxfilt  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMDemangle.a  lib/libLLVMSupport.a  lib/libLLVMDemangle.a  -lrt  -ldl  -lm  -ltinfo && :
/media/Heiwa/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.2.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
ninja: job failed: : && /cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -g -g1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Os -DNDEBUG -Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1    -Wl,-rpath-link,/media/Heiwa/sources/llvm/build/./lib  -Wl,-O3 -Wl,--gc-sections utils/not/CMakeFiles/not.dir/not.cpp.o -o bin/not  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  -lrt  -ldl  -lm  -ltinfo  lib/libLLVMDemangle.a && :
/media/Heiwa/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.2.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
ninja: job failed: : && /cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -g -g1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Os -DNDEBUG -Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1    -Wl,-rpath-link,/media/Heiwa/sources/llvm/build/./lib  -Wl,-O3 -Wl,--gc-sections tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o -o bin/llvm-config  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  -lrt  -ldl  -lm  -ltinfo  lib/libLLVMDemangle.a && :
/media/Heiwa/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.2.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
ninja: job failed: : && /cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -g -g1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Os -DNDEBUG -Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1    -Wl,-rpath-link,/media/Heiwa/sources/llvm/build/./lib  -Wl,-O3 -Wl,--gc-sections tools/llvm-undname/CMakeFiles/llvm-undname.dir/llvm-undname.cpp.o -o bin/llvm-undname  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMDemangle.a  lib/libLLVMSupport.a  lib/libLLVMDemangle.a  -lrt  -ldl  -lm  -ltinfo && :
/media/Heiwa/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.2.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
ninja: job failed: : && /cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -g -g1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Os -DNDEBUG -Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1    -Wl,-rpath-link,/media/Heiwa/sources/llvm/build/./lib  -Wl,-O3 -Wl,--gc-sections utils/yaml-bench/CMakeFiles/yaml-bench.dir/YAMLBench.cpp.o -o bin/yaml-bench  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  -lrt  -ldl  -lm  -ltinfo  lib/libLLVMDemangle.a && :
/media/Heiwa/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.2.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
ninja: job failed: : && /cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -g -g1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Os -DNDEBUG -Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1    -Wl,-rpath-link,/media/Heiwa/sources/llvm/build/./lib  -Wl,-O3 -Wl,--gc-sections tools/split-file/CMakeFiles/split-file.dir/split-file.cpp.o -o bin/split-file  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  -lrt  -ldl  -lm  -ltinfo  lib/libLLVMDemangle.a && :
/media/Heiwa/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.2.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
ninja: subcommands failed

@dslm4515
Copy link
Owner

Yes, i think i had a similar issue in getting vim to compile for the tool chain. Set these flags:

export LDFLAGS="-L/cgnutools/lib" 
export CPPFLAGS="-I/cgnutools/include"

@owl4ce
Copy link
Author

owl4ce commented Jun 12, 2021

Yes, i think i had a similar issue in getting vim to compile for the tool chain. Set these flags:

export LDFLAGS="-L/cgnutools/lib" 
export CPPFLAGS="-I/cgnutools/include"

still, suspected -ltinfo

collect2: error: ld returned 1 exit status
ninja: subcommands failed

Sorry, I will ignore this issue first. Move to another goals.

@andzai1995
Copy link

andzai1995 commented Jun 13, 2021

To be honest, I've been using a musl-libc system for 4 years... I haven't tested this repo on a Glibc system.

I don't have any glibc systems running :P

On Glibc system you have to build mlfs, then in mlfs chroot build and install libuv and cmake, then build entire cmlfs system. It is needed because cmake links objects with that libc, against which it has been build. When I tried to build CMLFS cgnutools on Ubuntu 21.04, I have got a lot of stuff that cmake can't find libstdc++. Previously I have built mlfs platform on my usb stick, so I needed to add libuv and cmake. And then everything moves like planned.

@andzai1995
Copy link

andzai1995 commented Jun 13, 2021

To be honest, I've been using a musl-libc system for 4 years... I haven't tested this repo on a Glibc system.
I don't have any glibc systems running :P

On Glibc system you have to build mlfs, then in mlfs chroot build and install libuv and cmake, then build entire cmlfs system. It is needed because cmake links objects with that libc, against which it has been build. When I tried to build CMLFS cgnutools on Ubuntu 21.04, I have got a lot of stuff that cmake can't find libstdc++. Previously I have built mlfs platform on my usb stick, so I needed to add libuv and cmake. And then everything moves like planned.

If this issue occurs, try to change build system from Ninja to Unix Makefiles. Then it should work, if it fails with ninja.

@andzai1995
Copy link

Hi, nice repository. I'm not sure what the problem is (the title). However, libstdc++ becomes like this:

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so
	ldd (0x7f16150ee000)
	libc.so => ldd (0x7f16150ee000)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so)
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetRegionStart: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetTextRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_RaiseException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume_or_Rethrow: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetIPInfo: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetDataRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetGR: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_DeleteException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: __popcountdi2: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetIP: symbol not found

So it can't build on step 8-clang

$ LD_LIBRARY_PATH=/cgnutools/lib:/cgnutools/${CMLFS_TARGET}/lib:/usr/lib:/lib ninja -C build
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: Relink `/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1' with `/lib64/libc.so.6' for IFUNC symbol `memset'
Segmentation fault

Though, libgcc_s.so.1 is fine.

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1
	ldd (0x7f04a7038000)
	libc.so => ldd (0x7f04a7038000)

Try to build MLFS environment, then in it begin to build CMLFS. And change Ninja to Unix Makefiles for some reason.

@owl4ce
Copy link
Author

owl4ce commented Jun 13, 2021

Hi, nice repository. I'm not sure what the problem is (the title). However, libstdc++ becomes like this:

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so
	ldd (0x7f16150ee000)
	libc.so => ldd (0x7f16150ee000)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so)
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetRegionStart: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetTextRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_RaiseException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume_or_Rethrow: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetIPInfo: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetDataRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetGR: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_DeleteException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: __popcountdi2: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetIP: symbol not found

So it can't build on step 8-clang

$ LD_LIBRARY_PATH=/cgnutools/lib:/cgnutools/${CMLFS_TARGET}/lib:/usr/lib:/lib ninja -C build
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: Relink `/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1' with `/lib64/libc.so.6' for IFUNC symbol `memset'
Segmentation fault

Though, libgcc_s.so.1 is fine.

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1
	ldd (0x7f04a7038000)
	libc.so => ldd (0x7f04a7038000)

Try to build MLFS environment, then in it begin to build CMLFS. And change Ninja to Unix Makefiles for some reason.

My issue yesterday is in cross ld still expect host's ncurses libraries.

@dslm4515
Copy link
Owner

I'll setup a host machine with a basic Ubuntu install and attempt a build.

I had a similar issue with an early build of Musl-LFS

@andzai1995
Copy link

Try also remove git in the first host system and/or in the first chroot mlfs system due to the fact of using git for versioning, may be build of temporary mlfs environtment will not be needed or will be easier. And this "output" with libstdc++ will not appear.

@dslm4515
Copy link
Owner

dslm4515 commented Jun 15, 2021

Got my Ubuntu 20.04 system up and running. To make sure host has a toolchain:

sudo apt install build-essentials flex bison cmake

I was able to build up to clang (8-clang) of cgnutools. Current error:

[ 24%] Building arm_neon.h...                                                                                                                   
Error loading shared library libstdc++.so.6: No such file or directory (needed by ../../../../bin/clang-tblgen)                                 Error loading shared library libgcc_s.so.1: No such file or directory (needed by ../../../../bin/clang-tblgen)

I did run the cmake command to generate Makefiles instead of ninja files.

So looks like clang-tblgen was built with dependencies in $LLVMSRC/build/lib :

cmlfs@amd64550:/mnt/cmlfs/sources/llvm$ readelf -d  build/bin/clang-tblgen 

Dynamic section at offset 0xce8f0 contains 28 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/../lib]

@dslm4515
Copy link
Owner

dslm4515 commented Jun 15, 2021

Fixed my issue for clang-tblgen with commits ce9c56f + 1d294be
So far building past 35% of clang ( 1-cgnutools/8-clang ) Build complete for clang of cgnutools!

Edit: I did use the LLVM source tree which had to be populated with sources of clang, compiler-rt, libunwind, libcxx, libcxx-abi, and lld... Not the source tarball that includes all of the projects and tools of the LLVM project.

@dslm4515
Copy link
Owner

Try also remove git in the first host system and/or in the first chroot mlfs system due to the fact of using git for versioning, may be build of temporary mlfs environtment will not be needed or will be easier. And this "output" with libstdc++ will not appear.

Yes, I was able to build cgnutools under Ubuntu without git installed. No mlfs chroot/toolchain required.

Following commits make cgnutools build successfully on a glibc host:

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

I got same problem with this
#8 (comment)

Thats ld from cross-binutils

@dslm4515
Copy link
Owner

Check /cgnutools/etc/ld-musl-x86_64.path

# Configure the dynamic linker
cat > /cgnutools/etc/ld-musl-x86_64.path << "EOF"
/cgnutools/lib
/cgnutools/x86_64-cmlfs-linux-musl/lib
/usr/lib
/lib
EOF

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

Check /cgnutools/etc/ld-musl-x86_64.path

# Configure the dynamic linker
cat > /cgnutools/etc/ld-musl-x86_64.path << "EOF"
/cgnutools/lib
/cgnutools/x86_64-cmlfs-linux-musl/lib
/usr/lib
/lib
EOF

Yeah, its same but still "cannot to find -ltinfo"

@dslm4515
Copy link
Owner

If i understand correctly, you are stuck at 5-GCC-final of 1-cgnutools with GCC failing to build due to cannot find -ltinfo by ld (GCC) ?

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

If i understand correctly, you are stuck at 5-GCC-final of 1-cgnutools with GCC failing to build due to cannot find -ltinfo by ld (GCC) ?

No, I stuck at 8-clang at [ 21%] Linking CXX executable ../../bin/llvm-config, caused by cannot find -ltinfo.

/cgnutools/x86_64-cmlfs-linux-musl/bin/ld is from binutils, and binutils still linked with host's libc (in this case, i use glibc).

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

I think to recompile binutils with current final GCC after install 5-GCC-final from 1-cgnutools ?

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

I think to recompile binutils with current final GCC after install 5-GCC-final from 1-cgnutools ?

oh maybe not, i'm confused. gcc final also still expect host's glibc. i wonder this problem is in cross libc or needs to separate stage to build cross gcc-toolchain (/cross-tools) and final temporary gcc-toolchain (/tools) like in mlfs, then build llvmtools

 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
 0x000000000000001d (RUNPATH)            Library runpath: [/cgnutools/lib]

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

I wonder how cross-binutils and host's binutils are differents, host's ld can find -ltinfo and cross ld not

@dslm4515
Copy link
Owner

With my first successful build, i did use cross-tools from MLFS to build cgnutools then used cgnutools to build llvmtools. I figured to combine cross-tools and cgnutools to avoid having 3 different tool chains

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

With my first successful build, i did use cross-tools from MLFS to build cgnutools then used cgnutools to build llvmtools. I figured to combine cross-tools and cgnutools to avoid having 3 different tool chains

Yeah, this current method in CMLFS is good idea but i have that problems. I have not intended to re-start the cross-tools from MLFS.

@dslm4515
Copy link
Owner

I'm currently stuck at 04-libcxx of 2-llvmtools, using LLV12 source (LLVM12 branch)... seems like header conflict.

I believe i used the same build instructions from master (LLVM11.0.0) for the LLVM12 branch.
I might scratch that LLVM12 build and retry LLVM11 (master)

@dslm4515 dslm4515 reopened this Jun 25, 2021
@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

I see, I need install ncurses to get libtinfo.so in /cgnutools/lib/

@dslm4515
Copy link
Owner

I see, I need install ncurses to get libtinfo.so in 1-cgnutools

For the host or to add to cgnutools?

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

I see, I need install ncurses to get libtinfo.so in 1-cgnutools

For the host or to add to cgnutools?

add to cgnutools

@owl4ce
Copy link
Author

owl4ce commented Jun 25, 2021

Yeah, worked now

@dslm4515
Copy link
Owner

Yeah, worked now

In that case, sounds like your host does not have the ncurses development libraries installed. So you can either install it for your host OR build it and install it to cgnutools.

@owl4ce
Copy link
Author

owl4ce commented Jun 26, 2021

Yeah, worked now

In that case, sounds like your host does not have the ncurses development libraries installed. So you can either install it for your host OR build it and install it to cgnutools.

My host has it, I use gentoo. As metioned in #8 (comment)

@owl4ce
Copy link
Author

owl4ce commented Jun 26, 2021

Try to use netbsd-curses 🤣

https://reviews.llvm.org/D54650

@owl4ce
Copy link
Author

owl4ce commented Jun 27, 2021

Lol, I need to install curses library too in llvmtools

@dslm4515
Copy link
Owner

I might consider netbsd-curses... just like how I use gettext-tiny instead of GNU's gettext.

@owl4ce
Copy link
Author

owl4ce commented Jun 27, 2021

and may be OpenBSD's m4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
Status: Done
Development

No branches or pull requests

3 participants