Skip to content

Cannot find GCC libraries when using --sysroot and --gcc-install-dir #119560

@carlosgalvezp

Description

@carlosgalvezp

Hi,

I'm trying to use clang with a custom sysroot (containing glibc) as well as a custom GCC, as follows:

clang++ -fuse-ld=lld --sysroot=sysroot_x86_64_linux/ --gcc-install-dir=gcc_9_x86_64_linux/usr/lib/gcc/x86_64-pc-linux-gnu/9.4.0/ foo.cpp

Compilation works as expected, however the linker cannot find libstdc++:

ld.lld: error: unable to find library -lstdc++
ld.lld: error: unable to find library -lgcc_s
ld.lld: error: unable to find library -lgcc_s

My expectation is that --gcc-install-dir would allow clang to find these libraries, potentially even passing relevant -L paths to the linker (lld). Is my expectation wrong?

I take from this post from @MaskRay that using sysroot and gcc-install-dir should be working combination:

When the GCC installation is not contained in the sysroot, typically the user wants to fix the GCC version as well.
The new --gcc-install-dir= can be used instead.

I have also tried --gcc-toolchain and get the same problems.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions