3 ms·
Oh hi, thanks for replying! So funny enough, git was literally the first thing I tried, because it was easily the first thing I could think of where being able
by dataflow 5y ago
Oh hi, thanks for replying! So funny enough, git was literally the first thing I tried, because it was easily the first thing I could think of where being able to move later versions of it to earlier versions of Linux would've made my life easier. I'm not sure if anything else really falls in this category for me. But on your suggestion, I just tried Python 3.9, clang++, and g++, and didn't get errors for any of them. It's pretty nifty! Thanks for writing it.
- stabbles 5y agoclang++ also is just a symlink to clang, and clang uses the filename to change the language mode to c++. So why does that work?
- pseudalopex 5y agoclang just checks if the name starts with clang++ probably.
- stabbles 5y agoI checked this, the logic is as follows. The following suffixes are mapped to the equivalent driver flags: {"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/c22b110612600b0d0a8003f40b1cf6e37c4696c2/clang/lib/Driver/ToolChain.cpp#L135-L163 https://github.com/llvm/llvm-project/blob/c22b110612600b0d0a... and https://github.com/llvm/llvm-project/blob/c22b110612600b0d0a8003f40b1cf6e37c4696c2/clang/lib/Driver/ToolChain.cpp#L177-L201 https://github.com/llvm/llvm-project/blob/c22b110612600b0d0a... TIL: if you symlink ++ -> clang it works as a compiler in C++ mode.
- account42 5y ago> 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++`.