summaryrefslogtreecommitdiff
path: root/eclass/toolchain.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-12-01 02:06:43 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-12-01 02:06:43 +0000
commitc635a4b7ddb6105bfc6fef130b188a087726677b (patch)
tree6707959596af4883f9621a0cdf56d35c06dbc63e /eclass/toolchain.eclass
parent080d89feff80cae2fc974ff2f24d463141c20635 (diff)
gentoo auto-resync : 01:12:2024 - 02:06:42
Diffstat (limited to 'eclass/toolchain.eclass')
-rw-r--r--eclass/toolchain.eclass56
1 files changed, 53 insertions, 3 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 13f3298fea90..505e7c2666d7 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1311,8 +1311,31 @@ toolchain_src_configure() {
confgcc+=( --enable-shared --disable-threads )
;;
nvptx*)
- # "LTO is not supported for this target"
- confgcc+=( --disable-lto )
+ needed_libc=newlib
+ 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
@@ -1389,7 +1412,7 @@ toolchain_src_configure() {
# __cxa_atexit is "essential for fully standards-compliant handling of
# destructors", but apparently requires glibc.
case ${CTARGET} in
- *-elf|*-eabi)
+ nvptx*|*-elf|*-eabi)
confgcc+=( --with-newlib )
;;
*-musl*)
@@ -1546,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
@@ -1966,6 +1995,9 @@ gcc_do_filter_flags() {
fi
fi
+ # https://gcc.gnu.org/PR100431
+ filter-flags -Werror=format-security
+
if ver_test -lt 13.6 ; then
# These aren't supported by the just-built compiler either.
filter-flags -fharden-compares -fharden-conditional-branches \
@@ -2666,6 +2698,24 @@ gcc_movelibs() {
fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
done
+ # Without this, we end up either unable to find the libgomp spec/archive, or
+ # we underlink and can't find gomp_nvptx_main (presumably because we can't find the plugin)
+ # https://src.fedoraproject.org/rpms/gcc/blob/02c34dfa3627ef05d676d30e152a66e77b58529b/f/gcc.spec#_1445
+ if [[ ${CTARGET} == nvptx* ]] && has_version ${CATEGORY}/${PN} ; then
+ rm -rf "${ED}"/usr/libexec/gcc/nvptx-none/${GCCMAJOR}/install-tools
+ rm -rf "${ED}"/usr/libexec/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/{install-tools,plugin,cc1,cc1plus,f951}
+ rm -rf "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/{install-tools,plugin}
+ rm -rf "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/{install-tools,plugin,include-fixed}
+ mv "${ED}"/usr/nvptx-none/lib/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/
+ mv "${ED}"/usr/nvptx-none/lib/mgomp/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/
+ mv "${ED}"/usr/nvptx-none/lib/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mptx-3.1/
+ mv "${ED}"/usr/nvptx-none/lib/mgomp/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/mptx-3.1/
+ mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/ || die
+ mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/mgomp/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/ || die
+ mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mptx-3.1/ || die
+ mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/mgomp/mptx-3.1/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/mgomp/mptx-3.1/ || die
+ fi
+
# We remove directories separately to avoid this case:
# mv SRC/lib/../lib/*.o DEST
# rmdir SRC/lib/../lib/