You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
3.1 KiB

  1. From: Jonathan Wakely <jwakely@redhat.com>
  2. Date: Fri, 7 Jan 2022 15:21:03 +0000 (+0000)
  3. Subject: libstdc++: Add -nostdinc++ for c++17 sources [PR100017]
  4. X-Git-Tag: releases/gcc-11.3.0~445
  5. X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=01a70ccd723eb9a479186fe37c972b0d0f8676cf
  6. libstdc++: Add -nostdinc++ for c++17 sources [PR100017]
  7. When building a build!=host compiler, the just-built gcc can't be used
  8. to build the target libstdc++ (because it is built for the host triplet,
  9. not the build triplet). The top-level configure.ac sets up the build
  10. flags for libstdc++ (and other "raw_cxx" libs) like this:
  11. GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX,
  12. [gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs],
  13. c++)
  14. The -nostdinc++ flag is only used for the IN-TREE-TOOL, i.e. when using
  15. the just-built gcc/xgcc compiler. This means that the cross-compiler
  16. used to build libstdc++ will add its own libstdc++ headers to the
  17. include path. That results in the #include <cfenv> in
  18. src/c++17/floating_to_chars.cc and src/c++17/floating_from_chars.cc
  19. doing #include_next <fenv.h> and finding the libstdc++ fenv.h wrapper
  20. from the host compiler. Because that has the same include guard as the
  21. <fenv.h> in the libstdc++ we're trying to build, we never reach the
  22. underlying <fenv.h> from libc. That results in several errors of the
  23. form:
  24. error: 'fenv_t' has not been declared in '::'
  25. The most correct fix would be to add -nostdinc++ to the
  26. RAW_CXX_FOR_TARGET variable in configure.ac, or the
  27. RAW_CXX_TARGET_EXPORTS variable in Makefile.tpl.
  28. Another solution would be to make the libstdc++ <fenv.h> wrapper use
  29. _GLIBCXX_INCLUDE_NEXT_C_HEADERS like our <stdlib.h> and other C header
  30. wrappers.
  31. For now though, the simplest and safest solution is to just add
  32. -nostdinc++ to the CXXFLAGS used for src/c++17/*.cc, which is what this
  33. does.
  34. libstdc++-v3/ChangeLog:
  35. PR libstdc++/100017
  36. * src/c++17/Makefile.am (AM_CXXFLAGS): Add -nostdinc++.
  37. * src/c++17/Makefile.in: Regenerate.
  38. (cherry picked from commit 4fde88e5dd152fe866a97b12e0f8229970d15cb3)
  39. ---
  40. --- a/libstdc++-v3/src/c++17/Makefile.am
  41. +++ b/libstdc++-v3/src/c++17/Makefile.am
  42. @@ -79,7 +79,7 @@ endif
  43. # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
  44. # as the occasion calls for it.
  45. AM_CXXFLAGS = \
  46. - -std=gnu++17 \
  47. + -std=gnu++17 -nostdinc++ \
  48. $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
  49. $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
  50. $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \
  51. --- a/libstdc++-v3/src/c++17/Makefile.in
  52. +++ b/libstdc++-v3/src/c++17/Makefile.in
  53. @@ -455,7 +455,7 @@ libc__17convenience_la_SOURCES = $(sourc
  54. # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
  55. # as the occasion calls for it.
  56. AM_CXXFLAGS = \
  57. - -std=gnu++17 \
  58. + -std=gnu++17 -nostdinc++ \
  59. $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
  60. $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
  61. $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) \