Skip to content

Clang Driver: Simplify Gentoo gcc-config detection #57570

@MaskRay

Description

@MaskRay

On Gentoo Linux, Clang Driver tries to pick the GCC installation as selected by gcc-config.
It reads $sysroot/etc/env.d/gcc/config-$CandidateTriple}, does some parsing, and selects the desired GCC installation.
See Generic_GCC::GCCInstallationDetector::ScanGentooGccConfig in https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Gnu.cpp

It tries to be permissive with --target= by detecting several aliases. I think these aliases detection should be removed.

    GentooTestTriples.push_back(TargetTriple.str());
    // Check rest of triples.
    GentooTestTriples.append(ExtraTripleAliases.begin(),
                             ExtraTripleAliases.end());
    GentooTestTriples.append(CandidateTripleAliases.begin(),
                             CandidateTripleAliases.end());

The code parses CURRENT=, LDPATH=, etc, which does not look very pretty. I am considering adding --gcc-install-dir= (https://reviews.llvm.org/D133329).

With the option,

  • make gcc-config provide a configuration file specifying --gcc-install-dir= (https://bugs.gentoo.org/868639)
  • configure sys-devel/clang with an appropriate CLANG_CONFIG_FILE_SYSTEM_DIR. Change clang to a shell script which invokes ${default_triple}-clang. This is because xxx-clang loads xxx.cfg while clang doesn't.
  • Remove Generic_GCC::GCCInstallationDetector::ScanGentooGccConfig

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