[PATCH] D80300: [Driver] Add DEFAULT_DYLD_PREFIX and DEFAULT_RPATH to complement DEFAULT_SYSROOT

Nemanja Ivanovic via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 04:18:06 PDT 2020


nemanjai added a comment.

According to https://clang.llvm.org/docs/CrossCompilation.html (under `Toolchain Options` option 2) it is quite likely that a user that desires to cross-compile will have the necessary toolchain installed into a directory that will not require the use of `--sysroot`.

So I think that letting `--target` override the default `--sysroot/--dyld-prefix/--rpath` is reasonable. What I am suggesting is that if `--target` is specified on the command line, it clears any default setting of these three options (i.e. clears them unless they were explicitly specified on the command line).

Namely, something along the lines of:

  diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
  index 5c726b2..9a85394 100644
  --- a/clang/lib/Driver/Driver.cpp
  +++ b/clang/lib/Driver/Driver.cpp
  @@ -1073,8 +1073,13 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
       T.setObjectFormat(llvm::Triple::COFF);
       TargetTriple = T.str();
     }
  -  if (const Arg *A = Args.getLastArg(options::OPT_target))
  +  if (const Arg *A = Args.getLastArg(options::OPT_target)) {
       TargetTriple = A->getValue();
  +    if (!Args.getLastArg(options::OPT__sysroot_EQ))
  +      SysRoot = "";
  +    if (!Args.getLastArg(options::OPT__dyld_prefix_EQ))
  +      DyldPrefix = "";
  +  }

And something similar for `DEFAULT_RPATH`.

Would something like this be satisfactory for everyone here? Or do others think this is the "worst of both worlds"? :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80300/new/

https://reviews.llvm.org/D80300





More information about the cfe-commits mailing list