“If you ever try to relocate a binary that doesn't work with the default configuration, the --detect option is a good first thing to try.”
From the README file…
From the README file…
So why does that work?
{"clang", nullptr}
{"clang++", "--driver-mode=g++"}
{"clang-c++", "--driver-mode=g++"}
{"clang-cc", nullptr}
{"clang-cpp", "--driver-mode=cpp"}
{"clang-g++", "--driver-mode=g++"}
{"clang-gcc", nullptr}
{"clang-cl", "--driver-mode=cl"}
{"cc", nullptr}
{"cpp", "--driver-mode=cpp"}
{"cl", "--driver-mode=cl"}
{"++", "--driver-mode=g++"}
{"flang", "--driver-mode=flang"}
`clang++-x` matches none of these. Then the same logic is applied to the name with any of "0123456789." trimmed from the right. Still no match. Then the trailing `-component` is stripped, and `clang++` matches.It works by chance...
See https://github.com/llvm/llvm-project/blob/c22b110612600b0d0a... and https://github.com/llvm/llvm-project/blob/c22b110612600b0d0a...
TIL: if you symlink ++ -> clang it works as a compiler in C++ mode.
Note that this is only about the compiler driver mode, i.e. the default libraries, search paths, include directories, etc. The source language is determined by the file extension unless specified with e.g. `-x c++`.