[cfe-dev] Failures with -DGCC_INSTALL_PREFIX

David Greene via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 11 12:36:59 PDT 2018


When clang is configured with -DGCC_INSTALL_PREFIX, the test
Driver/android-ndk-standalone fails to find the android gcc

I believe it may be due to this code in GCCInstallationDetector::init:

  StringRef GCCToolchainDir = getGCCToolchainDir(Args);
  if (GCCToolchainDir != "") {
    if (GCCToolchainDir.back() == '/')
      GCCToolchainDir = GCCToolchainDir.drop_back(); // remove the /

  } else {
    // If we have a SysRoot, try that first.
    if (!D.SysRoot.empty()) {
      AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);

    // Then look for gcc installed alongside clang.
    Prefixes.push_back(D.InstalledDir + "/..");

    // Next, look for prefix(es) that correspond to distribution-supplied gcc
    // installations.
    if (D.SysRoot.empty()) {
      // Typically /usr.
      AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);

getGCCToolchainDir return GCC_INSTALL_PREFIX if no toolchain option is

static llvm::StringRef getGCCToolchainDir(const ArgList &Args) {
  const Arg *A = Args.getLastArg(clang::driver::options::OPT_gcc_toolchain);
  if (A)
    return A->getValue();

Since GCC_INSTALL_PREFIX is non-empty, we fail to check the sysroot for
an installation.

What is the expected behavior in this case?  We want to run all of the
regression tests to make sure we don't break anything, but we also need
to set GCC_INSTALL_PREFIX.  Should GCCInstallationDetector::init be
changed to look at sysroot first?

In this case we're configuring for x86_64-unknown-linux-gnu.
Theoretically we could ignore GCC_INSTALL_PREFIX since the target
triples don't match, but I'm not sure if that's the right way to go.

Thanks for your help!


More information about the cfe-dev mailing list