[PATCH] D140925: [CMake] Use Clang to infer the target triple

Tamás Szelei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 3 15:42:14 PST 2023


tamas added inline comments.


================
Comment at: runtimes/CMakeLists.txt:168
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  set(CXX_TARGET_TRIPLE ${CMAKE_CXX_COMPILER} --target=${LLVM_RUNTIME_TRIPLE} -print-target-triple)
+  execute_process(COMMAND ${CXX_TARGET_TRIPLE}
----------------
I think there is one downside to this: the `normalize` function will not, in fact, normalize alternative spellings for equivalent architectures (and likely other components, I haven't checked that):
```
+ clang -print-target-triple -target amd64-unknown-linux-musl
amd64-unknown-linux-musl
+ clang -print-target-triple -target x86_64-unknown-linux-musl
x86_64-unknown-linux-musl
```
So the issue where the distribution build can install runtimes in paths that won't be found by the driver still remains (https://github.com/llvm/llvm-project/issues/57781). One way to fix this could be adding a new switch that does a more opinionated normalization (for example, always picks `x86_64` in the above). Sort of a reverse for `Triple::parseArch` etc. where it always returns one certain spelling when there are multiple common alternatives. Alternatively, `normalize` could be changed to do this, but that might subtle breaking consequences for users which are hard to foresee.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140925



More information about the cfe-commits mailing list