Skip to content

[clang] clang doesn't load the triple as specified in binary prefix #154910

@CendioOssman

Description

@CendioOssman

The documentation states that if clang is called as <triple>-<driver> (e.g. x86_64-w64-mingw32-clang++), then clang will load both config files <triple>.cfg and <driver>.cfg. This is really convenient as it allows you to share configuration between drivers and targets.

However, this is not what actually happens. Under the hood, clang converts that <triple> to it's preferred "real triple". In the example above, that happens to be x86_64-w64-windows-gnu instead.

This is very confusing as it is not documented. It is also not very practical as the that triple then differs to what the rest of the system is using. It's also fragile as we then need to keep track of what clang considers a "real triple" for everything and keep an eye on if that changes.

Relevant code here:

// Otherwise, use the real triple as used by the driver.
llvm::Triple RealTriple =
computeTargetTriple(*this, TargetTriple, *CLOptions);
if (Triple.str().empty()) {
Triple = RealTriple;
assert(!Triple.str().empty());
}

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