[RFC] Fix loose behaviors of Clang --target= (original) (raw)

February 17, 2022, 6:14am 2

I agree with the general idea of this proposal. The way we process the targets and search for gcc installs is really complicated and leads to confusing errors. I think the fundamental issue we have now is that the target is used for 2 separate purposes. The first is to instruct clang how to generate code, and the second is to select the runtime libraries (i.e. gcc install) for the compiler to use.

Do you think it would make sense to introduce a new flag, like --gcc-target or --runtime-target, that would be used only for searching the system for runtime libraries? So for the debian example, you could have
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu and -DLLVM_DEFAULT_RUNTIME_LIB_TARGET_TRIPLE=x86_64-linux-gnu This would keep things working as they are now while still allowing us to remove the hard-coded target lists that the driver uses to search for runtime libraries.

I think if we can decouple the target from the library searching that will make it much easier to make progress on this.