4 ms·
Clang accepts MSVC arguments and targets Windows if its binary is named clang-cl
- mschuster91 3y agoFor everyone else looking for the magic in this almost 7k lines monster, look at line 6610 [1]. [1] https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0df3e53340159c034f08533d/clang/lib/Driver/Driver.cpp#L6610 https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0d...
- olliej 3y agoAll of the argument parsing functions are insanely large, at least most of the actual individual argument handling stuff is autogenerated. [edit: a lot of the older code involves huge single functions, webkit, etc are similar and I suspect it’s true of most projects. It seems like a fairly standard code evolution pattern: a function is written, and keeps have logic added so it becomes bigger and bigger, until eventually someone adds something where refactoring makes enough sense that the functions are broken up. I wonder if someone has ever just done an analysis of commit history vs function size to see just how common this actually is. Something like “how old vs how recently modified vs function size” - I’m genuinely curious]
- ekeane 3y agoThe clang driver is particularly bad at this. There is a frequent 'just add one more thing here!' in every section of the driver. Additionally, it is large, somewhat complex, and not very exciting, so those refactors/simplifications don't happen nearly as often as other parts of the clang code base. The tablegen/macro-gen stuff DID get added at one point fortunately, but before that it was pretty rough as well.
- delta_p_delta_x 3y agoThanks! I'm positive I submitted the URL with the line number, but it's possible HN removed it for spam/remote execution filtering or something. This very interesting behaviour of clang actually comes from several other places as well. `IsClangCL()` that returns true if the driver mode is "cl": https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0df3e53340159c034f08533d/clang/lib/Driver/Driver.cpp#L6608 https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0d... `setDriverMode()` which sets the above: https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0df3e53340159c034f08533d/clang/lib/Driver/Driver.cpp#L1201 https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0d... This line that actually sets the triplet, the object format, etc: https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0df3e53340159c034f08533d/clang/lib/Driver/Driver.cpp#L1291 https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0d... Notice how `IsClangCL(getDriverMode(ProgName, ...))` is called in this line: https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0df3e53340159c034f08533d/clang/tools/driver/driver.cpp#L375 https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0d...
- dang 3y agoOk, I've restored the URL you submitted (https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0df3e53340159c034f08533d/clang/lib/Driver/Driver.cpp#L1291 https://github.com/llvm/llvm-project/blob/8ec28af8eaff5acd0d...).
- delta_p_delta_x 3y agoCheers!
- deleted 3y ago[deleted]