[PATCH] D100054: Handle flags such as -m32 when computing the prefix for programs/runtime libs

Petr Hosek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 9 10:54:47 PDT 2021


phosek added inline comments.


================
Comment at: clang/lib/Driver/Driver.cpp:1176-1210
+  // If command line flags such as -m32, etc. changed parts of the triple that
+  // are not just changes to normalization, we also need to update the raw
+  // triple string that is used to find tools. This ensures e.g. that clang -m32
+  // searches for i386-*-ld instead of x86_64-*-ld when linking (and also uses
+  // the triple-prefixed library paths).
+  EffectiveTargetTriple =
+      computeTargetTriple(*this, RawTargetTriple, *UArgs, "");
----------------
I think this should be handled by each toolchain. For example `Linux` toolchain already [has getMultiarchTriple](https://github.com/llvm/llvm-project/blob/16fe741c69429235210c03c46420f8fa6aece4a1/clang/lib/Driver/ToolChains/Linux.cpp#L40) which takes into account target handling on various existing platforms like Debian.

What I've been thinking of doing is to move that method to the `ToolChain` class as virtual so it could be overriden and customized by each toolchain, and then use it in [getRuntimePath](https://github.com/llvm/llvm-project/blob/16fe741c69429235210c03c46420f8fa6aece4a1/clang/lib/Driver/ToolChain.cpp#L485).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100054



More information about the cfe-commits mailing list