-
Notifications
You must be signed in to change notification settings - Fork 526
Closed
Description
On Debian Sid:
Output of cc --version
, which is different from gcc --version
:
cc (Debian 13.2.0-13) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Output of cc -v
, which is the same as gcc -v
:
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 13.2.0-13' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-13-13.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-13-13.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Debian 13.2.0-13)
So it's may be better to use -v
to check the compiler type?
correabuscar and g2p
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
NobodyXu commentedon Feb 21, 2024
That may be a good idea, however I'm not sure how it affects msvc and other compilers.
Be-ing commentedon Feb 21, 2024
I am also seeing this on GitHub Actions' Ubuntu 22.04 runner: https://github.com/KDAB/cxx-qt/actions/runs/7986404801/job/21806762461?pr=848#step:14:93
I cannot reproduce the warning locally on Fedora 39.
edg-l commentedon Feb 23, 2024
I'm seeing this too
willkill07 commentedon Feb 28, 2024
The standard way to check what version of compiler you have is to analyze the preprocessor definitions defined by the compiler for a trivial program. Simply relying on the output of
--version
is never used in any sane C++ build system.For instance, CMake looks at preprocessor definitions emitted by the compiler to detect compiler versions. It's usually pretty complex for the more difficult compilers, but this is more reasonable than relying on inspecting the output of
--version
. Note: you would have to check clang before gcc since clang pretends to be gcc.Clang:
GCC:
NobodyXu commentedon Feb 28, 2024
Thanks, I will work on a patch once I fixed the make problem.
NobodyXu commentedon Mar 2, 2024
Ok so for clang we can use:
on my macOS system, using the homebrew
clang
,clang -c a.c
gives me:Using the
gcc
imposted by appleclang
,gcc -c a.c
(cc -c a.c
gives the same output):Running real
gcc
,gcc-13 -c a.c
:Same output when using
clang++
,c++
,g++
, forg++-13
thoughg++-13 -c a.c
gives:NobodyXu commentedon Mar 2, 2024
For GCC:
For
gcc-13 -c b.c
:g++-13 -c b.c
:For clang, clang++ and clang-imposed cc, c++, gcc, g++ , they all give version
4.2.0
on my machine.NobodyXu commentedon Mar 2, 2024
TODO for myself: Also test zig-cc output
Would also be great to test different compilers in CI
NobodyXu commentedon Mar 6, 2024
Output of
zig cc
andzig c++
is basically the same asclang
andclang++
, only way of telling the difference is by runningzig cc --version
/zig cc -v
which gives:slightly different from
clang -v
dargueta commentedon Mar 6, 2024
I don't know Rust and have never seen this repo before, but it's affecting some third-party software I'm using that needs this library. (I am, however, very familiar with C/C++.)
Since we're invoking the compiler to begin with, perhaps we could do a little more work to get something more reliable? For example, we could compile and run a small program like this:
We could get detailed information from this, such as the width of
int
and so on. Since we completely control the output, we could construct JSON if we wanted to.I've found this list highly useful for compiler detection. There are other lists for detecting OS and host/target architecture.
NobodyXu commentedon Mar 6, 2024
Thanks @dargueta I would open a PR for this soon.
dargueta commentedon Mar 7, 2024
Don't copy and paste that, I just noticed a bug (missing return statements).
NobodyXu commentedon Mar 7, 2024
I will probably just use the macro-only and use
-E
to only run pre-processing.20 remaining items