https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115122
Bug ID: 115122
Summary: Incorrect detection of C99 support when
cross-compiling
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: tomas.kalibera at gmail dot com
Target Milestone: ---
Created attachment 58219
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58219&action=edit
docker file that reproduces the problem (libstdc++ doesn't use C99 complex
functions which are available)
When cross-compiling a native toolchain, configuration of libstdc++ incorrectly
concludes that there is no C99 support (which then triggers Bug 115117).
I've ran into this when building a native toolchain (to run on Windows, produce
code for Windows) on a Linux machine. Configure in libstdc++ builds a test
program as follows:
x86_64-w64-mingw32-c++ -L/opt/gcc-mingw/native/x86_64-w64-mingw32/lib
-L/opt/gcc-mingw/native/mingw/lib -isystem
/opt/gcc-mingw/native/x86_64-w64-mingw32/include -isystem
/opt/gcc-mingw/native/mingw/include -o conftest.exe -g -O2 -std=c++11
-fno-exceptions conftest.cpp -lm >&5
so, it tries to build the configure test using the cross-compiler, including
the "-std=c++11" argument but not including "-nostdinc++". That way, C99
functions would appear not available, and the test would fail.
I've attached a docker file that reproduces the problem. It ends by showing
that "c++config.h" ends up with undefined _GLIBCXX11_USE_C99_COMPLEX and also
copies the corresponding lines from the config.log of libstdc++.
The docker file also builds a cross-compiler (to cross-compile the native
compiler), so one can see that in the cross-compilation, the configure tests
run as
/build/gcc/build-x86_64/./gcc/xgcc -shared-libgcc
-B/build/gcc/build-x86_64/./gcc -nostdinc++
-L/build/gcc/build-x86_64/x86_64-w64-mingw32/libstdc++-v3/src
-L/build/gcc/build-x86_64/x86_64-w64-mingw32/libstdc++-v3/src/.libs
-L/build/gcc/build-x86_64/x86_64-w64-mingw32/libstdc++-v3/libsupc++/.libs
-L/opt/gcc-mingw/x86_64-w64-mingw32/lib -L/opt/gcc-mingw/mingw/lib -isystem
/opt/gcc-mingw/x86_64-w64-mingw32/include -isystem /opt/gcc-mingw/mingw/include
-B/opt/gcc-mingw/x86_64-w64-mingw32/bin/
-B/opt/gcc-mingw/x86_64-w64-mingw32/lib/ -isystem
/opt/gcc-mingw/x86_64-w64-mingw32/include -isystem
/opt/gcc-mingw/x86_64-w64-mingw32/sys-include -o conftest.exe -g -O2
-std=c++11 -fno-exceptions conftest.cpp -lm >&5
and succeeds. Note, it uses "-nostdinc++".