Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problems compiling LLVM toolchain
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
telestraw
n00b
n00b


Joined: 01 Mar 2024
Posts: 3

PostPosted: Sun Apr 28, 2024 4:27 pm    Post subject: Problems compiling LLVM toolchain Reply with quote

Greeting fellow Gentoo users,

I went through the first steps of the Gentoo installation, extracting the musl/llvm stage3 tarball, chrooting and syncing repos. The first step I went for was to bootstrap the latest version of the LLVM toolchain (17.0.6 -> 18.1.4). It went well at first (I compiled llvm,clang and lld) until I got an error compiling sys-libs/libcxxabi-18.1.4. However, I am able to re-compile the older and pre-packaged sys-libs/libcxxabi-17.0.6 successfully.

The error is the following:

Code:

CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/usr/lib/llvm/18/bin/x86_64-pc-linux-musl-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/var/tmp/portage/sys-libs/llvm-libunwind-18.1.4/work/runtimes_build-abi_x86_64.amd64/CMakeFiles/CMakeScratch/TryCompile-HdndgM'
   
    Run Build Command(s): /usr/bin/ninja -v cmTC_d3268
    [1/2] /usr/lib/llvm/18/bin/x86_64-pc-linux-musl-clang    -DNDEBUG -march=native -O3 -pipe -MD -MT CMakeFiles/cmTC_d3268.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_d3268.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_d3268.dir/testCCompiler.c.o -c /var/tmp/portage/sys-libs/llvm-libunwind-18.1.4/work/runtimes_build-abi_x86_64.amd64/CMakeFiles/CMakeScratch/TryCompile-HdndgM/testCCompiler.c
    [2/2] : && /usr/lib/llvm/18/bin/x86_64-pc-linux-musl-clang -march=native -O3 -pipe  CMakeFiles/cmTC_d3268.dir/testCCompiler.c.o -o cmTC_d3268   && :
    FAILED: cmTC_d3268
    : && /usr/lib/llvm/18/bin/x86_64-pc-linux-musl-clang -march=native -O3 -pipe  CMakeFiles/cmTC_d3268.dir/testCCompiler.c.o -o cmTC_d3268   && :
    ld.lld: error: cannot open crtbeginS.o: No such file or directory
    ld.lld: error: cannot open /usr/lib/llvm/18/bin/../../../../lib/clang/18/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory
    ld.lld: error: cannot open /usr/lib/llvm/18/bin/../../../../lib/clang/18/lib/linux/libclang_rt.builtins-x86_64.a: No such file or directory
    ld.lld: error: cannot open crtendS.o: No such file or directory
    x86_64-pc-linux-musl-clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:9 (project)
* Messages for package sys-libs/libcxxabi-18.1.4:

 * ERROR: sys-libs/libcxxabi-18.1.4::gentoo failed (configure phase):
 *   cmake failed
 *
 * Call stack:
 *     ebuild.sh, line  136:  Called src_configure
 *   environment, line 3817:  Called cmake-multilib_src_configure
 *   environment, line 1250:  Called multilib-minimal_src_configure
 *   environment, line 2752:  Called multilib_foreach_abi 'multilib-minimal_abi_src_configure'
 *   environment, line 3002:  Called multibuild_foreach_variant '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 2707:  Called _multibuild_run '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 2705:  Called _multilib_multibuild_wrapper 'multilib-minimal_abi_src_configure'
 *   environment, line  577:  Called multilib-minimal_abi_src_configure
 *   environment, line 2746:  Called multilib_src_configure
 *   environment, line 3239:  Called cmake_src_configure
 *   environment, line 1520:  Called die
 * The specific snippet of code:
 *       "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";
 *
 * If you need support, post the output of `emerge --info '=sys-libs/libcxxabi-18.1.4::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-libs/libcxxabi-18.1.4::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sys-libs/libcxxabi-18.1.4/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-libs/libcxxabi-18.1.4/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-libs/libcxxabi-18.1.4/work/runtimes_build-abi_x86_64.amd64'
 * S: '/var/tmp/portage/sys-libs/libcxxabi-18.1.4/work/runtimes'

 * Messages for package sys-libs/libcxx-18.1.4:

 * emerge --keep-going: sys-libs/libcxx-18.1.4 dropped because it requires
 * ~sys-libs/libcxxabi-18.1.4[static-libs,abi_x86_64(-)]


Here are the USE flags of the related packages that were compiled successfully:

Code:

sys-devel/llvm-18.1.4:18/18.1::gentoo  USE="libedit libffi ncurses zstd -binutils-plugin -debug -debuginfod -doc -exegesis -test -verify-sig -xml -z3"
sys-devel/clang-18.1.4:18/18.1::gentoo  USE="extra (pie) static-analyzer -debug -doc (-ieee-long-double) -test -verify-sig -xml"
sys-devel/lld-18.1.4:18/18.1::gentoo  USE="zstd -debug -test -verify-sig"
sys-devel/llvm-toolchain-symlinks-18:18::gentoo  USE="native-symlinks -multilib-symlinks"
sys-devel/clang-toolchain-symlinks-18:18::gentoo  USE="native-symlinks -gcc-symlinks -multilib-symlinks"
sys-devel/lld-toolchain-symlinks-18:18::gentoo  USE="native-symlinks -multilib-symlinks"


make.conf file: https://codeberg.org/doppl3r/configs/src/branch/main/make.conf

I have refered to the following sources:
https://wiki.gentoo.org/wiki/Clang
https://forums.gentoo.org/viewtopic-t-1084292-start-0.html
https://blogs.gentoo.org/mgorny/2022/10/07/clang-in-gentoo-now-sets-default-runtimes-via-config-file/
https://www.reddit.com/r/Gentoo/comments/snswg7/llvm_compilation_struggles/?rdt=59465 (similar error here https://www.reddit.com/r/Gentoo/comments/snswg7/comment/hw5jzm0/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)

Apologies if I missed anything out. All help is greatly appreciated and I won't hesitate to submit extra details and logs.

Thanks in advace!

Note: This is my latest attempt of various others to install the musl/llvm profile successfully. I come from a 'default' gcc/glibc installation.
Back to top
View user's profile Send private message
myga
Tux's lil' helper
Tux's lil' helper


Joined: 12 Jun 2023
Posts: 110

PostPosted: Thu May 02, 2024 4:04 am    Post subject: Reply with quote

Your 'make.conf' indicates that you are building that package(s) using 'clang' but the error 'ld.lld: error: cannot open crtbeginS.o: No such file or directory' tells me that the file 'crtbeginS.o' is provided by sys-devel/gcc. Did you install GCC? Also, did you setup 'GCC fallback environment' according to the wiki:

Quote:
"Create a configuration file with a set of environment variables using Portage's built in /etc/portage/env directory. This will override any defaults for any packages that fail to compile with clang."

_________________
[Never break the law to save people. Nope, there aint no heroes here. Unless you are 'Satoshi Nakamoto', that's a true anonymous.]
Back to top
View user's profile Send private message
telestraw
n00b
n00b


Joined: 01 Mar 2024
Posts: 3

PostPosted: Thu May 02, 2024 1:58 pm    Post subject: Reply with quote

Hey myga. Thanks for replying.

No, GCC is not provided by the musl/llvm stage3 tarball afaik. I am also sure that I haven't installed GCC yet since I started bootstrapping the LLVM toolchain first thing as stated. Anyway I am redoing the install and I'm not going to give up.

This time I'm experimenting with the '-stdlib' argument for CXXFLAGS. I am going compile GCC first and will use GNU's libstdc++ instead of LLVM's libc++/libcxx (-stdlib=libstdc++) along with the pre-packaged clang-17.0.6 compiler to compile the LLVM toolchain. It's weird to see a GCC component being used to compile sys-libs/libcxxabi-18.1.4...

I will publish my results ASAP. It's a nightmare doing this on a laptop :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum