commit:     6d9336278643e0ad9fc99cfd497d50c3a8f30319
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 30 02:59:57 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 30 05:10:29 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6d933627

toolchain.eclass: wire up offloading for nvptx

'crossdev -t nvptx-none' creates a standalone cross-compiler which is needed
anyway, but by itself, it's less useful than offloading support within
host gcc, where GCC can choose to offload into that cross-compiler as
appropriate.

This could include amdgcn-amdhsa support in the future.

Bug: https://bugs.gentoo.org/945296
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/toolchain.eclass | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index bcc47ffb9635..5b68c5acbc49 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1312,8 +1312,30 @@ toolchain_src_configure() {
                                ;;
                        nvptx*)
                                needed_libc=newlib
-                               # "LTO is not supported for this target"
-                               confgcc+=( --disable-lto )
+                               confgcc+=(
+                                       # "LTO is not supported for this target"
+                                       --disable-lto
+                               )
+
+                               # --enable-as-accelerator-for= seems to disable
+                               # installing nvtpx-none-cc etc, so we have to
+                               # avoid passing that for the stage1-build that
+                               # crossdev does. If we pass it unconditionally,
+                               # we can't build newlib after building stage1 
gcc.
+                               if has_version ${CATEGORY}/${PN} ; then
+                                       confgcc+=(
+                                               # It's unlikely that anyone 
will want
+                                               # to build nvptx-none as a pure 
standalone
+                                               # toolchain (which will be 
single-threaded, etc).
+                                               #
+                                               # If someone really wants it, 
we can see about
+                                               # adding a USE=offload or 
similar based on CTARGET
+                                               # for cross targets. But for 
now, we always assume
+                                               # we're being built as an 
offloading compiler (accelerator).
+                                               
--enable-as-accelerator-for=${CHOST}
+                                               --disable-sjlj-exceptions
+                                       )
+                               fi
                                ;;
                esac
 
@@ -1547,6 +1569,12 @@ toolchain_src_configure() {
        [[ ${CTARGET} == *-darwin* ]] && \
                confgcc+=( --enable-version-specific-runtime-libs )
 
+       # TODO: amdgcn-amdhsa?
+       [[ ${CTARGET} == x86_64* ]] && confgcc+=(
+               --enable-offload-defaulted
+               --enable-offload-targets=nvptx-none
+       )
+
        ### library options
 
        if in_iuse openmp ; then

Reply via email to