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

Libc++.so.1 (llvmtools) requires libatomic.so.1 #12

Closed
dslm4515 opened this issue Jun 27, 2021 · 11 comments
Closed

Libc++.so.1 (llvmtools) requires libatomic.so.1 #12

dslm4515 opened this issue Jun 27, 2021 · 11 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@dslm4515
Copy link
Owner

llvmtools' libc++.so.1 from libcxx should NOT rely on libatomic.so.1, which is provided by GCC.

$ ldd /llvmtools/lib/libc++.so.1
        ldd (0x7fb67cb49000)
        libc.so => ldd (0x7fb67cb49000)
Error loading shared library libatomic.so.1: No such file or directory (needed by /llvmtools/lib/libc++.so.1)
        libunwind.so.1 => /llvmtools/lib/../lib/libunwind.so.1 (0x7fb67ca6b000)
        libc++abi.so.1 => /llvmtools/lib/../lib/libc++abi.so.1 (0x7fb67ca0f000)

This will require to build LLVM for llvmtools with a LD_LIBARARY_PATH hack

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

owl4ce commented Jun 27, 2021

hmmmmmm
http://llvmweekly.org/issue/336

image

@dslm4515
Copy link
Owner Author

Re-built llvmtools and made sure libcxx did not require libatomic.

now llvm/clang for llvmtools fails to build:

FAILED: include/llvm/IR/Attributes.inc 
cd /mnt/cmlfs/sources/llvm/build && /mnt/cmlfs/sources/llvm/build/bin/llvm-tblgen -gen-attrs -I /mnt/cmlfs/sources/llvm/include/llvm/IR -I /mnt/cmlfs/sources/llvm/build/include -I /mnt/cmlfs/sources/llvm/include /mnt/cmlfs/sources/llvm/include/llvm/IR/Attributes.td --write-if-changed -o include/llvm/IR/Attributes.inc -d include/llvm/IR/Attributes.inc.d
/bin/sh: /mnt/cmlfs/sources/llvm/build/bin/llvm-tblgen: No such file or directory
[220/3316] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackDocument.cpp.o
ninja: build stopped: subcommand failed.

@dslm4515
Copy link
Owner Author

hmmmmmm
http://llvmweekly.org/issue/336

image

Looks like for libcxx, I’ll have to set a flag to disable libatomic

@owl4ce
Copy link

owl4ce commented Jun 27, 2021

hmmmmmm
http://llvmweekly.org/issue/336
image

Looks like for libcxx, I’ll have to set a flag to disable libatomic

How?

@dslm4515
Copy link
Owner Author

Looks like I’ll have to patch libcxx/cmake/Modules/CheckLibcxxAtomic.cmake

@dslm4515
Copy link
Owner Author

Although it’s strange that after rebuilding llvmtools... llvmtools’ Libc++.so.1 no longer requires libatomic.

not sure if it matters that PATH=/cgnutools/bin:/llvmtools/bin:/bin:/usr/bin

@owl4ce
Copy link

owl4ce commented Jun 27, 2021

Commenting this will disable libatomic detection for Linux when configure libcxx (cmake).

check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)

projects/libcxx/cmake/config-ix.cmake

102 else()
103   check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
104   check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
105   check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
106   set(LIBCXX_HAS_SYSTEM_LIB NO)
107 #  check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
108 endif()

@owl4ce
Copy link

owl4ce commented Jun 27, 2021

I wonder how atomic detected when building libcxx

@dslm4515
Copy link
Owner Author

I probably will include a check for libunwind, libcxx, and libcxxabi to make sure there are no GCC dependencies. It’s annoying to finally build LLVM for llvmtools only to realize llvmtools has GCC dependencies.

@owl4ce
Copy link

owl4ce commented Jun 27, 2021

LLVM 12.0.0

Successful by using above trick!
While building libcxx in llvmtools (deletes matched PATTERN):

sed -i '/check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)/d' \
${LLVMSRC}/projects/libcxx/cmake/config-ix.cmake

Progress of building Clang/LLVM in llvmtools (I'm prefer GNU's Make btw):

[ 99%] Built target clangStaticAnalyzerFrontend
make[2]: Entering directory '/mnt/cmlfs/sources/llvm/build'
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make[2]: Entering directory '/mnt/cmlfs/sources/llvm/build'
[ 99%] Building C object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o
[ 99%] Building CXX object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/core_main.cpp.o
[100%] Linking CXX executable ../../../../bin/c-arcmt-test
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[100%] Built target c-arcmt-test
make[2]: Entering directory '/mnt/cmlfs/sources/llvm/build'
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make[2]: Entering directory '/mnt/cmlfs/sources/llvm/build'
[100%] Linking CXX static library ../../../../lib/libclangFrontendTool.a
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[100%] Built target clangFrontendTool
make[2]: Entering directory '/mnt/cmlfs/sources/llvm/build'
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make[2]: Entering directory '/mnt/cmlfs/sources/llvm/build'
[100%] Linking CXX static library ../../../../../lib/libclangDependencyScanning.a
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[100%] Built target clangDependencyScanning
[100%] Linking CXX executable ../../../../bin/c-index-test
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[100%] Built target c-index-test
make[1]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make: Leaving directory '/mnt/cmlfs/sources/llvm/build

@dslm4515

@dslm4515
Copy link
Owner Author

Commenting this will disable libatomic detection for Linux when configure libcxx (cmake).

check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)

projects/libcxx/cmake/config-ix.cmake

102 else()
103   check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
104   check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
105   check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
106   set(LIBCXX_HAS_SYSTEM_LIB NO)
107 #  check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
108 endif()

Closing issue as @owl4ce fixed issue

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
None yet
Development

No branches or pull requests

2 participants