-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is_gcc() does not detect gcc properly when called as cc #7218
Comments
So dont do that. Compiling something in order to detect the compiler is |
On the contrary; the crazy approach is scraping version output that is clearly fragile and intended for human, not machine, consumption. The most sane way to tell if you can pass certain options to a compiler (without requiring up-front user input) is to try to run it with those arguments and find out if it complains. Alternatively, exposing tunables to allow builders to indicate what compiler should be expected is a simple and reliable method to solve this problem. |
Only GCC's --version output is fragile. And as I said that is a bug in GCC. One I will workaround by switching detection to check for clang. And incidentally passing flags to a compiler to check if itcomplains is bonkers. That only tells you whether the compiler runs or not. It does not distiguish between different compilers having different effects from the same flag. Many compilers implement flags from each other and ignore them in the name of some misguided attempt at being drop in replacements for each other. |
Oh yeah and kitty's build system supports the CC env var just fine. So use that as your tuneable. |
You don't need to compile anything to get the compiler ID. Meson, for example, has a lot of very complex logic to detect many different compilers. It detects that Instead, it checks for "Free Software Foundation" in the output. Well, actually it uses that to detect "gcc_or_lcc". In case you care about the lcc compiler, it does then check for compiler defines via There are other interesting things going on there -- the file is 1400 lines long, and quite a bit of it is just for detecting C / C++ compilers specifically. It's not as simple a task as people might assume. (This is why eventually people trend towards migrating to dedicated build systems.) |
Describe the bug
is_gcc()
returns false when GCC is called ascc
To Reproduce
Steps to reproduce the behavior:
cc
togcc
CC=cc
cc: error: unrecognized command-line option '-mllvm'
Environment details
On Void Linux, the output of
cc --version
is:Related: #7154
I would recommend the approach suggested in that issue instead of parsing
--version
outputThe text was updated successfully, but these errors were encountered: