GCC includes ordering issue? g++: error: 'round' is not a member of 'std'

DoneSubmitted by maxim.cournoyer.
Details
2 participants
  • Ludovic Courtès
  • maxim.cournoyer
Owner
unassigned
Severity
important
M
M
maxim.cournoyer wrote on 16 Jul 15:51 +0200
(name . bug-guix)(address . bug-guix@gnu.org)
87imenk1ps.fsf@hurd.i-did-not-set--mail-host-address--so-tickle-me
Hello,
The following C++ snippet file reproduces it:
// file: test.cpp
#include <cmath>#include <iostream>

int main() { float x = 9.999;
std::cout << "rounding value: " << x << " --> " << std::round(x);
return 0;}
// build with:// g++ -o test.o -std=c++17 test.cpp
It affects only GCC 8 and newer, GCC 7 is fine. The available "round"seems to be the one originating from tgmath.h (implementation detail ofmath.h AFAICT).
The std::round function is conditionally defined in the C++ standard(since C++11) in the cmath header. It is supposed to also #undef theglobal "round" macro, but it doesn't, or perhaps the ordering of theincludes is wrong and math.h gets included following cmath.
In cmath, macros such as 'round' are undefined based on someconditions. These conditions appear to be:
__cplusplus >= 201103L and _GLIBCXX_USE_C99_MATH_TR1 and not _GLIBCXX_NO_C99_ROUNDING_FUNCS
The following are some data points I've gathered from the following guix environment:
Toggle snippet (5 lines)guix environment --pure gcc-toolchain@10 --ad-hoc coreutils findutilsstrace the-silver-searcher

Toggle snippet (4 lines)echo $CPLUS_INCLUDE_PATH/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/c++:/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include
The following lists the special #include_next directives, which tellscpp (the C preprocessor) to look for the next file with that name in theremaining of the its search path (as opposed to by starting the lookupin the current search path).
Toggle snippet (42 lines)ag -f include_next $(realpath /gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/*)/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/bits/std_abs.h37:#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS38:#include_next <stdlib.h>40:# include_next <math.h>42:#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/cmath44:#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS45:#include_next <math.h>46:#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/complex.h38:# include_next <complex.h>
/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/cstdlib74:#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS75:#include_next <stdlib.h>76:#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/limits.h40: #include's protect themselves, and in GCC 2 we may #include_next through47:/* We don't have #include_next.119: We put this #include_next outside the double inclusion check because124:# include_next <limits.h>
/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/fenv.h36:# include_next <fenv.h>
/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/math.h29:#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS30:# include_next <math.h>
/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/stdlib.h29:#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS30:# include_next <stdlib.h>
/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/tgmath.h35:# include_next <tgmath.h>

Finally, the following lists the exact order in which g++/cpp haveopened them (I'm hoping that maps with the order it derived from its searchpath/#include_next):
Toggle snippet (86 lines)strace -z -f -e trace=openat g++ -o test.o -std=c++14 test.cpp[...][pid 8163] openat(AT_FDCWD, "test.cpp", O_RDONLY|O_NOCTTY) = 3[pid 8163] openat(AT_FDCWD, "/tmp/ccEUTfto.s", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/stdc-predef.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD,"/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/c++/cmath",O_RDONLY|O_NOCTTY) = 4 # From gcc-10.1.0[pid 8163] openat(AT_FDCWD, "/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/x86_64-unknown-linux-gnu/bits/os_defines.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/features.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/sys/cdefs.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/wordsize.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/long-double.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/gnu/stubs.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/gnu/stubs-64.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/x86_64-unknown-linux-gnu/bits/cpu_defines.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/c++/bits/cpp_type_traits.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/c++/ext/type_traits.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD,"/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/math.h",O_RDONLY|O_NOCTTY) = 4 # This one is from glibc-2.31[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/libc-header-start.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/types.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/wordsize.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/timesize.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/typesizes.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/time64.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/math-vector.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/libm-simd-decl-stubs.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/floatn.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/floatn-common.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/long-double.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/flt-eval-method.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/fp-logb.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/fp-fast.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-helper-functions.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-helper-functions.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-helper-functions.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-helper-functions.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls-narrow.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/iscanonical.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/c++/bits/std_abs.h", O_RDONLY|O_NOCTTY) = 4[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/stdlib.h", O_RDONLY|O_NOCTTY) = 4
[...]
[pid 8163] openat(AT_FDCWD, "test.cpp", O_RDONLY) = 4test.cpp: In function 'int main()':test.cpp:10:61: error: 'round' is not a member of 'std'; did you mean 'round'? 10 | std::cout << "rounding value: " << x << " --> " << std::round(x); | ^~~~~[pid 8163] openat(AT_FDCWD, "/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h", O_RDONLY) = 5In file included from /gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/features.h:465, from /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/x86_64-unknown-linux-gnu/bits/os_defines.h:39, from /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h:518, from /gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/c++/cmath:41, from test.cpp:3:/gnu/store/4rssdv43wikii23rghfjlr62z83x44r0-profile/include/bits/mathcalls.h:298:1: note: 'round' declared here 298 | __MATHCALLX (round,, (_Mdouble_ __x), (__const__)); | ^~~~~~~~~~~[pid 8163] +++ exited with 1 +++--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8163, si_uid=1000, si_status=1, si_utime=43, si_stime=8} ---+++ exited with 1 +++
Perhaps the wrong math.h (the one from glibc) is being included? Indeed,browsing its content, I can't see a definition for round, and all cmathdoes is wrap the original definitions in the std namespace!
The possible math.h candidates are:
Toggle snippet (9 lines)find -L /gnu/store/dis9nlzbqy5j860gl1nxjijmcw9dsb6w-profile/include -name '*math.h' | xargs realpath/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/math.h/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/tgmath.h/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/tr1/math.h/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/include/c++/tr1/tgmath.h/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/math.h/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/tgmath.h
The #include_next does what it's intended to do and pick math.h fromanother search directory with a file of the same name, which it finds inglibc.
I don't have any more ideas of things to look at at this point in time.
Maxim
L
L
Ludovic Courtès wrote on 20 Jul 23:45 +0200
control message for bug #42392
(address . control@debbugs.gnu.org)
87y2ndq2r3.fsf@gnu.org
severity 42392 importantquit
L
L
Ludovic Courtès wrote on 21 Jul 17:27 +0200
Re: bug#42392: GCC includes ordering issue? g++: error: 'round' is not a member of 'std'
(address . maxim.cournoyer@gmail.com)(address . 42392@debbugs.gnu.org)
87imegoplx.fsf@gnu.org
Hi,
maxim.cournoyer@gmail.com skribis:
Toggle quote (34 lines)> The following C++ snippet file reproduces it:>> // file: test.cpp>> #include <cmath>> #include <iostream>>>> int main() {> float x = 9.999;>> std::cout << "rounding value: " << x << " --> " << std::round(x);>> return 0;> }>> // build with:> // g++ -o test.o -std=c++17 test.cpp>>> It affects only GCC 8 and newer, GCC 7 is fine. The available "round"> seems to be the one originating from tgmath.h (implementation detail of> math.h AFAICT).>> The std::round function is conditionally defined in the C++ standard> (since C++11) in the cmath header. It is supposed to also #undef the> global "round" macro, but it doesn't, or perhaps the ordering of the> includes is wrong and math.h gets included following cmath.>> In cmath, macros such as 'round' are undefined based on some> conditions. These conditions appear to be:>> __cplusplus >= 201103L and _GLIBCXX_USE_C99_MATH_TR1 and not _GLIBCXX_NO_C99_ROUNDING_FUNCS
See alsohttps://lists.gnu.org/archive/html/guix-devel/2020-06/msg00096.html,which suggests rather a misconfiguration issue.
Comparing ‘c++config.h’ from GCC 7 (which works) and GCC 8 (the firstone that exhibits this problem), we see:
diff -ubBr --show-c-function /gnu/store/93z2pmmpla1n47q3xivqyic4mwvy0r5q-gcc-toolchain-8.4.0/include/c\+\+/x86_64-unknown-linux-gnu/bits/c\+\+config.h /gnu/store/xa45bzcbib4zqa7gk70nb35dzzwyr376-gcc-toolchain-7.5.0/include/c\+\+/x86_64-unknown-linux-gnu/bits/c\+\+config.h--- /gnu/store/xa45bzcbib4zqa7gk70nb35dzzwyr376-gcc-toolchain-7.5.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h 1970-01-01 01:00:01.000000000 +0100+++ /gnu/store/93z2pmmpla1n47q3xivqyic4mwvy0r5q-gcc-toolchain-8.4.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h 1970-01-01 01:00:01.000000000 +0100
[...]
@@ -644,61 +619,61 @@ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `acosf' function. */-#define _GLIBCXX_HAVE_ACOSF 1+/* #undef _GLIBCXX_HAVE_ACOSF */ /* Define to 1 if you have the `acosl' function. */-#define _GLIBCXX_HAVE_ACOSL 1+/* #undef _GLIBCXX_HAVE_ACOSL */ /* Define to 1 if you have the `aligned_alloc' function. */ #define _GLIBCXX_HAVE_ALIGNED_ALLOC 1 /* Define to 1 if you have the `asinf' function. */-#define _GLIBCXX_HAVE_ASINF 1+/* #undef _GLIBCXX_HAVE_ASINF */ /* Define to 1 if you have the `asinl' function. */-#define _GLIBCXX_HAVE_ASINL 1+/* #undef _GLIBCXX_HAVE_ASINL */ /* Define to 1 if the target assembler supports .symver directive. */ #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 /* Define to 1 if you have the `atan2f' function. */-#define _GLIBCXX_HAVE_ATAN2F 1+/* #undef _GLIBCXX_HAVE_ATAN2F */ /* Define to 1 if you have the `atan2l' function. */-#define _GLIBCXX_HAVE_ATAN2L 1+/* #undef _GLIBCXX_HAVE_ATAN2L */ /* Define to 1 if you have the `atanf' function. */-#define _GLIBCXX_HAVE_ATANF 1+/* #undef _GLIBCXX_HAVE_ATANF */ /* Define to 1 if you have the `atanl' function. */-#define _GLIBCXX_HAVE_ATANL 1+/* #undef _GLIBCXX_HAVE_ATANL */ /* Define to 1 if you have the `at_quick_exit' function. */-#define _GLIBCXX_HAVE_AT_QUICK_EXIT 1+/* #undef _GLIBCXX_HAVE_AT_QUICK_EXIT */ /* Define to 1 if the target assembler supports thread-local storage. */ /* #undef _GLIBCXX_HAVE_CC_TLS */ /* Define to 1 if you have the `ceilf' function. */-#define _GLIBCXX_HAVE_CEILF 1+/* #undef _GLIBCXX_HAVE_CEILF */ /* Define to 1 if you have the `ceill' function. */-#define _GLIBCXX_HAVE_CEILL 1+/* #undef _GLIBCXX_HAVE_CEILL */ /* Define to 1 if you have the <complex.h> header file. */-#define _GLIBCXX_HAVE_COMPLEX_H 1+/* #undef _GLIBCXX_HAVE_COMPLEX_H */ /* Define to 1 if you have the `cosf' function. */-#define _GLIBCXX_HAVE_COSF 1+/* #undef _GLIBCXX_HAVE_COSF */ /* Define to 1 if you have the `coshf' function. */-#define _GLIBCXX_HAVE_COSHF 1+/* #undef _GLIBCXX_HAVE_COSHF */ /* Define to 1 if you have the `coshl' function. */-#define _GLIBCXX_HAVE_COSHL 1+/* #undef _GLIBCXX_HAVE_COSHL */ /* Define to 1 if you have the `cosl' function. */-#define _GLIBCXX_HAVE_COSL 1+/* #undef _GLIBCXX_HAVE_COSL */ /* Define to 1 if you have the <dirent.h> header file. */ #define _GLIBCXX_HAVE_DIRENT_H 1
/tmp/guix-build-gcc-10.1.0.drv-0/build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/config.logreads this:
Toggle snippet (25 lines)configure:19924: checking for float trig functionsconfigure:19948: /tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc/xgcc -shared-libgcc -B/tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc -nostdinc++ -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/bin/ -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/lib/ -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/include -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/sys-include -fno-checking -c -fno-builtin -D_GNU_SOURCE conftest.cpp >&5In file included from /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/math.h:36, from conftest.cpp:122:/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/cmath:41:10: fatal error: bits/c++config.h: No such file or directory 41 | #include <bits/c++config.h> | ^~~~~~~~~~~~~~~~~~compilation terminated.configure:19948: $? = 1configure: failed program was:
[...]
| /* end confdefs.h. */| #include <math.h>| int| main ()| {| acosf (0); asinf (0); atanf (0); cosf (0); sinf (0); tanf (0); coshf (0); sinhf (0); tanhf (0);| ;| return 0;| }configure:19962: result: no
At this point, we have:
Toggle snippet (19 lines)export CPLUS_INCLUDE_PATH=\"/gnu/store/61pv34q6kad3cii1pngyairvxbxgdm1n-isl-0.22.1/include\:/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/include\:/gnu/store/5jf395qa3v4amdi60850rz2a15zlsrza-mpfr-4.0.2/include\:/gnu/store/lgrnkwh7w5yawgqaglwj1pls5vwz1nz7-mpc-1.1.0/include\:/gnu/store/243algr6h60j46spn5dqhjc4mhkd0a0p-libelf-0.8.13/include\:/gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/include\:/gnu/store/i8h2pcxqdq07ijm3ibkka8f4smn1w48v-bzip2-1.0.8/include\:/gnu/store/9860f1abqj8wjjnwl8a9v54pdcc3bhgf-xz-5.2.4/include\:/gnu/store/60g7r3l01fd7c58yjbm6krgcwj1jkpwg-file-5.38/include\:/gnu/store/swqdvwri9dbv6zssg6v0by7l05hd6wxp-gawk-5.0.1/include\:/gnu/store/hm40bxnv8jxmbc1lpb7zfimii4xm9m81-make-4.3/include\:/gnu/store/m1z7cdbqsqyp9xnjw5cvlb4a7gkcg3m4-binutils-2.34/include\:/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++\:/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include\:/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include\:/gnu/store/gfapkk5c6hvl1d94m4sqnhn7f9l5gqyh-linux-libre-headers-5.4.20/include"
but <bits/c++config.h> is in a directory not listed here:
Toggle snippet (4 lines)$ find /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0 -name c++config.h/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h
‘gcc-final’ doesn’t have this problem because it depends on ‘libstdc++’(separate package) where:
Toggle snippet (4 lines)$ find /gnu/store/v507xkc5flnzqa49yp41w5y611p4lqbg-libstdc++-7.5.0 -name c++config.h/gnu/store/v507xkc5flnzqa49yp41w5y611p4lqbg-libstdc++-7.5.0/include/bits/c++config.h
So somehow the problems seems to be that ‘xgcc’ doesn’t search‘gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu’. We could add it toCPLUS_INCLUDE_PATH manually, but it seems to me we’re missing something.
Thoughts?
Thanks,Ludo’.
L
L
Ludovic Courtès wrote on 23 Jul 11:37 +0200
(address . maxim.cournoyer@gmail.com)(address . 42392@debbugs.gnu.org)
87a6zqefm6.fsf@gnu.org
Hi!
Ludovic Courtès <ludo@gnu.org> skribis:
Toggle quote (27 lines)> /tmp/guix-build-gcc-10.1.0.drv-0/build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/config.log> reads this:>> configure:19924: checking for float trig functions> configure:19948: /tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc/xgcc -shared-libgcc -B/tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc -nostdinc++ -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/bin/ -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/lib/ -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/include -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/sys-include -fno-checking -c -fno-builtin -D_GNU_SOURCE conftest.cpp >&5> In file included from /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/math.h:36,> from conftest.cpp:122:> /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/cmath:41:10: fatal error: bits/c++config.h: No such file or directory> 41 | #include <bits/c++config.h>> | ^~~~~~~~~~~~~~~~~~> compilation terminated.> configure:19948: $? = 1> configure: failed program was:>> [...]>> | /* end confdefs.h. */> | #include <math.h>> | int> | main ()> | {> | acosf (0); asinf (0); atanf (0); cosf (0); sinf (0); tanf (0); coshf (0); sinhf (0); tanhf (0);> | ;> | return 0;> | }> configure:19962: result: no
The attached patch addresses this with a questionable yet efficienthack. The test cases reported by Maxim and by Erik Garrison now buildfine.
I’ve asked for guidance for a proper fix athttps://gcc.gnu.org/pipermail/gcc-help/2020-July/139204.html, but inthe meantime, I’m happy to go with this patch.
Thoughts?
Thanks,Ludo’.
Toggle diff (48 lines)diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scmindex 9ff5e3d7c0..8969fefd84 100644--- a/gnu/packages/gcc.scm+++ b/gnu/packages/gcc.scm@@ -530,6 +530,12 @@ Go. It also includes runtime support libraries for these languages.") (patches (search-patches "gcc-strmov-store-file-names.patch" "gcc-7-libsanitizer-mode-size.patch" "gcc-5.0-libvtv-runpath.patch"))))+ (inputs+ ;; XXX: This gross hack allows us to have libstdc++'s <bits/c++config.h>+ ;; in the search path, thereby avoiding misconfiguration of libstdc++:+ ;; <https://bugs.gnu.org/42392>.+ `(("libstdc++" ,libstdc++-headers)+ ,@(package-inputs gcc-6))) (description "GCC is the GNU Compiler Collection. It provides compiler front-ends for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.@@ -607,6 +613,31 @@ using compilers other than GCC." (propagated-inputs '()) (synopsis "GNU C++ standard library"))) +(define libstdc+++ ;; Libstdc++ matching the default GCC.+ (make-libstdc++ gcc))++(define libstdc++-headers+ ;; XXX: This package is for internal use to work around+ ;; <https://bugs.gnu.org/42392> (see above). The main difference compared+ ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>+ ;; is right under include/c++ and not under+ ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).+ (package+ (inherit libstdc++)+ (name "libstdc++-headers")+ (outputs '("out"))+ (build-system trivial-build-system)+ (arguments+ '(#:builder (let* ((out (assoc-ref %outputs "out"))+ (libstdc++ (assoc-ref %build-inputs "libstdc++")))+ (mkdir out)+ (mkdir (string-append out "/include"))+ (symlink (string-append libstdc++ "/include")+ (string-append out "/include/c++")))))+ (inputs `(("libstdc++" ,libstdc++)))+ (synopsis "Headers of GNU libstdc++")))+ (define-public libstdc++-4.9 (make-libstdc++ gcc-4.9))
L
L
Ludovic Courtès wrote on 24 Jul 14:24 +0200
(address . maxim.cournoyer@gmail.com)(address . 42392-done@debbugs.gnu.org)
874kpxaynk.fsf@gnu.org
Hello,
Ludovic Courtès <ludo@gnu.org> skribis:
Toggle quote (8 lines)> The attached patch addresses this with a questionable yet efficient> hack. The test cases reported by Maxim and by Erik Garrison now build> fine.>> I’ve asked for guidance for a proper fix at> <https://gcc.gnu.org/pipermail/gcc-help/2020-July/139204.html>, but in> the meantime, I’m happy to go with this patch.
Closed
M
M
Maxim Cournoyer wrote on 26 Jul 07:33 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 42392@debbugs.gnu.org)
871rkyg7rz.fsf@gmail.com
Hello Ludovic!
Thank you for the investigation, and sorry for not having been able toreply earlier!
Ludovic Courtès <ludo@gnu.org> writes:
[...]
Toggle quote (3 lines)>>>> __cplusplus >= 201103L and _GLIBCXX_USE_C99_MATH_TR1 and not _GLIBCXX_NO_C99_ROUNDING_FUNCS
Thanks for pointing out this configuration time problem!
[...]
Toggle quote (7 lines)> Comparing ‘c++config.h’ from GCC 7 (which works) and GCC 8 (the first> one that exhibits this problem), we see:>> diff -ubBr --show-c-function /gnu/store/93z2pmmpla1n47q3xivqyic4mwvy0r5q-gcc-toolchain-8.4.0/include/c\+\+/x86_64-unknown-linux-gnu/bits/c\+\+config.h /gnu/store/xa45bzcbib4zqa7gk70nb35dzzwyr376-gcc-toolchain-7.5.0/include/c\+\+/x86_64-unknown-linux-gnu/bits/c\+\+config.h> --- /gnu/store/xa45bzcbib4zqa7gk70nb35dzzwyr376-gcc-toolchain-7.5.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h 1970-01-01 01:00:01.000000000 +0100> +++ /gnu/store/93z2pmmpla1n47q3xivqyic4mwvy0r5q-gcc-toolchain-8.4.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h 1970-01-01 01:00:01.000000000 +0100>
[...]
Interesting!
Toggle quote (5 lines)> /tmp/guix-build-gcc-10.1.0.drv-0/build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/config.log> reads this:>> configure:19924: checking for float trig functions
Notes: This check is made by the GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1 m4macro defined under in libstdc++-v3/linkage.m4. The macro definitionhasn't changed since 2005, so it's not the cause of the problem.
Toggle quote (10 lines)> configure:19948: /tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc/xgcc -shared-libgcc -B/tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc -nostdinc++ -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/bin/ -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/lib/ -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/include -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/sys-include -fno-checking -c -fno-builtin -D_GNU_SOURCE conftest.cpp >&5> In file included from /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/math.h:36,> from conftest.cpp:122:> /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/cmath:41:10: fatal error: bits/c++config.h: No such file or directory> 41 | #include <bits/c++config.h>> | ^~~~~~~~~~~~~~~~~~> compilation terminated.> configure:19948: $? = 1> configure: failed program was:
Eh! I fail to see what changed between 7.5 and 8.1, that would havecaused such a change in behavior.
[...]
Toggle quote (40 lines)> At this point, we have:>> export CPLUS_INCLUDE_PATH=\> "/gnu/store/61pv34q6kad3cii1pngyairvxbxgdm1n-isl-0.22.1/include\> :/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/include\> :/gnu/store/5jf395qa3v4amdi60850rz2a15zlsrza-mpfr-4.0.2/include\> :/gnu/store/lgrnkwh7w5yawgqaglwj1pls5vwz1nz7-mpc-1.1.0/include\> :/gnu/store/243algr6h60j46spn5dqhjc4mhkd0a0p-libelf-0.8.13/include\> :/gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/include\> :/gnu/store/i8h2pcxqdq07ijm3ibkka8f4smn1w48v-bzip2-1.0.8/include\> :/gnu/store/9860f1abqj8wjjnwl8a9v54pdcc3bhgf-xz-5.2.4/include\> :/gnu/store/60g7r3l01fd7c58yjbm6krgcwj1jkpwg-file-5.38/include\> :/gnu/store/swqdvwri9dbv6zssg6v0by7l05hd6wxp-gawk-5.0.1/include\> :/gnu/store/hm40bxnv8jxmbc1lpb7zfimii4xm9m81-make-4.3/include\> :/gnu/store/m1z7cdbqsqyp9xnjw5cvlb4a7gkcg3m4-binutils-2.34/include\> :/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++\> :/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include\> :/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include\> :/gnu/store/gfapkk5c6hvl1d94m4sqnhn7f9l5gqyh-linux-libre-headers-5.4.20/include">>> but <bits/c++config.h> is in a directory not listed here:>> $ find /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0 -name c++config.h> /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h>>> ‘gcc-final’ doesn’t have this problem because it depends on ‘libstdc++’> (separate package) where:>> $ find /gnu/store/v507xkc5flnzqa49yp41w5y611p4lqbg-libstdc++-7.5.0 -name c++config.h> /gnu/store/v507xkc5flnzqa49yp41w5y611p4lqbg-libstdc++-7.5.0/include/bits/c++config.h>>> So somehow the problems seems to be that ‘xgcc’ doesn’t search> ‘gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu’. We could add it to> CPLUS_INCLUDE_PATH manually, but it seems to me we’re missing something.>> Thoughts?
Great findings!
But you got me curious as how the previous GCC version managed to eschewthis problem :-). Sadly, a couple evening of eye-balling GCC logs andlooking at include files haven't given me a clue.
Oh well, thank you for fixing it!
Maxim
L
L
Ludovic Courtès wrote on 27 Jul 20:24 +0200
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 42392@debbugs.gnu.org)
87eeowvmsf.fsf@gnu.org
Hi!
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
Toggle quote (13 lines)>> configure:19948: /tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc/xgcc -shared-libgcc -B/tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc -nostdinc++ -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/bin/ -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/lib/ -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/include -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/sys-include -fno-checking -c -fno-builtin -D_GNU_SOURCE conftest.cpp >&5>> In file included from /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/math.h:36,>> from conftest.cpp:122:>> /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/cmath:41:10: fatal error: bits/c++config.h: No such file or directory>> 41 | #include <bits/c++config.h>>> | ^~~~~~~~~~~~~~~~~~>> compilation terminated.>> configure:19948: $? = 1>> configure: failed program was:>> Eh! I fail to see what changed between 7.5 and 8.1, that would have> caused such a change in behavior.
Nothing: the difference is between ‘gcc-final’ and the GCCs exportedfrom (gnu packages gcc).
‘gcc-final’ has ‘libstdc++’ (a separate package) has an input, like Iwrote. And thus <bits/c++config.h> is found in this case.
Does that make sense?
Thanks,Ludo’.
?