aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@baylibre.com>2025-02-20 16:31:50 +0100
committerThomas Schwinge <tschwinge@baylibre.com>2025-03-14 13:21:18 +0100
commit1268924a2eed4e4f4cf1f43cc996b2f0eedeb07e (patch)
tree2cc47d812b0a46b176faa96a8866eac361ff81ac
parent62dc2d24f1ee9fd81b85937b0f1b7d51818fb0d4 (diff)
downloadgcc-1268924a2eed4e4f4cf1f43cc996b2f0eedeb07e.zip
gcc-1268924a2eed4e4f4cf1f43cc996b2f0eedeb07e.tar.gz
gcc-1268924a2eed4e4f4cf1f43cc996b2f0eedeb07e.tar.bz2
GCN, nvptx: Allow for "hosted" libstdc++ build
We need '-fno-exceptions', '-fno-rtti', disable generation of PCH files, and for nvptx twiddle some more knobs. PR target/92713 PR target/101544 libstdc++-v3/ * config/cpu/nvptx/cpu_defines.h: New. * config/cpu/nvptx/t-nvptx: Likewise. * configure.host: Handle GCN, nvptx.
-rw-r--r--libstdc++-v3/config/cpu/nvptx/cpu_defines.h36
-rw-r--r--libstdc++-v3/config/cpu/nvptx/t-nvptx7
-rw-r--r--libstdc++-v3/configure.host37
3 files changed, 80 insertions, 0 deletions
diff --git a/libstdc++-v3/config/cpu/nvptx/cpu_defines.h b/libstdc++-v3/config/cpu/nvptx/cpu_defines.h
new file mode 100644
index 0000000..65744e0
--- /dev/null
+++ b/libstdc++-v3/config/cpu/nvptx/cpu_defines.h
@@ -0,0 +1,36 @@
+// Specific definitions for nvptx platforms -*- C++ -*-
+
+// Copyright (C) 2025 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file bits/cpu_defines.h
+ * This is an internal header file, included by other library headers.
+ * Do not attempt to use it directly. @headername{iosfwd}
+ */
+
+#ifndef _GLIBCXX_CPU_DEFINES
+#define _GLIBCXX_CPU_DEFINES 1
+
+// No support for referencing weak symbols without a definition.
+#define _GLIBCXX_USE_WEAK_REF 0
+
+#endif
diff --git a/libstdc++-v3/config/cpu/nvptx/t-nvptx b/libstdc++-v3/config/cpu/nvptx/t-nvptx
new file mode 100644
index 0000000..a2f0f2d
--- /dev/null
+++ b/libstdc++-v3/config/cpu/nvptx/t-nvptx
@@ -0,0 +1,7 @@
+# Per-file flags, see '../../../configure.host', "inject per-file flags".
+
+# 'ptxas'/CUDA Driver rejects objects with a lot of global constant data:
+# ptxas error : File uses too much global constant data ([...])
+# Cut short the assembly-time check; defer to actual use of the object file.
+AM_MAKEFLAGS += CXXFLAGS-src/c++17/floating_to_chars.lo=-Wa,--no-verify
+AM_MAKEFLAGS += CXXFLAGS-src/c++20/tzdb.lo=-Wa,--no-verify
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index 933a43f..cb4c28a 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -150,6 +150,9 @@ case "${host_cpu}" in
arm*)
cpu_defines_dir=cpu/arm
;;
+ nvptx)
+ cpu_defines_dir=cpu/nvptx
+ ;;
powerpc* | rs6000)
cpu_defines_dir=cpu/powerpc
;;
@@ -367,6 +370,16 @@ case "${host}" in
arm*-*-freebsd*)
port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
;;
+ nvptx-*-none)
+ # For 'make all-target-libstdc++-v3', we need to inject per-file flags:
+ OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} \$(CXXFLAGS-\$(subdir)/\$@)"
+ # ..., see:
+ tmake_file="$tmake_file cpu/nvptx/t-nvptx"
+
+ # For 'make all-target-libstdc++-v3', re 'alloca'/VLA usage:
+ EXTRA_CFLAGS="${EXTRA_CFLAGS} -mfake-ptx-alloca"
+ OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} -mfake-ptx-alloca"
+ ;;
powerpc*-*-darwin*)
port_specific_symbol_files="\$(srcdir)/../config/os/bsd/darwin/ppc-extra.ver"
;;
@@ -383,3 +396,27 @@ case "${host}" in
abi_baseline_subdir_switch=--print-multi-os-directory
;;
esac
+
+
+# Dumb down libstdc++ for certain configurations.
+# THIS TABLE IS SORTED. KEEP IT THAT WAY.
+case "${host}" in
+ amdgcn-*-amdhsa \
+ | nvptx-*-none )
+ # For 'make all-target-libstdc++-v3' and 'make check-target-libstdc++-v3',
+ # exception handling is not supported: in case that exception handling
+ # constructs survive compiler optimizations, the back ends error out:
+ # sorry, unimplemented: exception handling not supported
+ EXTRA_CXX_FLAGS="${EXTRA_CXX_FLAGS} -fno-exceptions"
+
+ # For 'make all-target-libstdc++-v3' and 'make check-target-libstdc++-v3',
+ # RTTI is not supported.
+ EXTRA_CXX_FLAGS="${EXTRA_CXX_FLAGS} -fno-rtti"
+
+ # Cannot '#include' all newlib header files without explosion, for example:
+ # error: 'jmp_buf' was not declared in this scope
+ # Just disable generation of PCH files here, instead of attempting to care
+ # for such special cases in some more complex way.
+ enable_libstdcxx_pch=no
+ ;;
+esac