Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 945296 - emerge sys-devel/nvptx-tools with the usual command crossdev -t nvptx fails
Summary: emerge sys-devel/nvptx-tools with the usual command crossdev -t nvptx fails
Status: IN_PROGRESS
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on: 946079
Blocks:
  Show dependency tree
 
Reported: 2024-11-29 09:05 UTC by Benjamin Schulz
Modified: 2025-01-23 21:57 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,12.55 KB, text/plain)
2024-11-29 09:10 UTC, Benjamin Schulz
Details
info.log (cross-nvptx-info.log,19.79 KB, text/plain)
2024-11-29 09:28 UTC, Benjamin Schulz
Details
stage1 logfile in tar gz format (cross-nvptx-gcc-stage1.log.xz,48.65 KB, application/octet-stream)
2024-11-29 09:30 UTC, Benjamin Schulz
Details
config.log in tar gz format (gcc-config.logs.tar.xz,50.80 KB, application/octet-stream)
2024-11-29 09:31 UTC, Benjamin Schulz
Details
build.log (cross-nvptx-tools-nvptx-tools.log,135.83 KB, text/plain)
2024-11-29 10:33 UTC, Benjamin Schulz
Details
gcc-stage1- build log (cross-nvptx-tools-gcc-stage1.log,16.16 KB, text/plain)
2024-11-29 10:43 UTC, Benjamin Schulz
Details
target nvptx gcc-stage1 build log (logfile.tar.gz,73.30 KB, text/plain)
2024-11-29 11:05 UTC, Benjamin Schulz
Details
gcc-config-bug945296-offloading.patch (gcc-config-bug945296-offloading.patch,1.02 KB, patch)
2024-12-01 01:33 UTC, Sam James
Details | Diff
warnings from gcc with gcc-config patch (file_945296.txt,44.97 KB, text/plain)
2024-12-01 18:48 UTC, Benjamin Schulz
Details
logfile in tar gz format (cross-nvptx-none-gcc-stage2.log.xz,62.77 KB, application/octet-stream)
2024-12-01 19:01 UTC, Benjamin Schulz
Details
logfile (cross-nvptx-none-info.log,19.92 KB, text/plain)
2024-12-01 19:01 UTC, Benjamin Schulz
Details
more logfiles (logfiles.tar.gz,499.35 KB, application/octet-stream)
2024-12-01 19:10 UTC, Benjamin Schulz
Details
logfile (file_945296.txt,645.69 KB, text/plain)
2024-12-02 01:14 UTC, Benjamin Schulz
Details
log 1 (cross-nvptx-none-gcc-stage1.log.xz,51.82 KB, application/octet-stream)
2024-12-02 04:34 UTC, Benjamin Schulz
Details
log2 (cross-nvptx-none-info.log,19.94 KB, text/plain)
2024-12-02 04:35 UTC, Benjamin Schulz
Details
log3 (gcc-config.logs.tar.xz,56.46 KB, application/octet-stream)
2024-12-02 04:35 UTC, Benjamin Schulz
Details
3 logfiles in tar.gz archive (logfiles.tar.gz,80.00 KB, application/octet-stream)
2024-12-02 13:57 UTC, Benjamin Schulz
Details
log in txt form (cross-nvptx-none-info.log,20.25 KB, text/plain)
2024-12-24 11:39 UTC, Benjamin Schulz
Details
stage 1 log.xz (cross-nvptx-none-gcc-stage1.log.xz,17.54 KB, application/octet-stream)
2024-12-24 11:40 UTC, Benjamin Schulz
Details
gcc config logs (gcc-config.logs.tar.xz,49.17 KB, application/octet-stream)
2024-12-24 11:40 UTC, Benjamin Schulz
Details
info.log (cross-nvptx-none-info.log,20.25 KB, text/plain)
2024-12-24 22:57 UTC, Benjamin Schulz
Details
log.xz (cross-nvptx-none-gcc-stage1.log.xz,17.54 KB, application/octet-stream)
2024-12-24 22:57 UTC, Benjamin Schulz
Details
logs.tar.xz (gcc-config.logs.tar.xz,49.17 KB, application/octet-stream)
2024-12-24 22:58 UTC, Benjamin Schulz
Details
info.log (cross-nvptx-none-info.log,20.31 KB, text/plain)
2024-12-24 23:08 UTC, Benjamin Schulz
Details
log.xz (cross-nvptx-none-gcc-stage1.log.xz,68.52 KB, application/octet-stream)
2024-12-24 23:09 UTC, Benjamin Schulz
Details
tar.xz (gcc-config.logs.tar.xz,65.43 KB, application/octet-stream)
2024-12-24 23:09 UTC, Benjamin Schulz
Details
arraytestclass (mdspan.h,135.29 KB, text/x-chdr)
2025-01-15 19:20 UTC, Benjamin Schulz
Details
arraytest-main (main.cpp,3.88 KB, text/x-c++src)
2025-01-15 19:20 UTC, Benjamin Schulz
Details
cmakelists.txt (CMakeLists.txt,933 bytes, text/plain)
2025-01-15 19:21 UTC, Benjamin Schulz
Details
info.log (cross-nvptx-none-info.log,20.44 KB, text/plain)
2025-01-22 00:26 UTC, Benjamin Schulz
Details
log.gz (cross-nvptx-none-gcc-stage1.log.xz,21.96 KB, application/octet-stream)
2025-01-22 00:26 UTC, Benjamin Schulz
Details
gcc-config.log (gcc-config.logs.tar.xz,47.39 KB, application/octet-stream)
2025-01-22 00:27 UTC, Benjamin Schulz
Details
stage1 log (cross-nvptx-none-gcc-stage1.log.xz,73.69 KB, application/x-xz)
2025-01-22 01:06 UTC, Benjamin Schulz
Details
config log (gcc-config.logs.tar.xz,47.39 KB, application/octet-stream)
2025-01-22 01:06 UTC, Benjamin Schulz
Details
info.log (cross-nvptx-none-info.log,20.42 KB, text/plain)
2025-01-22 01:07 UTC, Benjamin Schulz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Schulz 2024-11-29 09:05:49 UTC
emerge crossdev
amd then
crossdev  -t nvptx fails

leads to 
  GNU nano 8.2                                                                           /var/tmp/portage/cross-gcc14+/binutils-2.42-r2/temp/build.log                                                                                      
 ^[[32;01m*^[[0m   Applying ppc64le/2.4.4 patch ...
 ^[[32;01m*^[[0m   Applying clang-runtime/2.4.7 patch ...
 ^[[32;01m*^[[0m Running elibtoolize in: binutils-2.42/gprofng/libcollector/
 ^[[32;01m*^[[0m   Applying ppc64le/2.4.4 patch ...
 ^[[32;01m*^[[0m   Applying clang-runtime/2.4.7 patch ...
 ^[[32;01m*^[[0m Running elibtoolize in: binutils-2.42/ld/
 ^[[32;01m*^[[0m   Applying ppc64le/2.4.4 patch ...
 ^[[32;01m*^[[0m   Applying clang-runtime/2.4.7 patch ...
 ^[[32;01m*^[[0m Running elibtoolize in: binutils-2.42/libctf/
 ^[[32;01m*^[[0m   Applying ppc64le/2.4.4 patch ...
 ^[[32;01m*^[[0m Running elibtoolize in: binutils-2.42/libiberty/
 ^[[32;01m*^[[0m Running elibtoolize in: binutils-2.42/libsframe/
 ^[[32;01m*^[[0m   Applying ppc64le/2.4.4 patch ...
 ^[[32;01m*^[[0m Running elibtoolize in: binutils-2.42/opcodes/
 ^[[32;01m*^[[0m   Applying ppc64le/2.4.4 patch ...
 ^[[32;01m*^[[0m Running elibtoolize in: binutils-2.42/zlib/
 ^[[32;01m*^[[0m   Applying ppc64le/2.4.4 patch ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/cross-gcc14+/binutils-2.42-r2/work/binutils-2.42 ...

 ^[[32m*^[[0m  CATEGORY: cross-gcc14+
 ^[[32m*^[[0m    CBUILD: x86_64-pc-linux-gnu
 ^[[32m*^[[0m     CHOST: x86_64-pc-linux-gnu
 ^[[32m*^[[0m   CTARGET: gcc14+
 ^[[32m*^[[0m    CFLAGS: -march=native -O3 -pipe -std=gnu17
 ^[[32m*^[[0m   LDFLAGS: -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--undefined-version

 * econf: updating binutils-2.42/config.sub with /usr/share/gnuconfig/config.sub
 * econf: updating binutils-2.42/config.guess with /usr/share/gnuconfig/config.guess
/var/tmp/portage/cross-gcc14+/binutils-2.42-r2/work/binutils-2.42/configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=gcc14+ --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --s>
configure: loading site script /usr/share/config.site
configure: loading site script /usr/share/config.site.d/80crossdev.conf
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... Invalid configuration 'gcc14+': machine 'gcc14+-unknown' not recognized
configure: error: /bin/sh /var/tmp/portage/cross-gcc14+/binutils-2.42-r2/work/binutils-2.42/config.sub gcc14+ failed

!!! Please attach the following file when seeking support:
!!! /var/tmp/portage/cross-gcc14+/binutils-2.42-r2/work/build/config.log
 ^[[31;01m*^[[0m ERROR: cross-gcc14+/binutils-2.42-r2::escpr2 failed (configure phase):
 ^[[31;01m*^[[0m   econf failed
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m Call stack:
 ^[[31;01m*^[[0m               ebuild.sh, line  136:  Called src_configure
 ^[[31;01m*^[[0m             environment, line 1815:  Called econf '--enable-plugins' '--without-included-gettext' '--with-system-zlib' '--build=x86_64-pc-linux-gnu' '--with-sysroot=/usr/gcc14+' '--enable-poison-system-directories' '-->
 ^[[31;01m*^[[0m        phase-helpers.sh, line  647:  Called __helpers_die 'econf failed'
 ^[[31;01m*^[[0m   isolated-functions.sh, line  112:  Called die
 ^[[31;01m*^[[0m The specific snippet of code:
 ^[[31;01m*^[[0m                die "$@"





Reproducible: Always




emerge --info
Portage 3.0.66.1 (python 3.12.7-final-0, default/linux/amd64/23.0/desktop/plasma, gcc-14, glibc-2.40-r5, 6.11.6-gentoo-x86_64 x86_64)
=================================================================
System uname: Linux-6.11.6-gentoo-x86_64-x86_64-AMD_Ryzen_9_3900X_12-Core_Processor-with-glibc2.40
KiB Mem:    32792468 total,  15808008 free
KiB Swap:   31249404 total,  29989884 free
Timestamp of repository gentoo: Fri, 29 Nov 2024 03:00:00 +0000
Head commit of repository gentoo: abeee5fedd10e3af2bc45ec6f84be9896889671c
Timestamp of repository escpr2: Thu, 31 Oct 2024 18:34:26 +0000
Head commit of repository escpr2: f2c923b8c651f1d14744975f879c2c78f6e5f8f9

sh bash 5.2_p37
ld GNU ld (Gentoo 2.43 p3) 2.43.1
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.71-r7::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.17-r1::gentoo
dev-build/cmake:           3.31.1::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r100::gentoo
dev-build/meson:           1.6.0::gentoo
dev-java/java-config:      2.3.4::gentoo
dev-lang/perl:             5.40.0::gentoo
dev-lang/python:           3.12.7_p1::gentoo, 3.13.0::gentoo
dev-lang/rust-bin:         1.81.0-r100::gentoo, 1.82.0-r100::gentoo
sys-apps/baselayout:       2.17::gentoo
sys-apps/openrc:           0.55.1::gentoo
sys-apps/sandbox:          2.40::gentoo
sys-devel/binutils:        2.43-r2::gentoo
sys-devel/binutils-config: 5.5.2::gentoo
sys-devel/clang:           18.1.8-r6::gentoo
sys-devel/gcc:             13.3.1_p20241115::gentoo, 14.2.1_p20241116::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             18.1.8::gentoo, 19.1.4::gentoo
sys-devel/llvm:            18.1.8-r6::gentoo, 19.1.4::gentoo
sys-kernel/linux-headers:  6.11::gentoo (virtual/os-headers)
sys-libs/glibc:            2.40-r5::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-verify-max-age: 3
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes

escpr2
    location: /var/db/repos/escpr2
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/escpr2.git
    masters: gentoo
    volatile: False

Binary Repositories:

gentoobinhost
    priority: 9999
    sync-uri: https://distfiles.gentoo.org/releases/amd64/binpackages/23.0/x86-64

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE @BINARY-REDISTRIBUTABLE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O3 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=native -O3 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance binpkg-request-signature buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles getbinpkg ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O3 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="de_DE.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X a52 aac acl acpi activities alsa amd64 bluetooth branding bzip2 cairo cdda cdr cet contrib crypt cuda cudnn cups dbus declarative dri dts dvd dvdr dvi elogind encode eps exif fits flac fortran gdbm gdbui gif gnutls go gphoto2 gpm graphite gtk gui iconv icu ipv6 jit jpeg kde kf6compat kwallet lcms libcxx libnotify libtirpc llvm lm-sensors lto mad mng modules-sign mp3 mp4 mpeg multilib ncurses networkmanager nls nvenc objc objc++ offload ogg ompt opencv opengl openmp pam pango pcre pdf pipewire plasma png policykit postscript ppds pulseaudio qml qt5 qt6 raw readline rust screencast sdl seccomp semantic-desktop sound spell ssl startup-notification svg test-rust tiff tpm truetype udev udisks uefi unicode upower usb vorbis vulkan wayland wcs widgets wxwidgets x264 xattr xcb xft xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gcc_12" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 aes avx avx2 f16c fma3 pclmul popcnt rdrand sha sse3 sse4_1 sse4_2 sse4a ssse3" CURL_QUIC="ngtcp2" CURL_SSL="gnutls" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="libinput" KERNEL="linux" L10N="de" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres16" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Benjamin Schulz 2024-11-29 09:10:32 UTC
Created attachment 912586 [details]
build.log
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-29 09:11:49 UTC
That output doesn't match the target. The one you pasted in the other bug was right.
Comment 3 Benjamin Schulz 2024-11-29 09:25:11 UTC
yes you are right...  I'm generating a new log by emerging it with the right target again...
Comment 4 Benjamin Schulz 2024-11-29 09:28:31 UTC
Created attachment 912605 [details]
info.log
Comment 5 Benjamin Schulz 2024-11-29 09:30:55 UTC
Created attachment 912606 [details]
stage1 logfile in tar gz format
Comment 6 Benjamin Schulz 2024-11-29 09:31:25 UTC
Created attachment 912607 [details]
config.log in tar gz format
Comment 7 Benjamin Schulz 2024-11-29 09:32:16 UTC
* crossdev version:      20240921
 * Host Portage ARCH:     amd64
 * Host Portage System:   x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu)
 * Target Portage ARCH:   *
 * Target System:         nvptx
 * Stage:                 3 (C compiler & libc)
 * USE=multilib:          no
 * Target ABIs:           default

 * binutils:              nvptx-tools-[latest]
 * gcc:                   gcc-[latest]
 * headers:               linux-headers-[latest]
 * libc:                  newlib-[latest]

 * CROSSDEV_OVERLAY:      /var/db/repos/escpr2
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:    /
 * Portage flags:         
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  
 * leaving metadata/layout.conf alone in /var/db/repos/escpr2
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  
 * Log: /var/log/portage/cross-nvptx-nvptx-tools.log
 * Emerging cross-nvptx-tools ...                                                                                                                                            [ ok ]
 * Log: /var/log/portage/cross-nvptx-gcc-stage1.log
 * Emerging cross-gcc-stage1 ...

 * error: gcc failed :(
 * 
 * If you file a bug, please attach the following logfiles:
 * /var/log/portage/cross-nvptx-info.log
 * /var/log/portage/cross-nvptx-gcc-stage1.log.xz
 * /var/tmp/portage/cross-nvptx/gcc*/temp/gcc-config.logs.tar.xz
Comment 8 Benjamin Schulz 2024-11-29 10:33:00 UTC
Created attachment 912674 [details]
build.log
Comment 9 Benjamin Schulz 2024-11-29 10:33:29 UTC
So, I've found the build log now of this... it appears there were file collisions?.....
Comment 10 Benjamin Schulz 2024-11-29 10:43:03 UTC
the file collisions came from a previous install attempt. after removing them, it still fails, but at the gcc stage.
Comment 11 Benjamin Schulz 2024-11-29 10:43:45 UTC
Created attachment 912686 [details]
gcc-stage1- build log
Comment 12 Benjamin Schulz 2024-11-29 10:45:13 UTC

>> Source prepared.
>>> Configuring source in /var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/gcc-14-20241116 ...
 ^[[32m*^[[0m ADAFLAGS=""
 ^[[32m*^[[0m CFLAGS="-O2 -pipe"
 ^[[32m*^[[0m CPPFLAGS=" -D_GENTOO_TIME64_FORCE=0"
 ^[[32m*^[[0m CXXFLAGS="-O2 -pipe"
 ^[[32m*^[[0m CCASFLAGS=""
 ^[[32m*^[[0m FFLAGS="-O2 -pipe"
 ^[[32m*^[[0m FCFLAGS="-O2 -pipe"
 ^[[32m*^[[0m LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"

 ^[[32m*^[[0m PREFIX:          /usr
 ^[[32m*^[[0m BINPATH:         /usr/x86_64-pc-linux-gnu/nvptx-tools/gcc-bin/14
 ^[[32m*^[[0m LIBPATH:         /usr/lib/gcc/nvptx-tools/14
 ^[[32m*^[[0m DATAPATH:        /usr/share/gcc-data/nvptx-tools/14
 ^[[32m*^[[0m STDCXX_INCDIR:   /usr/lib/gcc/nvptx-tools/14/include/g++-v14
 ^[[32m*^[[0m Languages:       c,rust
 ^[[32m*^[[0m GCC version:     14.2.1

 ^[[32m*^[[0m /bin/sh /var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/gcc-14-20241116/configure --host=x86_64-pc-linux-gnu --target=nvptx-tools --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/nv>
configure: loading site script /usr/share/config.site
configure: loading site script /usr/share/config.site.d/80crossdev.conf
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... Invalid configuration 'nvptx-tools': OS 'tools' not recognized
configure: error: /bin/sh /var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/gcc-14-20241116/config.sub nvptx-tools failed
 ^[[31;01m*^[[0m ERROR: cross-nvptx-tools/gcc-14.2.1_p20241116::escpr2 failed (configure phase):
 ^[[31;01m*^[[0m   Failed to run command: /bin/sh /var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/gcc-14-20241116/configure --host=x86_64-pc-linux-gnu --target=nvptx-tools --build=x86_64-pc-linux-gnu --prefix=/usr --bindir>
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m Call stack:
 ^[[31;01m*^[[0m     ebuild.sh, line  136:  Called src_configure
 ^[[31;01m*^[[0m   environment, line 3602:  Called toolchain_src_configure
 ^[[31;01m*^[[0m   environment, line 5330:  Called edo '/bin/sh' '/var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/gcc-14-20241116/configure' '--host=x86_64-pc-linux-gnu' '--target=nvptx-tools' '--build=x86_64-pc-linux-gnu'>
 ^[[31;01m*^[[0m   environment, line 1609:  Called die
 ^[[31;01m*^[[0m The specific snippet of code:
 ^[[31;01m*^[[0m       "$@" || die -n "Failed to run command: $@"
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m If you need support, post the output of `emerge --info '=cross-nvptx-tools/gcc-14.2.1_p20241116::escpr2'`,
 ^[[31;01m*^[[0m the complete build log and the output of `emerge -pqv '=cross-nvptx-tools/gcc-14.2.1_p20241116::escpr2'`.
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m Please include /var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/gcc-build-logs.tar.xz in your bug report.
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m The complete build log is located at '/var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/temp/build.log'.
 ^[[31;01m*^[[0m The ebuild environment file is located at '/var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/temp/environment'.
 ^[[31;01m*^[[0m Working directory: '/var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/build'
 ^[[31;01m*^[[0m S: '/var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/work/gcc-14-20241116'

>>> Failed to emerge cross-nvptx-tools/gcc-14.2.1_p20241116, Log file:

>>>  '/var/tmp/portage/cross-nvptx-tools/gcc-14.2.1_p20241116/temp/build.log'
 * Messages for package cross-nvptx-tools/gcc-14.2.1_p20241116:
 * ERROR: cross-nvptx-tools/gcc-14.2.1_p20241116::escpr2 failed (configure
Comment 13 Benjamin Schulz 2024-11-29 10:56:32 UTC
hm, if i, after removing the file collisions, emerge the target nvptx instead of nvptx-tools, i get a more meaningful build report. But it also fails...
Comment 14 Benjamin Schulz 2024-11-29 11:05:05 UTC
Created attachment 912689 [details]
target nvptx gcc-stage1 build log
Comment 15 Benjamin Schulz 2024-11-29 11:07:54 UTC
checking host system type... nvptx-unknown-none
checking for --enable-version-specific-runtime-libs... no
checking for a BSD-compatible install... /usr/lib/portage/python3.12/ebuild-helpers/xattr/install -c
checking for gawk... gawk
checking for nvptx-ar... nvptx-ar
checking for nvptx-lipo... nvptx-lipo
checking for nvptx-nm... /var/tmp/portage/cross-nvptx/gcc-14.2.1_p20241116/work/build/./gcc/nm
checking for nvptx-ranlib... nvptx-ranlib
checking for nvptx-strip... nvptx-strip
checking whether ln -s works... yes
checking for nvptx-gcc... /var/tmp/portage/cross-nvptx/gcc-14.2.1_p20241116/work/build/./gcc/xgcc -B/var/tmp/portage/cross-nvptx/gcc-14.2.1_p20241116/work/build/./gcc/ -B/usr/nvptx/bin/ -B/usr/nvptx/lib/ -isystem /usr/nvptx/include -isystem /usr/nvptx/sys-include   
checking for suffix of object files... configure: error: in `/var/tmp/portage/cross-nvptx/gcc-14.2.1_p20241116/work/build/nvptx/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details
make[1]: *** [Makefile:12426: configure-target-libgcc] Error 1
make[1]: Leaving directory '/var/tmp/portage/cross-nvptx/gcc-14.2.1_p20241116/work/build'



I guess that seems to be the error, finally...
Comment 16 Benjamin Schulz 2024-11-29 20:12:12 UTC
hm, cross-nvptx/newlib also fails, in direct emerge.

If I follow this tutorial 
https://gcc.gnu.org/wiki/Offloading#How_to_build_an_offloading-enabled_GCC i would have to install newlib. 


nfiguring in nvptx/newlib
configure: creating cache ./config.cache
checking build system type... x86_64-pc-linux-gnu
checking host system type... nvptx-unknown-none
checking for a BSD-compatible install... /usr/lib/portage/python3.12/ebuild-helpers/xattr/install -c
checking whether build environment is sane... yes
checking for nvptx-strip... nvptx-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for nvptx-gcc... nvptx-cc -B/var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/build/nvptx/newlib/ -isystem /var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/build/nvptx/newlib/targ-include -isystem /var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/newlib-4.4.0.20231231/newlib/libc/include -B/var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/build/nvptx/libgloss/nvptx -L/var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/build/nvptx/libgloss/libnosys -L/var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/newlib-4.4.0.20231231/libgloss/nvptx   
checking whether we are cross compiling... yes
checking for suffix of object files... configure: error: in `/var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/build/nvptx/newlib':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details
make[1]: *** [Makefile:8448: configure-target-newlib] Error 1
make[1]: Leaving directory '/var/tmp/portage/cross-nvptx/newlib-4.4.0.20231231/work/build'
make[1]: *** Waiting for unfinished jobs.
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-29 21:59:35 UTC
Looking, but it may take a bit of time.
Comment 18 Larry the Git Cow gentoo-dev 2024-11-29 22:01:56 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7c053ac40241806d3cdb2e367368c8b66cda447e

commit 7c053ac40241806d3cdb2e367368c8b66cda447e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-29 21:59:46 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-29 21:59:46 +0000

    sys-devel/nvptx-tools: add 0_pre20240809
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/nvptx-tools/Manifest                     |  1 +
 .../nvptx-tools/nvptx-tools-0_pre20240809.ebuild   | 52 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)
Comment 19 Larry the Git Cow gentoo-dev 2024-11-30 02:08:25 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=f212c4740e1e16748d965bbd80155fcdfd4786a1

commit f212c4740e1e16748d965bbd80155fcdfd4786a1
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 02:06:58 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 02:08:20 +0000

    crossdev: nvptx target fixes
    
    * We don't need linux-headers
    * Set the same GMASK/GUSE as newlib (not sure how useful the multilib
    bit here is, mind)
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 10 ++++++++++
 1 file changed, 10 insertions(+)

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=ae9adb13dc23de2fb45a858ba7f18998fb238b62

commit ae9adb13dc23de2fb45a858ba7f18998fb238b62
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 02:06:18 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 02:08:20 +0000

    wrappers/emerge-wrapper: add nvptx*
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 wrappers/emerge-wrapper | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=2b44881a2d2defadcdcd30260f535b92458da9b5

commit 2b44881a2d2defadcdcd30260f535b92458da9b5
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 01:46:37 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 02:08:19 +0000

    crossdev: no SSP for nvptx
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 20 Larry the Git Cow gentoo-dev 2024-11-30 02:08:50 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2cfb62836bcd010f49e186bfa9679ea469e72b32

commit 2cfb62836bcd010f49e186bfa9679ea469e72b32
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 02:05:12 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 02:08:36 +0000

    toolchain.eclass: wire up nvptx more
    
    We need to handle nvptx* in CTARGET in a few more places so we propagate
    that we're using newlib (which is obviously right but also means we don't
    then fail when building libatomic b/c libg.a is missing).
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/toolchain.eclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 21 Larry the Git Cow gentoo-dev 2024-11-30 02:20:22 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=02fc58c7c363a44a3d8ba718935e83050fb26294

commit 02fc58c7c363a44a3d8ba718935e83050fb26294
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 02:19:48 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 02:19:48 +0000

    sys-devel/crossdev: add 20241130
    
    Michal Rostecki (4):
          crossdev: Use libunwind and libc++ in LLVM environments
          ci: Test crossdev in GitHub Actions
          ci: Run the container explicitly with `docker run`
          ci: Test more targets, move the testing logic to a script
    
    Sam James (4):
          crossdev: tweak GUSE_DISABLE*
          crossdev: no SSP for nvptx
          wrappers/emerge-wrapper: add nvptx*
          crossdev: nvptx target fixes
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/crossdev/Manifest                 |  1 +
 sys-devel/crossdev/crossdev-20241130.ebuild | 40 +++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
Comment 22 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 02:21:49 UTC Comment hidden (obsolete)
Comment 23 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 02:23:38 UTC Comment hidden (obsolete)
Comment 24 Larry the Git Cow gentoo-dev 2024-11-30 02:55:18 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=c272f335f8b0df15f724e9ee3e2289a9deddbd11

commit c272f335f8b0df15f724e9ee3e2289a9deddbd11
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 02:28:09 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 02:52:12 +0000

    crossdev: don't turn off openmp/fortran for nvptx
    
    openmp and fortran are rather useful for offloading.
    
    Not clear to me whether or not we can turn this on for newlib in general
    wrt bug #489798 and bug #589672.
    
    Bug: https://bugs.gentoo.org/489798
    Bug: https://bugs.gentoo.org/589672
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Comment 25 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 03:16:05 UTC
I am making some more changes I'm testing now. Please wait.
Comment 26 Larry the Git Cow gentoo-dev 2024-11-30 05:10:43 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6d9336278643e0ad9fc99cfd497d50c3a8f30319

commit 6d9336278643e0ad9fc99cfd497d50c3a8f30319
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 02:59:57 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 05:10:29 +0000

    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@gentoo.org>

 eclass/toolchain.eclass | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
Comment 27 Larry the Git Cow gentoo-dev 2024-11-30 05:10:44 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=5fcf21142c9bc90ecae60826e0a2e70357769666

commit 5fcf21142c9bc90ecae60826e0a2e70357769666
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 04:40:54 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 04:41:20 +0000

    crossdev: build openmp, fortran by default for nvptx
    
    Followup to c272f335f8b0df15f724e9ee3e2289a9deddbd11.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Comment 28 Larry the Git Cow gentoo-dev 2024-11-30 05:13:43 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4f1807da7cb79c43875db9aad2e5a6b558b341be

commit 4f1807da7cb79c43875db9aad2e5a6b558b341be
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 05:13:05 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 05:13:05 +0000

    sys-devel/crossdev: add 20241130.1
    
    Sam James (2):
          crossdev: don't turn off openmp/fortran for nvptx
          crossdev: build openmp, fortran by default for nvptx
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/crossdev/Manifest                   |  1 +
 sys-devel/crossdev/crossdev-20241130.1.ebuild | 40 +++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
Comment 29 Larry the Git Cow gentoo-dev 2024-11-30 10:18:30 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=2cef8f3d996277a8f44a49b7c220ab8ba2a9e435

commit 2cef8f3d996277a8f44a49b7c220ab8ba2a9e435
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 10:16:55 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 10:18:24 +0000

    crossdev: nvptx needs multilib
    
    See https://gcc.gnu.org/legacy-ml/gcc-help/2020-01/msg00106.html.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 30 Larry the Git Cow gentoo-dev 2024-11-30 10:38:14 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0e3008ddccb1bccfa7225fb20a9db7694d2752d9

commit 0e3008ddccb1bccfa7225fb20a9db7694d2752d9
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 10:21:26 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 10:37:38 +0000

    sys-libs/newlib: pass -Wa,--no-verify for nvptx
    
    nvptx-tools performs verification if CUDA is installed, otherwise it
    skips it. newlib fails to build with that veriifcation, so punt
    it for now.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-libs/newlib/newlib-4.4.0.20231231.ebuild | 24 ++++++++++++++++++++++++
 sys-libs/newlib/newlib-9999.ebuild           | 24 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
Comment 31 Larry the Git Cow gentoo-dev 2024-11-30 11:04:03 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=b2540825f96c83e449d9ffe74894a0cc173ae47e

commit b2540825f96c83e449d9ffe74894a0cc173ae47e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 11:01:26 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 11:03:22 +0000

    15.0.0: don't pass -fcf-protection for offload
    
    Well, actually, disable it.
    
    Bug: https://bugs.gentoo.org/945296
    Bug: https://gcc.gnu.org/PR114717
    Signed-off-by: Sam James <sam@gentoo.org>

 15.0.0/gentoo/26_all_enable-cet.patch | 2 +-
 15.0.0/gentoo/README.history          | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 32 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 11:11:55 UTC
I've spent the day on this and made some pretty good progress but there's more to be done. I'll work on it more tomorrow too.
Comment 33 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 11:13:56 UTC
Will let you know when it is ready to try.

Remaining things so far (may add more):
* Fix needing to add -fno-stack-protector
* Propagate CET patch fix once tested
* Figure out gomp_nvptx_main undefined reference issue (ask Alexander if get stuck as he seems to have implemented it)
Comment 34 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 11:14:18 UTC
(In reply to Sam James from comment #33)
> Will let you know when it is ready to try.
> 
> Remaining things so far (may add more):
> * Fix needing to add -fno-stack-protector
> * Propagate CET patch fix once tested
> * Figure out gomp_nvptx_main undefined reference issue (ask Alexander if get
> stuck as he seems to have implemented it)

* Properly test my gcc-config hack and commit it
Comment 35 Larry the Git Cow gentoo-dev 2024-11-30 11:30:13 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=d066fc8f8de408b4e8d9d12a93f19d60ec08e250

commit d066fc8f8de408b4e8d9d12a93f19d60ec08e250
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 11:29:18 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 11:29:58 +0000

    15.0.0: pass -fno-stack-protector for offloading
    
    --enable-default-ssp doesn't seem to cover this.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 15.0.0/gentoo/04_all_nossp-on-nostdlib.patch | 2 +-
 15.0.0/gentoo/README.history                 | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 36 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 11:32:01 UTC
(In reply to Sam James from comment #34)
> (In reply to Sam James from comment #33)
> > Will let you know when it is ready to try.
> > 
> > Remaining things so far (may add more):
> > * Fix needing to add -fno-stack-protector
> > * Propagate CET patch fix once tested
> > * Figure out gomp_nvptx_main undefined reference issue (ask Alexander if get
> > stuck as he seems to have implemented it)
> 
> * Properly test my gcc-config hack and commit it

* Figure out the libgomp.{spec,a} issue (possibly related to the undefined ref) where I need to move it
Comment 37 Larry the Git Cow gentoo-dev 2024-11-30 13:09:21 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=52a39b64a029c40995c6490a307f0c51e9897f2b

commit 52a39b64a029c40995c6490a307f0c51e9897f2b
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 12:49:09 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 13:09:02 +0000

    toolchain.eclass: move nvptx files to accel/ subdir
    
    This is what Fedora does and it seems to have fixed the issue I was having
    with needing to manually move libgomp.{a,spec} and then after that, getting
    undefined references to gomp_nvptx_main (which I assume is because the plugin
    wasn't being loaded).
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/toolchain.eclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Comment 38 Benjamin Schulz 2024-11-30 14:22:30 UTC
thanks for the help. I am not too well versed on these kinds of gentoo internals. Also, as I never have used offloading with gcc, i would need some instructions what to do, besides crosstev -t nvptx and then start gcc with 

-foffload=nvptx-none 

by the way, here is an interesting instruction how to configure gcc manually for nvidia offloading 

It has three pages and details all steps:

https://www.heise.de/hintergrund/Accelerator-Offloading-mit-GCC-3317330.html

I do not know if that would be helpful for devs creating install scripts which do these commands to build the offload compiler and these nvptx files...
Comment 39 Larry the Git Cow gentoo-dev 2024-11-30 14:36:37 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=407e8b720858c57c802614439242364d3cc630a3

commit 407e8b720858c57c802614439242364d3cc630a3
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 14:35:40 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 14:35:40 +0000

    toolchain.eclass: move more for nvptx
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/toolchain.eclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Comment 40 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 14:45:59 UTC
(In reply to Benjamin Schulz from comment #38)
> thanks for the help. I am not too well versed on these kinds of gentoo
> internals. Also, as I never have used offloading with gcc, i would need some
> instructions what to do, besides crosstev -t nvptx and then start gcc with 
> 

You're welcome! It's been fun and a learning experience for me too. Still figuring out some bits, but I did just get a "hello world"-style thing working :)

> https://www.heise.de/hintergrund/Accelerator-Offloading-mit-GCC-3317330.html
> 
> I do not know if that would be helpful for devs creating install scripts
> which do these commands to build the offload compiler and these nvptx
> files...

Thanks. I think it is useful because there's not that much documentation out there, so even little tidbits can help put pieces together.
Comment 41 Larry the Git Cow gentoo-dev 2024-11-30 14:49:42 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e1214306a0f10fff29dd052617a54489b2e88380

commit e1214306a0f10fff29dd052617a54489b2e88380
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-30 14:48:35 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-30 14:48:35 +0000

    sys-devel/crossdev: add 20241130.3
    
    Sam James (2):
          crossdev: nvptx needs multilib
          Makefile: fix tarball generation
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/crossdev/Manifest                   |  1 +
 sys-devel/crossdev/crossdev-20241130.3.ebuild | 40 +++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
Comment 42 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-30 14:51:56 UTC
Remaining issues:
* Fix needing to add -fno-stack-protector (my attempt doesn't *seem* to have worked, need to investigate)
* Properly test my gcc-config hack and commit it
* Fix compat w/ dash
* Propagate the gcc-patches changes to at least 14 once they're all settled

And of course, once this is all done, I may play with amd, although I may be a bit fed up by then :p
Comment 43 Benjamin Schulz 2024-12-01 01:15:38 UTC
By the way,

Many of these machine learning libraries that are on the market for python are, once you look into the code, quite horrible. For example, this is what tensorflow became after a rename: https://github.com/jax-ml/jax/issues

Here is the reason why numba is so fast:
https://github.com/numba/numba/issues/9730

So, given that state, one basically has to do everything by oneself. 

As a result, gpu offloading for gcc is a rather important feature, if one wants to do any computation. Just tell me when I can test anything. 

At the moment, on my system, it still does not work with the unmasked 9999 crossdev and nvptx packages, it seems.
Comment 44 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-01 01:33:17 UTC
Created attachment 912904 [details, diff]
gcc-config-bug945296-offloading.patch

(In reply to Benjamin Schulz from comment #43)

> As a result, gpu offloading for gcc is a rather important feature, if one
> wants to do any computation. Just tell me when I can test anything. 
> 

Yeah, I agree it's important. I'm actually quite surprised you're only the 2nd person to ask about it. The 1st person was about a year ago when I did that very initial wiring of nvptx-none (and hoped they would do some of the further work on it as they were interested in it). You're the 2nd. But I think a lot of people don't think to ask and just try something and then leave it, rather than let us know.

Just make sure to give me a tip when you make some money off it ;)

> At the moment, on my system, it still does not work with the unmasked 9999
> crossdev and nvptx packages, it seems.

You should be able to try it out if you do the following (make sure you follow the precise order):
1) Make sure you have latest crossdev and have run emerge --sync too to pick up eclass and ebuild changes
2) crossdev -C everything nvptx related
3) Patch sys-devel/gcc-config with the attached patch (it's not committed yet for a reason, it's a hack and I need to test it properly) and rebuild it:
4) Rebuild your regular GCC first (sys-devel/gcc:14 or whatever) to pick up the eclass changes to enable offloading detection
5) crossdev -t nvptx-none
6) git clone https://github.com/matthiasdiener/omptest && cd omptest, then edit the Makefile to add -foffload=nvptx-none to CXXFLAGS and FCFLAGS, then `make`

For me, step 6) shows my nvidia card being picked up now and it using it for offloading. If any step prior to 6) fails, please stop and tell me.

I still have some more patches to tidy up and commit like the gcc-config one, but that offloading example actually works for me now (I got to that point quite late yesterday/earlier).
Comment 45 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-01 01:38:49 UTC
Also, the GCC version that crossdev builds a toolchain for must match the compiler you'll be using. But by default both of those should be 14.
Comment 46 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-01 01:40:16 UTC
You might have to also add -fno-stack-protector in *FLAGS in the Makefile too for omptest, but if you get to that point, it's obvious (as it fails with some __stack_chk_fail undefined ref).
Comment 47 Benjamin Schulz 2024-12-01 18:36:30 UTC
I am currently rebuilding my gcc with offload patches from sam.

Its taking a bit of time since there is a cron job also working on my system...

Once an offload compiler is there, I can test it myself with a short c++ file. 

For the curious: here are enough examples for offloading.
https://enccs.github.io/openmp-gpu/target/

No need for a large omp target testing project project. a few short lines in a cpp file should make clear if it works.
Comment 48 Benjamin Schulz 2024-12-01 18:48:32 UTC
Created attachment 912998 [details]
warnings from gcc with gcc-config patch

recompiling gcc with emerge gcc worked but created the attached warnings below.

I am posting them because some mention a "payload" and I do not know if that has something to do with offloading 

now trying out crossdev -t nvptx-none
Comment 49 Benjamin Schulz 2024-12-01 18:56:30 UTC
crossdev -t nvptx-none
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 * crossdev version:      baba6164d1aa2fd4eee6b52ef10f70b999ee9393
 * Host Portage ARCH:     amd64
 * Host Portage System:   x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu)
 * Target Portage ARCH:   *
 * Target System:         nvptx-none
 * Stage:                 4 (C/C++ compiler)
 * USE=multilib:          yes
 * Target ABIs:           default

 * binutils:              nvptx-tools-[latest]
 * gcc:                   gcc-[latest]
 * libc:                  newlib-[latest]

 * CROSSDEV_OVERLAY:      /var/db/repos/escpr2
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:    /
 * Portage flags:         
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -
 * leaving metadata/layout.conf alone in /var/db/repos/escpr2
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -
!!! WARNING - Cannot auto-configure CHOST nvptx-none;
!!! You should edit /usr/nvptx-none/etc/portage/make.conf /usr/nvptx-none/etc/portage/profile/make.defaults /usr/nvptx-none/etc/portage/profile/use.force
!!! by hand to complete your configuration.
!!!  No ARCH is known for this target.
!!!  No KERNEL is known for this target.
 * Log: /var/log/portage/cross-nvptx-none-nvptx-tools.log
 * Emerging cross-nvptx-tools ...                                                                                                                                                               [ ok ]
 * Log: /var/log/portage/cross-nvptx-none-gcc-stage1.log
 * Emerging cross-gcc-stage1 ...                                                                                                                                                                [ ok ]
 * Log: /var/log/portage/cross-nvptx-none-newlib.log
 * Emerging cross-newlib ...                                                                                                                                                                    [ ok ]
 * Log: /var/log/portage/cross-nvptx-none-gcc-stage2.log
 * Emerging cross-gcc-stage2 ...

 * error: gcc failed :(
 * 
 * If you file a bug, please attach the following logfiles:
 * /var/log/portage/cross-nvptx-none-info.log
 * /var/log/portage/cross-nvptx-none-gcc-stage2.log.xz
 * /var/tmp/portage/cross-nvptx-none/gcc*/temp/gcc-config.logs.tar.xz
localhost /home/benni #
Comment 50 Benjamin Schulz 2024-12-01 19:01:24 UTC
Created attachment 912999 [details]
logfile in tar gz format
Comment 51 Benjamin Schulz 2024-12-01 19:01:49 UTC
Created attachment 913000 [details]
logfile
Comment 52 Benjamin Schulz 2024-12-01 19:10:23 UTC
Created attachment 913001 [details]
more logfiles
Comment 53 Benjamin Schulz 2024-12-01 19:11:23 UTC
Did I something wrong? it seems stage2 of the cross build failed.
That is at least better than before, where it failed at stage 1....
Comment 54 Benjamin Schulz 2024-12-01 19:14:38 UTC
this here seems to be the problem:


none/gcc-14.2.1_p20241116/work/build/nvptx-none/libstdc++-v3/libsupc++/.libs -B/usr/nvptx-none/bin/ -B/usr/nvptx-none/lib/ -isystem /usr/nvptx-none/include -isystem /usr/nvptx-none/sys-include    linker (/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build/./gcc/collect-ld) supports shared libraries... no
libtool.m4: error: problem compiling CXX test program

checking for /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build/./gcc/xg++ -B/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build/./gcc/ -nostdinc++ -funconfigured-libstdc++-v3 -L/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build/nvptx-none/libstdc++-v3/src -L/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build/nvptx-none/libstdc++-v3/src/.libs -L/var/tmp/portage/cross-nvptx-none/gcc-14.2.
Comment 55 Benjamin Schulz 2024-12-01 19:15:38 UTC
and this one



configure: error: "libffi has not been ported to nvptx-unknown-none."
make[1]: *** [Makefile:15559: configure-target-libffi] Error 1
make[1]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build'



make[1]: *** Waiting for unfinished jobs....
make[1]: Entering directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build'
Checking multilib configuration for libatomic...
mkdir -p -- nvptx-none/libatomic
Comment 56 Benjamin Schulz 2024-12-01 19:23:03 UTC
these here were the useflags for my original re emerged gcc

 sys-devel/gcc-14.2.1_p20241116:14::gentoo  USE="cet (cxx) (default-stack-clash-protection) (default-znow) fortran go graphite jit lto (multilib) nls objc objc++ openmp (pie) rust sanitize ssp zstd -ada (-custom-cflags) -d -debug -doc (-fixed-point) -hardened (-ieee-long-double) (-libssp) -modula2 -objc-gc (-pch) -pgo -systemtap -test (-time64) -valgrind -vanilla -vtv" 0 KiB



emerge --info
Portage 3.0.66.1 (python 3.12.7-final-0, default/linux/amd64/23.0/desktop/plasma, gcc-14, glibc-2.40-r5, 6.11.6-gentoo-x86_64 x86_64)
=================================================================
System uname: Linux-6.11.6-gentoo-x86_64-x86_64-AMD_Ryzen_9_3900X_12-Core_Processor-with-glibc2.40
KiB Mem:    32792460 total,  22229424 free
KiB Swap:   31249404 total,  29974780 free
Timestamp of repository gentoo: Sun, 01 Dec 2024 17:00:00 +0000
Head commit of repository gentoo: dc16a37cb65e40fc1e900ec2c27b1dfd14ee6e02
Timestamp of repository escpr2: Thu, 31 Oct 2024 18:34:26 +0000
Head commit of repository escpr2: f2c923b8c651f1d14744975f879c2c78f6e5f8f9

sh bash 5.2_p37
ld GNU ld (Gentoo 2.43 p3) 2.43.1
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.71-r7::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.17-r1::gentoo
dev-build/cmake:           3.31.1::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r100::gentoo
dev-build/meson:           1.6.0::gentoo
dev-java/java-config:      2.3.4::gentoo
dev-lang/perl:             5.40.0::gentoo
dev-lang/python:           3.12.7_p1::gentoo, 3.13.0::gentoo
dev-lang/rust-bin:         1.81.0-r100::gentoo, 1.82.0-r100::gentoo, 1.83.0::gentoo
sys-apps/baselayout:       2.17::gentoo
sys-apps/openrc:           0.55.1::gentoo
sys-apps/sandbox:          2.40::gentoo
sys-devel/binutils:        2.43-r2::gentoo
sys-devel/binutils-config: 5.5.2::gentoo
sys-devel/clang:           18.1.8-r6::gentoo, 19.1.4::gentoo
sys-devel/gcc:             13.3.1_p20241115::gentoo, 14.2.1_p20241116::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             18.1.8::gentoo, 19.1.4::gentoo
sys-devel/llvm:            18.1.8-r6::gentoo, 19.1.4::gentoo
sys-kernel/linux-headers:  6.11::gentoo (virtual/os-headers)
sys-libs/glibc:            2.40-r5::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 3
    sync-rsync-verify-metamanifest: yes

escpr2
    location: /var/db/repos/escpr2
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/escpr2.git
    masters: gentoo
    volatile: False

Binary Repositories:

gentoobinhost
    priority: 9999
    sync-uri: https://distfiles.gentoo.org/releases/amd64/binpackages/23.0/x86-64

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE @BINARY-REDISTRIBUTABLE NVIDIA-CUDA NVIDIA EPSON-EULA NVIDIA-cuDNN google-chrome all-rights-reserved android"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O3 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=native -O3 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance binpkg-request-signature buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles getbinpkg ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O3 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="de_DE.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X a52 aac acl acpi activities alsa amd64 bluetooth branding bzip2 cairo cdda cdr cet contrib crypt cuda cudnn cups dbus declarative dri dts dvd dvdr dvi elogind encode eps exif fits flac fortran gdbm gdbui gif gnutls go gphoto2 gpm graphite gtk gui iconv icu ipv6 jit jpeg kde kf6compat kwallet lcms libnotify libtirpc lm-sensors lto mad mng modules-sign mp3 mp4 mpeg multilib ncurses networkmanager nls nvenc objc objc++ offload ogg ompt opencv opengl openmp pam pango pcre pdf pipewire plasma png policykit postscript ppds pulseaudio qml qt5 qt6 raw readline rust screencast sdl seccomp semantic-desktop sound spell ssl startup-notification svg test-rust tiff tpm truetype udev udisks uefi unicode upower usb vorbis vulkan wayland wcs widgets wxwidgets x264 xattr xcb xft xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gcc_12" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 aes avx avx2 f16c fma3 pclmul popcnt rdrand sha sse3 sse4_1 sse4_2 sse4a ssse3" CURL_QUIC="ngtcp2" CURL_SSL="gnutls" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="libinput" KERNEL="linux" L10N="de" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres16" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 57 Benjamin Schulz 2024-12-01 21:29:38 UTC
Hi, it appears here is the solution for this:
(yes, I have go in my host compiler)....
(hm, because go has native parallelism, it would be ideal for gpu, but it is sad that this is what it creates... I will now use the flat -go and then see...

https://gcc.gnu.org/legacy-ml/gcc/2018-03/msg00122.html

> configure: error: "libffi has not been ported to nvptx-unknown-none."
> [...]

Right, such things are not supported for a "--target=nvptx" compiler.

But, if your desire is to just enable additional languages, without
offloading support for them (which doesn't exist, as discussed in my
other email), then the solution is to just specify them in
"--enable-languages" for your "gcc-8.0.0_host_build" (host compiler) but
not for your "gcc-8.0.0_build" (nvptx offloading compiler), keeping the
latter at "--enable-languages=c,c++,fortran,lto".
Comment 58 Benjamin Schulz 2024-12-01 21:42:47 UTC
USE="-go" crossdev -t nvptx-none

finished without error. 

This is a bit of a, well, annoying problem, since the only way this then would work regularly, is if one would put the useflag -go  in a config file for the offload compiler, but then the gentoo dev teams would have to periodically check whether this is still valid.

I will now test some code.

Lets see....
Comment 59 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-01 22:40:20 UTC
Go doesn't support OpenMP AFAIK. I'll fix that issue when I've woken up a bit.
Comment 60 Benjamin Schulz 2024-12-01 22:49:19 UTC
Hi, I am afraid that it won't compile your said test set with the modified make.



nvptx mkoffload: severe error: posix_spawnp: File or directory not found.
Compilation stopped.
lto-wrapper: severe error: /usr/libexec/gcc/x86_64-pc-linux-gnu/14//accel/nvptx-none/mkoffload returned status 1
compilation ended.
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned status 1 
make: *** [Makefile:28: testomp] error 1
Comment 61 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-01 22:51:01 UTC
(In reply to Benjamin Schulz from comment #60)

Are you sure you applied the gcc-config patch too?
Comment 62 Benjamin Schulz 2024-12-01 22:58:31 UTC
I tried to compile it with USE="-go -lto" crossdev -t but that did not work too apparently...

So, since link time optimization is a good thing, i turned it back on, removed the cross compiler and emerged it again with crossdev and USE="-go" but well i guess there is some problem still...

this is my nvidia-drivers
[ebuild   R    ] x11-drivers/nvidia-drivers-565.57.01-r3:0/565::gentoo  USE="X modules modules-sign static-libs strip tools wayland -dist-kernel -kernel-open -modules-compress -persistenced -powerd" ABI_X86="(64) -32" 0 KiB


this is my cuda

dev-util/nvidia-cuda-toolkit-12.4.1:0/12.4.1::gentoo  USE="debugger examples nsight profiler rdma sanitizer vis-profiler" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB

WARNING: One or more updates/rebuilds have been skipped due to a dependency conflict:

dev-util/nvidia-cuda-toolkit:0

  (dev-util/nvidia-cuda-toolkit-12.6.1:0/12.6.1::gentoo, ebuild scheduled for merge) USE="debugger examples nsight profiler rdma sanitizer vis-profiler" ABI_X86="(64)" conflicts with
    <dev-util/nvidia-cuda-toolkit-12.5:=[profiler] required by (sci-libs/caffe2-2.5.1-r3:0/0::gentoo, installed) USE="cuda numpy openmp -distributed -fbgemm -flash -gloo -mkl -mpi -nnpack -onednn -openblas -opencl -qnnpack -rocm -xnnpack" ABI_X86="(64)" AMDGPU_TARGETS="gfx1030 gfx1100 gfx906 gfx908 gfx90a gfx942 -gfx1010 -gfx1011 -gfx1012 -gfx1031 -gfx1101 -gfx1102 -gfx803 -gfx900 -gfx940 -gfx941" PYTHON_SINGLE_TARGET="python3_12 -python3_10 -python3_11"
    ^                             ^^^^            
    <dev-util/nvidia-cuda-toolkit-12.5:0/12.4.1=[profiler] required by (sci-libs/caffe2-2.5.1-r3:0/0::gentoo, installed) USE="cuda numpy openmp -distributed -fbgemm -flash -gloo -mkl -mpi -nnpack -onednn -openblas -opencl -qnnpack -rocm -xnnpack" ABI_X86="(64)" AMDGPU_TARGETS="gfx1030 gfx1100 gfx906 gfx908 gfx90a gfx942 -gfx1010 -gfx1011 -gfx1012 -gfx1031 -gfx1101 -gfx1102 -gfx803 -gfx900 -gfx940 -gfx941" PYTHON_SINGLE_TARGET="python3_12 -python3_10 -python3_11"
    ^                             ^^^^^^^^^^^^^^          

Sun Dec  1 23:53:35 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.57.01              Driver Version: 565.57.01      CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce GTX 1660 ...    Off |   00000000:2D:00.0  On |                  N/A |
| 31%   40C    P8              7W /  125W |     548MiB /   6144MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
Comment 63 Benjamin Schulz 2024-12-01 23:00:18 UTC
Hi i have put the gcc patch into the /etc/portage/patches/sys-devel/gcc-config/ folder as a file named gcc-config.patch.

then I typed emerge gcc....
Comment 64 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-01 23:02:29 UTC
(In reply to Benjamin Schulz from comment #63)
> Hi i have put the gcc patch into the
> /etc/portage/patches/sys-devel/gcc-config/ folder as a file named
> gcc-config.patch.
> 
> then I typed emerge gcc....

Yes, you have to re-emerge _gcc-config_ first, not _gcc_, that is emerge -v1 sys-devel/gcc-config first.
Comment 65 Benjamin Schulz 2024-12-01 23:03:08 UTC
ah clearly, perhaps i forgot to emerge gcc-config first...
Comment 66 Larry the Git Cow gentoo-dev 2024-12-01 23:05:38 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=9e258378b3b596b14130a8538fc37193e3abd5e1

commit 9e258378b3b596b14130a8538fc37193e3abd5e1
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-01 23:04:50 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-01 23:04:50 +0000

    crossdev: nvptx: disable irrelevant languages and force necessary ones on
    
    Link: https://gcc.gnu.org/legacy-ml/gcc/2018-03/msg00122.html
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Comment 67 Benjamin Schulz 2024-12-02 00:47:09 UTC
hi i now have typed 

emerge gcc-config, 

then 

emerge gcc, 

then 

crossdev -C nvptx-none 

in order to de-install it, then 

USE="-go" crossdev -t nvptx-none.

when i write a simple codefile, i get

 g++ -O0 -fopenmp -foffload=nvptx-none -fno-stack-protector ./main.cpp 

still the same errors...


nvptx mkoffload: schwerwiegender Fehler: posix_spawnp: Datei oder Verzeichnis nicht gefunden
Kompilierung beendet.

schwerwiegender Fehler: /usr/libexec/gcc/x86_64-pc-linux-gnu/14//accel/nvptx-none/mkoffload gab Ende-Status 1 zurück
Kompilierung beendet.
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed


I suspect that code should be correct.

https://enccs.github.io/openmp-gpu/target/

/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#define NX 102400

int main(void)
{
  double vecA[NX],vecB[NX],vecC[NX];
  double r=0.2;

/* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
     vecA[i] = pow(r, i);
     vecB[i] = 1.0;
  }

/* dot product of two vectors */
  #pragma omp target
  for (int i = 0; i < NX; i++) {
     vecC[i] = vecA[i] * vecB[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += vecC[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}


when I type eselect gcc and select the cross compiler, i get:

home/benni/projects/openmptestnew/openmpoffloatest # eselect gcc set 1
 * Switching cross-compiler to nvptx-none-14 ...
 * insanity with nvptx-none-x86_64-pc-linux-gnu-accel-nvptx-none-gcc and //usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-x86_64-pc-linux-gnu-accel-nvptx-none-gcc
 * insanity with nvptx-none-x86_64-pc-linux-gnu-accel-nvptx-none-lto-dump and //usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-x86_64-pc-linux-gnu-accel-nvptx-none-lto-dump 

so it looks the patch has been installed?
Comment 68 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 00:49:33 UTC
The "insanity" error is exactly the one the patch is supposed to fix, it worked for me but msg e it's incomplete (of course that's part of why I haven't committed it yet).
Comment 69 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 00:51:50 UTC
(In reply to Sam James from comment #68)
> The "insanity" error is exactly the one the patch is supposed to fix, it
> worked for me but msg e it's incomplete (of course that's part of why I
> haven't committed it yet).

s/msg e/maybe/
Comment 70 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 00:52:33 UTC
If you are absolutely sure the patch was applied to gcc-config, please try as a workaround manually creating a symlink: /usr/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/x86_64-pc-linux-gnu-accel-nvptx-none-gcc.
Comment 71 Benjamin Schulz 2024-12-02 00:59:04 UTC
well at least,  my

nano -w /etc/portage/patches/sys-devel/gcc-config/gcc-config.patch 

shows this here:

From 57ceb28b266b380411a5e2c84131b04539f8b414 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Sun, 1 Dec 2024 01:30:31 +0000
Subject: [PATCH] WIP: gcc-config: handle offload/accel compilers properly

Bug: https://bugs.gentoo.org/945296
Signed-off-by: Sam James <sam@gentoo.org>
---
 gcc-config | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc-config b/gcc-config
index 404ab29..c4cee31 100755
--- a/gcc-config
+++ b/gcc-config
@@ -318,7 +318,7 @@ update_wrappers() {
                x=${x%:*}
 
                if [[ ! -x ${ref} ]] ; then
-                       if is_cross_compiler ; then
+                       if is_cross_compiler && [[ ${ref} != *-accel-* ]] ; then
                                ewarn "insanity with ${x} and ${ref}"
                        else
                                # For native targets, the ref might not be
@@ -332,6 +332,7 @@ update_wrappers() {
                        # Delete stale native symlink.
                        rm -f "${EROOT}usr/bin/${x}"
                elif [[ -x ${ref} ]] ; then
+                       [[ ${x} == *-accel-* ]] && x="${x#${CTARGET}-}"
                        atomic_ln "${ref#${ROOT}}" "${EROOT}usr/bin" "${x}"
                else
                        # Make sure we have no stale wrappers


Previously, if such a patch was in that directory, then it got applied. I re-emerged gcc-config and i re-emerged gcc-14 with this patch in it.
Comment 72 Benjamin Schulz 2024-12-02 01:03:08 UTC
that symlink, ln -s tells me, file already exists...
Comment 73 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 01:05:31 UTC
We're close, I promise!

Can you share (not as a comment, attached) output of: strace -f g++ -O0 -fopenmp -foffload=nvptx-none -fno-stack-protector ./main.cpp

I want to see what paths it's trying
Comment 74 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 01:05:56 UTC
ls -hal /usr/bin/*nvptx* too
Comment 75 Benjamin Schulz 2024-12-02 01:08:57 UTC
removing the file and then symlinking, the result is still the same, saying lto-wrapper failed...

i remember, recently there was an update to either nvidia-drivers or cuda... i remember a case where they had to be both recent before one can use cuda... Currently, I have not installed the most recent cuda because other packages need the previous version. Perhaps its that?
Comment 76 Benjamin Schulz 2024-12-02 01:13:13 UTC
ls -hal /usr/bin/*nvptx*
lrwxrwxrwx 1 root root  12 29. Nov 19:46 /usr/bin/emerge-nvptx-75 -> cross-emerge
lrwxrwxrwx 1 root root  12  2. Dez 01:22 /usr/bin/emerge-nvptx-none -> cross-emerge
lrwxrwxrwx 1 root root  12 29. Nov 19:46 /usr/bin/nvptx-75-ebuild -> cross-ebuild
lrwxrwxrwx 1 root root  12 29. Nov 19:46 /usr/bin/nvptx-75-emerge -> cross-emerge
lrwxrwxrwx 1 root root  14 29. Nov 19:46 /usr/bin/nvptx-75-fix-root -> cross-fix-root
lrwxrwxrwx 1 root root  16 29. Nov 19:46 /usr/bin/nvptx-75-pkg-config -> cross-pkg-config
lrwxrwxrwx 1 root root  11  2. Dez 01:13 /usr/bin/nvptx-none-ar -> /usr/bin/ar
-rwxr-xr-x 1 root root 55K  2. Dez 01:13 /usr/bin/nvptx-none-as
lrwxrwxrwx 1 root root  14  2. Dez 01:56 /usr/bin/nvptx-none-cc -> nvptx-none-gcc
lrwxrwxrwx 1 root root  61  2. Dez 01:17 /usr/bin/nvptx-none-cpp -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-cpp
lrwxrwxrwx 1 root root  12  2. Dez 01:22 /usr/bin/nvptx-none-ebuild -> cross-ebuild
lrwxrwxrwx 1 root root  12  2. Dez 01:22 /usr/bin/nvptx-none-emerge -> cross-emerge
lrwxrwxrwx 1 root root  14  2. Dez 01:22 /usr/bin/nvptx-none-fix-root -> cross-fix-root
lrwxrwxrwx 1 root root  61  2. Dez 01:17 /usr/bin/nvptx-none-gcc -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc
lrwxrwxrwx 1 root root  64  2. Dez 01:17 /usr/bin/nvptx-none-gcc-ar -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc-ar
lrwxrwxrwx 1 root root  64  2. Dez 01:17 /usr/bin/nvptx-none-gcc-nm -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc-nm
lrwxrwxrwx 1 root root  68  2. Dez 01:17 /usr/bin/nvptx-none-gcc-ranlib -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc-ranlib
lrwxrwxrwx 1 root root  63  2. Dez 01:17 /usr/bin/nvptx-none-gccrs -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gccrs
-rwxr-xr-x 1 root root 51K  2. Dez 01:13 /usr/bin/nvptx-none-ld
-rwxr-xr-x 1 root root 35K  2. Dez 01:13 /usr/bin/nvptx-none-nm
lrwxrwxrwx 1 root root  74  2. Dez 01:17 /usr/bin/nvptx-none-nvptx-none-gccrs -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-nvptx-none-gccrs
lrwxrwxrwx 1 root root  16  2. Dez 01:22 /usr/bin/nvptx-none-pkg-config -> cross-pkg-config
lrwxrwxrwx 1 root root  15  2. Dez 01:13 /usr/bin/nvptx-none-ranlib -> /usr/bin/ranlib
-rwxr-xr-x 1 root root 27K  2. Dez 01:13 /usr/bin/nvptx-none-run
lrwxrwxrwx 1 root root 100  2. Dez 01:56 /usr/bin/nvptx-none-x86_64-pc-linux-gnu-accel-nvptx-none-gccrs -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-x86_64-pc-linux-gnu-accel-nvptx-none-gccrs
Comment 77 Benjamin Schulz 2024-12-02 01:14:35 UTC
Created attachment 913013 [details]
logfile
Comment 78 Benjamin Schulz 2024-12-02 01:14:58 UTC
i have put the trace file into a log. its rather large...
Comment 79 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 01:15:52 UTC
I don't see x86_64-pc-linux-gnu-accel-nvptx-none-gcc as a symlink in your output...
Comment 80 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 01:21:50 UTC
For reference here is mine that works (ignore the 15, I've tested it with 14 too)

$ ls -hal /usr/bin/*nvptx*
lrwxrwxrwx 1 root root  12 Nov 30 13:30 /usr/bin/emerge-nvptx-none -> cross-emerge
lrwxrwxrwx 1 root root  11 Nov 30 13:31 /usr/bin/nvptx-none-ar -> /usr/bin/ar
-rwxr-xr-x 1 root root 51K Nov 30 13:31 /usr/bin/nvptx-none-as
lrwxrwxrwx 1 root root  14 Dec  1 16:31 /usr/bin/nvptx-none-cc -> nvptx-none-gcc
lrwxrwxrwx 1 root root  61 Nov 30 13:37 /usr/bin/nvptx-none-cpp -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-cpp
lrwxrwxrwx 1 root root  12 Nov 30 13:30 /usr/bin/nvptx-none-ebuild -> cross-ebuild
lrwxrwxrwx 1 root root  12 Nov 30 13:30 /usr/bin/nvptx-none-emerge -> cross-emerge
lrwxrwxrwx 1 root root  14 Nov 30 13:30 /usr/bin/nvptx-none-fix-root -> cross-fix-root
lrwxrwxrwx 1 root root  61 Nov 30 13:37 /usr/bin/nvptx-none-gcc -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc
lrwxrwxrwx 1 root root  64 Nov 30 13:37 /usr/bin/nvptx-none-gcc-ar -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc-ar
lrwxrwxrwx 1 root root  64 Nov 30 13:37 /usr/bin/nvptx-none-gcc-nm -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc-nm
lrwxrwxrwx 1 root root  68 Nov 30 13:37 /usr/bin/nvptx-none-gcc-ranlib -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/14/nvptx-none-gcc-ranlib
-rwxr-xr-x 1 root root 47K Nov 30 13:31 /usr/bin/nvptx-none-ld
-rwxr-xr-x 1 root root 31K Nov 30 13:31 /usr/bin/nvptx-none-nm
lrwxrwxrwx 1 root root  16 Nov 30 13:30 /usr/bin/nvptx-none-pkg-config -> cross-pkg-config
lrwxrwxrwx 1 root root  15 Nov 30 13:31 /usr/bin/nvptx-none-ranlib -> /usr/bin/ranlib
-rwxr-xr-x 1 root root 19K Nov 30 13:31 /usr/bin/nvptx-none-run
lrwxrwxrwx 1 root root  87 Dec  1 16:31 /usr/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/15/x86_64-pc-linux-gnu-accel-nvptx-none-gcc
lrwxrwxrwx 1 root root  92 Dec  1 16:31 /usr/bin/x86_64-pc-linux-gnu-accel-nvptx-none-lto-dump -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/15/x86_64-pc-linux-gnu-accel-nvptx-none-lto-dump

$ ls -hal /usr/bin/*accel*
lrwxrwxrwx 1 root root 87 Dec  1 16:31 /usr/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/15/x86_64-pc-linux-gnu-accel-nvptx-none-gcc
lrwxrwxrwx 1 root root 92 Dec  1 16:31 /usr/bin/x86_64-pc-linux-gnu-accel-nvptx-none-lto-dump -> /usr/x86_64-pc-linux-gnu/nvptx-none/gcc-bin/15/x86_64-pc-linux-gnu-accel-nvptx-none-lto-dump
Comment 81 Benjamin Schulz 2024-12-02 02:52:05 UTC
Hi, i found the problem....

I had portage configured to use binary packages...

and so it installed gcc-config as a binary and steadfastly ignored your patch.

Now i installed it from source...

Will re-emerge gcc now...
Comment 82 Benjamin Schulz 2024-12-02 04:32:18 UTC
now its getting strange. i have run emerge gcc-config (with the patch)

this was its output:

emerge gcc-config

 * IMPORTANT: 28 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

Calculating dependencies... done!
Dependency resolution took 3.69 s (backtrack: 0/20).


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-devel/gcc-config-2.11::gentoo
 * gcc-config-2.11.tar.xz BLAKE2B SHA512 size ;-) ...                                                                                                                                          [ ok ]
>>> Unpacking source...
>>> Unpacking gcc-config-2.11.tar.xz to /var/tmp/portage/sys-devel/gcc-config-2.11/work
>>> Source unpacked in /var/tmp/portage/sys-devel/gcc-config-2.11/work
>>> Preparing source in /var/tmp/portage/sys-devel/gcc-config-2.11/work/gcc-config-2.11 ...
 * ===================================================================================================================================================================================================
 * Applying user patches from /etc/portage/patches ...
 * Applying gcc-config.patch ...                                                                                                                                                               [ ok ]
 * User patches applied.
 * ===================================================================================================================================================================================================
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sys-devel/gcc-config-2.11/work/gcc-config-2.11 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/sys-devel/gcc-config-2.11/work/gcc-config-2.11 ...
make -j24 PV=2.11 SUBLIBDIR=lib64 USE_CC_WRAPPERS=yes USE_NATIVE_LINKS=yes TOOLCHAIN_PREFIX=x86_64-pc-linux-gnu- 
sed \
        -e 's:@GENTOO_EPREFIX@::g' \
        -e 's:@GENTOO_LIBDIR@:lib64:g' \
        -e 's:@PV@:2.11:g' \
        -e 's:@USE_NATIVE_LINKS@:yes:g' \
        -e 's:@USE_CC_WRAPPERS@:yes:g' \
        gcc-config > .gcc-config
sed \
        -e '1s:/:/:' \
        -e 's:@PV@:2.11:g' \
        -e 's:@TOOLCHAIN_PREFIX@:x86_64-pc-linux-gnu-:g' \
        c89 > .c89
sed \
        -e '1s:/:/:' \
        -e 's:@PV@:2.11:g' \
        -e 's:@TOOLCHAIN_PREFIX@:x86_64-pc-linux-gnu-:g' \
        c99 > .c99
chmod a+rx .gcc-config
chmod a+rx .c89
chmod a+rx .c99
>>> Source compiled.
>>> Test phase [not enabled]: sys-devel/gcc-config-2.11

>>> Install sys-devel/gcc-config-2.11 into /var/tmp/portage/sys-devel/gcc-config-2.11/image
make -j24 PV=2.11 SUBLIBDIR=lib64 USE_CC_WRAPPERS=yes USE_NATIVE_LINKS=yes TOOLCHAIN_PREFIX=x86_64-pc-linux-gnu- DESTDIR=/var/tmp/portage/sys-devel/gcc-config-2.11/image install 
mkdir -p -m 755 /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/bin /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/share/eselect/modules /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/share/gcc-config /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/share/doc/gcc-config-2.11
install -m 755 .gcc-config /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/bin/gcc-config
install -m 755 .c89 /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/share/gcc-config/c89
install -m 755 .c99 /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/share/gcc-config/c99
if [ "yes" = yes ] ; then \
        install -m 755 .c89 /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/bin/c89 && \
        install -m 755 .c99 /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/bin/c99 ;  \
fi
install -m 644 gcc.eselect /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/share/eselect/modules
install -m 644 README /var/tmp/portage/sys-devel/gcc-config-2.11/image/usr/share/doc/gcc-config-2.11
>>> Completed installing sys-devel/gcc-config-2.11 into /var/tmp/portage/sys-devel/gcc-config-2.11/image

 * Final size of build directory: 736 KiB
 * Final size of installed tree:   96 KiB

 and I saw it getting in. 

I ran 

emerge gcc,

which installed gcc from source.

Afterwards, I ran
 
emerge --sync;

emerge crossdev; 

crossdev -C nvptx-none;

USE="-go" crossdev -t nvptx...

 and now gcc fails to emerge at stage 1 again

crossdev -t nvptx-none
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 * crossdev version:      9e258378b3b596b14130a8538fc37193e3abd5e1
 * Host Portage ARCH:     amd64
 * Host Portage System:   x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu)
 * Target Portage ARCH:   *
 * Target System:         nvptx-none
 * Stage:                 4 (C/C++ compiler)
 * USE=multilib:          yes
 * Target ABIs:           default

 * binutils:              nvptx-tools-[latest]
 * gcc:                   gcc-[latest]
 * libc:                  newlib-[latest]

 * CROSSDEV_OVERLAY:      /var/db/repos/escpr2
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:    /
 * Portage flags:         
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -
 * leaving sys-libs/newlib in /var/db/repos/escpr2
 * leaving sys-devel/nvptx-tools in /var/db/repos/escpr2
 * leaving sys-devel/gcc in /var/db/repos/escpr2
 * leaving dev-debug/gdb in /var/db/repos/escpr2
 * leaving metadata/layout.conf alone in /var/db/repos/escpr2
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -
 * Log: /var/log/portage/cross-nvptx-none-nvptx-tools.log
 * Emerging cross-nvptx-tools ...                                                                                                                                                               [ ok ]
 * Log: /var/log/portage/cross-nvptx-none-gcc-stage1.log
 * Emerging cross-gcc-stage1 ...

 * error: gcc failed :(
 * 
 * If you file a bug, please attach the following logfiles:
 * /var/log/portage/cross-nvptx-none-info.log
 * /var/log/portage/cross-nvptx-none-gcc-stage1.log.xz
 * /var/tmp/portage/cross-nvptx-none/gcc*/temp/gcc-config.logs.tar.xz
Comment 83 Benjamin Schulz 2024-12-02 04:34:31 UTC
Created attachment 913016 [details]
log 1
Comment 84 Benjamin Schulz 2024-12-02 04:35:08 UTC
Created attachment 913017 [details]
log2
Comment 85 Benjamin Schulz 2024-12-02 04:35:29 UTC
Created attachment 913018 [details]
log3
Comment 86 Benjamin Schulz 2024-12-02 04:40:01 UTC
ar/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/gcc-14-20241116/gcc/config/nvptx/nvptx.cc:325:12: warning: unquoted identifier or keyword ‘sm_’ in format [-Wformat-diag]
  325 |     error ("PTX version (%<-mptx%>) needs to be at least %s to support selected"
 

I have applied the patch, but did an emerge --sync and emerge crossdev before crosstev -t nvptx-none...
Comment 87 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 09:35:13 UTC
```
configure:3090: checking whether the C compiler works
configure:3112: /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build/./gcc/xgcc -B/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241116/work/build/./gcc/ -B/usr/nvptx-none/bin/ -B/usr/nvptx-none/lib/ -isystem /usr/nvptx-none/include -isystem /usr/nvptx-none/sys-include    -g -O2   conftest.c  >&5
error resolving libg.a
collect2: error: ld returned 1 exit status
```

Let's see.
Comment 88 Larry the Git Cow gentoo-dev 2024-12-02 09:42:57 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=075277041c223391b2c980d0e05989bfd1adee41

commit 075277041c223391b2c980d0e05989bfd1adee41
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-02 09:42:08 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-02 09:42:30 +0000

    crossdev: nvptx: don't force on openmp as it affects stage1 too
    
    Bug: https://bugs.gentoo.org/945296
    Fixes: 9e258378b3b596b14130a8538fc37193e3abd5e1
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 1 -
 1 file changed, 1 deletion(-)
Comment 89 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 09:43:58 UTC
Please try again after -C, emerge --sync, and emerge -v1 crossdev.
Comment 90 Benjamin Schulz 2024-12-02 13:57:26 UTC
Created attachment 913069 [details]
3 logfiles in tar.gz archive
Comment 91 Benjamin Schulz 2024-12-02 14:00:09 UTC
it still fails, after emerge --sync; emerge -v1 crossdev; crossdev -C nvptx-none; crossdev -t nvptx-none. I attached the logfiles...
Comment 92 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 14:06:41 UTC
(In reply to Benjamin Schulz from comment #91)
> it still fails, after emerge --sync; emerge -v1 crossdev; crossdev -C
> nvptx-none; crossdev -t nvptx-none. I attached the logfiles...

```
Calculating dependencies  
 * IMPORTANT: 28 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

.... done!
Dependency resolution took 1.75 s (backtrack: 0/20).


emerge: there are no ebuilds to satisfy "cross-nvptx-none/gcc".

emerge: searching for similar names...
emerge: Maybe you meant cross-nvptx-none/nvptx-tools?
```

Not sure what happened there? Maybe delete all the cross-* stuff from your escpr2 repo (it really shouldn't be writing there anyway), then emerge -vn eselect-repository && eselect repository create crossdev. crossdev should put that stuff in there then which is much better than a random repo where it might get clobbered on syncs.
Comment 93 Benjamin Schulz 2024-12-02 14:15:03 UTC
ah it seems there was just a typo
Comment 94 Benjamin Schulz 2024-12-02 15:18:01 UTC
now it compiled. However, I can still not start anything.


gcc -fopenmp -foffload=nvptx-none  ./main.cpp 

would complain about:

-fcf-protection=full

It would only accept none or check for that flag.

But then it would stop with this:

 gcc  -fopenmp -foffload=nvptx-none  -fcf-protection=check ./main.cpp 

lto1: severe error: the compiler does not support zstd-lto compression

According to gcc's documentation, I can set  -flto-compression-level=0 and that would mean no compression. But that flag should only be meaningful with -flto, which I did not supply.

Anyway, this

gcc  -fopenmp -foffload=nvptx-none  -fcf-protection=check -flto-compression-level=0 ./main.cpp 

and this:
gcc  -fopenmp -foffload=nvptx-none  -fcf-protection=check -flto-compression-level=0 ./main.cpp 

fail with the same error 
"the compiler does not support zstd-lto compression"



the code is this one:
/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#include "omp.h"
#define NX 102400

int main(void)
{
  double vecA[NX],vecB[NX],vecC[NX];
  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] = pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  #pragma omp target teams distribute parallel for
  for (int i = 0; i < NX; i++) {
    vecC[i] = vecA[i] * vecB[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += vecC[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}
Comment 95 Benjamin Schulz 2024-12-02 15:20:56 UTC
ae i meant this 

gcc  -flto -fopenmp -foffload=nvptx-none  -fcf-protection=check -flto-compression-level=0 ./main.cpp 

fails as well as this

gcc  -fopenmp -foffload=nvptx-none  -fcf-protection=check -flto-compression-level=0 ./main.cpp 

and this
gcc  -flto -fopenmp -foffload=nvptx-none  -fcf-protection=check ./main.cpp 

saying the compiler does not support lto compression
Comment 96 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 15:21:15 UTC
I'll handle the -fcf-protection issue along with the remaining TODOs later (as it has an easy workaround for now).

Can you show me:
emerge -pvO sys-devel/gcc:14 cross-nvptx-none/gcc:14 output
Comment 97 Benjamin Schulz 2024-12-02 15:24:39 UTC
my gcc flags are these:


 sys-devel/gcc-14.2.1_p20241116:14::gentoo  USE="cet (cxx) (default-stack-clash-protection) (default-znow) fortran go graphite jit lto (multilib) nls objc objc++ openmp (pie) rust sanitize ssp zstd -ada (-custom-cflags) -d -debug -doc (-fixed-point) -hardened (-ieee-long-double) (-libssp) -modula2 -objc-gc (-pch) -pgo -systemtap -test (-time64) -valgrind -vanilla -vtv" 0 KiB


[ebuild   R    ] cross-nvptx-none/gcc-14.2.1_p20241116:14::escpr2  USE="cxx fortran jit lto (multilib) nls openmp pie (-ada) (-cet) -custom-cflags (-d) -debug (-default-stack-clash-protection) -default-znow -doc -fixed-point (-go) (-graphite) (-hardened) -ieee-long-double -libssp (-modula2) -objc -objc++ -objc-gc (-pch) -pgo (-rust) -sanitize (-ssp) -systemtap -test (-time64) -valgrind -vanilla -vtv -zstd" 0 KiB


so there is zstd in there...
Comment 98 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 15:25:52 UTC
But not for the cross compiler! Please hold.
Comment 99 Larry the Git Cow gentoo-dev 2024-12-02 15:27:35 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=88d805301c5ca721d66d5102aa6ba2747cb2771e

commit 88d805301c5ca721d66d5102aa6ba2747cb2771e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-02 15:24:29 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-02 15:27:14 +0000

    crossdev: nvptx: enable zlib+zstd for LTO
    
    LTO is used behind-the-scenes between the host and offload to communicate
    data. We need to use the same compression for both. It's easiest if we just
    enable both supported compression formats in the offload compiler: zlib
    and zstd.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Comment 100 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 15:27:47 UTC
Try that (again from scratch, sorry).
Comment 101 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 15:31:31 UTC
> escpr2

I see you didn't take my advice yet wrt the other repo -- please do (see https://bugs.gentoo.org/945296#c92).
Comment 102 Benjamin Schulz 2024-12-02 17:43:22 UTC
Hi there, yes thanks for the tip.
i have put now crossdev in a separate repository...

Now it appears that with -fno-stack-protector and either -fcf-protection=none or -fcf-protection=check, i can compile some things. 

But it is still a bit strange, unfortunately, depending on the source-code.

For example, the following compiles and returns warnings:


gcc  -O3 -fopenmp -foffload=nvptx-none  -fcf-protection=none -fno-stack-protector ./main.cpp -lm


/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/ccYZZvVP.crtoffloadtable.o: warning: relocation against `__offload_vars_end' in read-only section `.rodata'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE

/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#include "omp.h"

#define NX 102400

int main(void)
{
  double vecA[NX],vecB[NX],vecC[NX];
  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] =pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  #pragma omp target teams distribute parallel for map(vecC) map(vecA,vecB)
  for (int i = 0; i < NX; i++) {
    vecC[i] = vecA[i] * vecB[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += vecC[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}


But does it really work on the graphics card? It seems so. Since it takes a bit long to start, which is typical for gpu offloading.

But now let us check that with the first example from
https://enccs.github.io/openmp-gpu/target/


/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include "omp.h"


int main()
{
    int num_devices = omp_get_num_devices();
    printf("Number of available devices %d\n", num_devices);

    #pragma omp target
    {
        if (omp_is_initial_device()) {
            printf("Running on host\n");
        } else {
            int nteams= omp_get_num_teams();
            int nthreads= omp_get_num_threads();
            printf("Running on device with %d teams in total and %d threads in each team\n",nteams,nthreads);
        }
    }
return 0;
}

gcc  -O3 -fopenmp -foffload=nvptx-none  -fcf-protection=check -fno-stack-protector ./main2.cpp -lm -lstdc++ 


unresolved symbol __printf_chk


collect2: Fehler: ld gab 1 als Ende-Status zurück
nvptx mkoffload: schwerwiegender Fehler: x86_64-pc-linux-gnu-accel-nvptx-none-gcc gab Ende-Status 1 zurück
Kompilierung beendet.


lto-wrapper: schwerwiegender Fehler: /usr/libexec/gcc/x86_64-pc-linux-gnu/14//accel/nvptx-none/mkoffload gab Ende-Status 1 zurück
Kompilierung beendet.
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: Fehler: ld gab 1 als Ende-Status zurück




Apparently, it has difficulties finding printf when running on the device. 
unresolved symbol __printf_chk
printf is in libc, I think. But I guess I've linked to libc.

Now lets say we want to use a function from math inside the loop on a device:

Modify the first example with this:
/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#include "omp.h"
#include "vector"
#define NX 102400
using namespace std;
int main(void)
{
  vector<double> vecA(NX),vecB(NX),vecC(NX);
  double r=0.2;


  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] =pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  double* A=vecA.data();
  double* B=vecB.data();
  double* C=vecC.data();

  #pragma omp target teams distribute parallel for map(A[0,NX]) map(B[0,NX],C[0,NX])
  for (int i = 0; i < NX; i++) {
    C[i] = (A[i]) * pow((B[i]),1.0);
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += C[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}


It compiles even.

But executing it, leads to 

libgomp: cuCtxSynchronize error: an illegal memory access was encountered

libgomp: cuMemFree_v2 error: an illegal memory access was encountered

libgomp: device finalization failed


I dont' know but without functions like sqrt, or pow... numerical programming gets a bit hard with just +,-,* and /
Comment 103 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 17:46:02 UTC
Yeah, for now, please do:
 -U_FORTIFY_SOURCE -fno-stack-protector -fcf-protection=none -Wl,-z,notext

These are the issues I was referring to earlier when I said I have to finish off some bits ;)

I know that some restrictions apply to what you can and can't do with operations but I have no idea of the specifics. That part at least isn't likely to be our fault.
Comment 104 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 17:53:13 UTC
I can reproduce that crash with sqrt. I will try have a look but no promises on that. Of course, if we find it works on another distro but not Gentoo, then that's obviously more pressing. Maybe you can try in a Docker container?
Comment 105 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 18:06:05 UTC
If I copy the example solution to Exercise 02 from https://enccs.github.io/openmp-gpu/target/, that works.

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97203.
Comment 106 Benjamin Schulz 2024-12-02 18:13:55 UTC
Hi apparently it may not be on our/gentoo's sind.

openacc has some function that can map std:: math functions to the device:

https://stackoverflow.com/questions/15330713/openacc-use-math-h-library

Openmp has something like declare target:

https://www.ibm.com/docs/de/xl-c-and-cpp-linux/16.1.1?topic=parallelization-pragma-omp-declare-target

perhaps one can or has to apply this not only with the simple struct with constructor, as in this example, but also to an stl math function?
Comment 107 Benjamin Schulz 2024-12-02 18:16:45 UTC
Yes, i know, simple examples, where a  pointer with a data range  is uploaded work..


Its a bit... well... is there some way, one can append 

#pragma omp declare target in front of stl math functions?
Comment 108 Benjamin Schulz 2024-12-02 18:21:36 UTC
here seems to be some solution?

https://stackoverflow.com/questions/49531448/openmp-gpu-offloading-math-library

Somebody has tried the same with the sqrt function and got help from ubuntu?
Comment 109 Benjamin Schulz 2024-12-02 18:36:37 UTC
ah now, it seems to be a problem when mapping pointers from vectors...

this one here seems to work

/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#define NX 102400

int main(void)
{
  double vecA[NX],vecB[NX],vecC[NX];
  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] = pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  #pragma omp target teams distribute parallel for
  for (int i = 0; i < NX; i++) {
    vecC[i] = sqrt(vecA[i]) * vecB[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += vecC[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}
Comment 110 Benjamin Schulz 2024-12-02 18:41:15 UTC
/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#define NX 102400
#include <vector>

int main(void)
{
  double vecA[NX],vecB[NX],vecC[NX];
  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] = pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  #pragma omp target teams distribute parallel for map (vecA,vecB,vecC)
  for (int i = 0; i < NX; i++) {
    vecC[i] = pow(vecA[i],2) * vecB[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += vecC[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}
Comment 111 Benjamin Schulz 2024-12-02 18:45:48 UTC
this here seems not to work:
/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#define NX 102400
#include <vector>
using namespace std;
int main(void)
{
  vector<double> vecA(NX);
  vector<double> vecB(NX);
  vector<double> vecC(NX);
  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] = pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  #pragma omp target teams distribute parallel for map (vecA,vecB,vecC)
  for (int i = 0; i < NX; i++) {
    vecC[i] = pow(vecA[i],2) * vecB[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += vecC[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}
Comment 112 Benjamin Schulz 2024-12-02 18:54:10 UTC
compiles, but does not work.


Vector.data() should have continuous memory.


/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#define NX 102400
#include <vector>
using namespace std;
int main(void)
{
  vector<double> vecA(NX);
  vector<double> vecB(NX);
  vector<double> vecC(NX);
  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] = pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  double *A=vecA.data();
  double *B=vecB.data();
  double *C=vecC.data();
  #pragma omp target teams distribute parallel for map (to: A[0,NX], B[0,NX]) map (from: C[0,NX])
  for (int i = 0; i < NX; i++) {
    vecC[i] = vecA[i] * vecB[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += vecC[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}
Comment 113 Benjamin Schulz 2024-12-02 18:58:20 UTC
sorry it should mean

C[i] = A[i] * B[i];

Compiles but creates: 

libgomp: cuCtxSynchronize error: an illegal memory access was encountered

libgomp: cuMemFree_v2 error: an illegal memory access was encountered

libgomp: device finalization failed

It does not copy that pointer to the device...

without openmp offload, the code compiles, and works of course. result should be 

The sum is: 1.250000 

/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#define NX 102400
#include <vector>
using namespace std;
int main(void)
{
  vector<double> vecA(NX);
  vector<double> vecB(NX);
  vector<double> vecC(NX);

  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vecA[i] = pow(r, i);
    vecB[i] = 1.0;
  }

  /* dot product of two vectors */
  double *A=vecA.data();
  double *B=vecB.data();
  double *C=vecC.data();
  #pragma omp target teams distribute parallel for map (A[0,NX],B[0,NX],C[0,NX])
  for (int i = 0; i < NX; i++) {
    C[i] = A[i] * B[i];
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += C[i];
  }
  printf("The sum is: %8.6f \n", sum);
  return 0;
}
Comment 114 Benjamin Schulz 2024-12-02 19:16:59 UTC
Apparently, it is not a problem of the stl.
This example also compiles but fails.

In my book "Using OpenMP, the next step", from van der Pas, Stotzer, Terboven, there are dozens of examples like that, e.g. on p. 274.


#include <stdio.h>
#include <math.h>
#define NX 102400
#include <vector>
using namespace std;
int main(void)
{
  double *A=(double*)malloc(sizeof(double)*NX);
  double *B=(double*)malloc(sizeof(double)*NX);
  double *C=(double*)malloc(sizeof(double)*NX);

  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    A[i] = pow(r, i);
    B[i] = 1.0;
  }

  /* dot product of two vectors */
  #pragma omp target map (to: A[0,NX], B[0,NX]) map (from: C[0,NX])
  {
  #pragma omp parallel for shared (A,B,C)
  for (int i = 0; i < NX; i++) {
    C[i] = A[i] * B[i];
  }
  }

  double sum = 0.0;
  /* calculate the sum */
  for (int i = 0; i < NX; i++) {
    sum += C[i];
  }
  printf("The sum is: %8.6f \n", sum);

  free(A);
  free(B);
  free(C);
  return 0;
}
Comment 115 Benjamin Schulz 2024-12-02 19:55:04 UTC
turns out that one needs to declare the array bounds in #pragma omp with a : and not a comma. This here works:

with these compile options:

gcc  -O3 -fopenmp -foffload=nvptx-none  -fcf-protection=none -fno-stack-protector    ./main.cpp -lm -lstdc++


with the following warnings:

/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/cc782zGt.crtoffloadtable.o: warning: relocation against `__offload_funcs_end' in read-only section `.rodata'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE


#include <stdio.h>
#include <math.h>
#define NX 102400
#include <vector>
#include "omp.h"
using namespace std;
int main(void)
{
  vector <double> vA(NX),vB(NX),vC(NX);

  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vA[i] = pow(r, i);
    vB[i] = 1.0;
  }

  /* dot product of two vectors */

  double*A=vA.data();
  double*B=vB.data();
  double *C=vC.data();
  #pragma omp target map (A[0:NX], B[0:NX], C[0:NX])
  {
  #pragma omp parallel for shared (A,B,C)
  for (int i = 0; i < NX; i++) {
    C[i] = A[i] * B[i];
  }
  }

  double sum = 0.0;
  /* calculate the sum */


  for (int i = 0; i < NX; i++) {
    sum += C[i];
  }
  printf("The sum is: %8.6f \n", sum);


  return 0;
}

this here works too, so one can access at least some stl math functions:

/* Copyright (c) 2019 CSC Training */
/* Copyright (c) 2021 ENCCS */
#include <stdio.h>
#include <math.h>
#define NX 102400
#include <vector>
#include "omp.h"
using namespace std;
int main(void)
{
  vector <double> vA(NX),vB(NX),vC(NX);

  double r=0.2;

  /* Initialization of vectors */
  for (int i = 0; i < NX; i++) {
    vA[i] = pow(r, i);
    vB[i] = 1.0;
  }

  /* dot product of two vectors */

  double*A=vA.data();
  double*B=vB.data();
  double *C=vC.data();
  #pragma omp target map (A[0:NX], B[0:NX], C[0:NX])
  {
  #pragma omp parallel for shared (A,B,C)
  for (int i = 0; i < NX; i++) {
    C[i] = sqrt(A[i]) * B[i];
  }
  }

  double sum = 0.0;
  /* calculate the sum */


  for (int i = 0; i < NX; i++) {
    sum += C[i];
  }
  printf("The sum is: %8.6f \n", sum);


  return 0;
}

Good that its finally ok.


Thank you for your help.

Best regards,
Benjamin

I would also like to test clang with this...
Comment 116 Larry the Git Cow gentoo-dev 2024-12-02 21:35:31 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=453e85f4bc2a567710f2d7659504fbdc76d0897e

commit 453e85f4bc2a567710f2d7659504fbdc76d0897e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-02 21:34:42 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-02 21:34:42 +0000

    sys-devel/crossdev: add 20241202
    
    Sam James (3):
          crossdev: nvptx: disable irrelevant languages and force necessary ones on
          crossdev: nvptx: don't force on openmp as it affects stage1 too
          crossdev: nvptx: enable zlib+zstd for LTO
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/crossdev/Manifest                 |  1 +
 sys-devel/crossdev/crossdev-20241202.ebuild | 40 +++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
Comment 117 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 21:35:40 UTC
> Thank you for your help.

You're very welcome!

> 
> I would also like to test clang with this...

Yeah, mgorny is still working on getting the changes landed, then will backport it, and we can go from there then.
Comment 118 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 21:46:15 UTC
(In reply to Sam James from comment #117)
> > Thank you for your help.
> 
> You're very welcome!
> 

I should also say: thank you for your prompt testing and feedback. I wouldn't have had the motivation to carry on without that.
Comment 119 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 21:50:27 UTC
OK, to recap for myself from https://bugs.gentoo.org/945296#c42 with some new bits...

TODO:
* Fix needing to add -fno-stack-protector (my attempt doesn't *seem* to have worked, need to investigate)
* Properly test my gcc-config hack and commit it
* Fix compat w/ dash
* Propagate the gcc-patches changes to at least 14 once they're all settled
* Fix F_S
* Fix cet still being added
* Do we need to backport the PIE patch from jakub or is -z,notext good enough for now (doubt and more awkward to implement, even)?
Comment 120 Benjamin Schulz 2024-12-02 23:34:22 UTC
Well, If needed, I can test more.

Currently, I am always getting this warning during compile:

/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/ccQdqLfV.crtoffloadtable.o: warning: relocation against `__offload_funcs_end' in read-only section `.rodata'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE


Which does not seem to affect the behavior at runtime.


What i noticed is that, well gcc is not checking the syntax correctly anymore. map(p[a,b]) makes no sense in OpenMP syntax, which requires map(p[a:b]. Yet gcc only complains during runtime. 

But that is a problem of gcc, but that is clearly something for upstream.
Comment 121 Benjamin Schulz 2024-12-02 23:38:00 UTC
and note: its not only   -fno-stack-protector . I need  
-fcf-protection=check or -fcf-protection=none.

With just -fno-stack-protector, i am getting errors like this:

nvptx mkoffload: Severe failure x86_64-pc-linux-gnu-accel-nvptx-none-gcc returned status 1.
Compilation ended.

lto-wrapper: Severe failure: /usr/libexec/gcc/x86_64-pc-linux-gnu/14//accel/nvptx-none/mkoffload returned status 1
Compilation ended
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned status 1
Comment 122 Benjamin Schulz 2024-12-02 23:51:02 UTC
when I add -no-pie, then the warnings disappear.

So, to recap, that is the full set of options which I need

-fcf-protection=none or -fcf-protection=check
-fno-stack-protector 
-no-pie
Comment 123 Benjamin Schulz 2024-12-03 00:24:34 UTC
Interestingly


 -fcf-protection=check

works. According to the documentation:

The value check is used for the final link with link-time optimization (LTO). An error is issued if LTO object files are compiled with different -fcf-protection values. The value check is ignored at the compile time.

It also works with -lto enabled. -lto affects optimization on several obj files.

I now wrote a small program which has two cpp files. I guess that should generate two obj files. it works with -lto and  -fcf-protection=check but perhaps that changes if a complicated and large external library is loaded?
Comment 124 Benjamin Schulz 2024-12-03 00:38:54 UTC
I can, by the way, not reproduce that gcc "bug" where somebody called a function inside a simd instruction:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97203

on my system:

 #pragma omp target map (A[0:NX], B[0:NX], C[0:NX])
  {
  #pragma omp simd
  for (int i = 0; i < NX; i++) {
    C[i] = __builtin_sinf(A[i]) * B[i];
  }
  }

works.

As well as calling an arbitrary own function... so I guess that bug could be closed in gcc...

It is interesting, since I did not know that. simd can be much faster than parallel for. Normally one would expect gcc to use simd on its own, by the way. But often it does not do that. stating explicitly #pragma omp simd can speed things up, even with -O3 used, at least on my system...
Comment 125 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-08 02:41:49 UTC
I'll hopefully get to the remaining TODOs of mine over the next week.
Comment 126 Larry the Git Cow gentoo-dev 2024-12-08 03:18:44 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=491f85516b7903a4893cbd2bd0a3dcf6a7423c93

commit 491f85516b7903a4893cbd2bd0a3dcf6a7423c93
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-01 01:30:31 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-08 03:16:40 +0000

    gcc-config: handle offload/accel compilers properly
    
    accel/offload compilers are named like 'x86_64-pc-linux-gnu-accel-nvptx-none-gcc'.
    
    When building the offload compiler, we'll have ${CHOST}-${CTARGET} where
    CHOST is the host and CTARGET is whatever the offload target is. gcc-config
    doesn't expect this 'double tuple'.
    
    e.g. when building nvptx-none, we'll have something like 'nvptx-none-x86_64-pc-linux-gnu-accel-nvptx-none-gcc'
    and we want to strip that to be just x86_64-pc-linux-gnu-accel-nvptx-none-gcc, as that's
    what we want symlinks to be made for in /usr/bin.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 gcc-config | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Comment 127 Larry the Git Cow gentoo-dev 2024-12-08 03:29:40 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4834ad1c39a6ca6f4012245cfef9d566dace69b6

commit 4834ad1c39a6ca6f4012245cfef9d566dace69b6
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-08 03:25:20 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-08 03:29:12 +0000

    sys-devel/gcc-config: add 2.12
    
    Berin Aniesh (1):
            README: Convert README from rST to markdown
    
    Sam James (5):
            README: grammar tweaks
            gcc-config: handle offload/accel compilers properly
            tests/run_tests: adapt to NO_COLOR
            .gitignore: ignore test temporary directories
            Makefile: README -> README.md
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/gcc-config/Manifest                 |  1 +
 sys-devel/gcc-config/gcc-config-2.12.1.ebuild | 60 +++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
Comment 128 Larry the Git Cow gentoo-dev 2024-12-10 05:07:49 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=35045208b613bd86d21415331da51d235ee5e6e7

commit 35045208b613bd86d21415331da51d235ee5e6e7
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 05:07:05 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 05:07:05 +0000

    15.0.0: add nvptx bashism patch
    
    Bug: https://gcc.gnu.org/PR117854
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 ...tx-fix-bashisms-with-gen-copyright.sh-use.patch | 68 ++++++++++++++++++++++
 15.0.0/gentoo/README.history                       |  1 +
 2 files changed, 69 insertions(+)
Comment 129 Larry the Git Cow gentoo-dev 2024-12-10 05:11:46 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=f41e17d0b106cc664c051f599c09ce696a3ab66d

commit f41e17d0b106cc664c051f599c09ce696a3ab66d
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 05:11:17 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 05:11:17 +0000

    15.0.0: update -fstack-clash-protection patch for offload
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 15.0.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch | 2 +-
 15.0.0/gentoo/README.history                                      | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 130 Larry the Git Cow gentoo-dev 2024-12-10 05:13:15 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=ec76a392e824bb1abe5f2d390d4bdbd96ee50040

commit ec76a392e824bb1abe5f2d390d4bdbd96ee50040
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 05:12:51 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 05:13:01 +0000

    15.0.0: update -D_GLIBCXX_ASSERTIONS patch for offload
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 15.0.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 131 Larry the Git Cow gentoo-dev 2024-12-10 05:19:21 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=95a0fb3364df529328991a746a47ea9bd3ef4e23

commit 95a0fb3364df529328991a746a47ea9bd3ef4e23
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 05:18:49 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 05:19:16 +0000

    15.0.0: update -fcf-protection patch for offload
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 15.0.0/gentoo/26_all_enable-cet.patch | 2 +-
 15.0.0/gentoo/README.history          | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 132 Larry the Git Cow gentoo-dev 2024-12-10 05:25:02 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=8883d5d098f3a0b981b04f455748bf13acfc1d32

commit 8883d5d098f3a0b981b04f455748bf13acfc1d32
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 05:24:33 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 05:24:33 +0000

    14.2.0: update patches for nvptx/accel
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 14.2.0/gentoo/04_all_nossp-on-nostdlib.patch                      | 5 +++--
 14.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch          | 2 +-
 14.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch | 2 +-
 14.2.0/gentoo/26_all_enable-cet.patch                             | 4 ++--
 14.2.0/gentoo/README.history                                      | 7 +++++++
 5 files changed, 14 insertions(+), 6 deletions(-)
Comment 133 Larry the Git Cow gentoo-dev 2024-12-10 05:28:35 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=8b7a28b5604dc83e14f114c97cc465d54c344e75

commit 8b7a28b5604dc83e14f114c97cc465d54c344e75
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 05:27:58 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 05:28:33 +0000

    14.2.0: add bashisms patch for nvptx too, cut patchset 6
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 ...tx-fix-bashisms-with-gen-copyright.sh-use.patch | 71 ++++++++++++++++++++++
 14.2.0/gentoo/README.history                       |  3 +-
 2 files changed, 73 insertions(+), 1 deletion(-)
Comment 134 Larry the Git Cow gentoo-dev 2024-12-10 05:30:48 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=97c1985c00e3dace87668528e3d3096ccdbb5304

commit 97c1985c00e3dace87668528e3d3096ccdbb5304
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 05:29:57 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 05:30:11 +0000

    sys-devel/gcc: avoid passing hardening flags for nvptx/offload for 14
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/gcc/Manifest                    | 1 +
 sys-devel/gcc/gcc-14.2.1_p20241207.ebuild | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 135 Larry the Git Cow gentoo-dev 2024-12-10 19:21:52 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8a15551bf82f745e3921931ae8843daf27f918df

commit 8a15551bf82f745e3921931ae8843daf27f918df
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-10 19:20:52 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-10 19:20:52 +0000

    sys-devel/gcc: C23 fixes and nvptx patch tweaks for 15
    
    Bug: https://bugs.gentoo.org/945296
    Closes: https://bugs.gentoo.org/944999
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/gcc/Manifest                         |  1 +
 sys-devel/gcc/gcc-15.0.0_pre20241208-r1.ebuild | 53 ++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
Comment 136 Larry the Git Cow gentoo-dev 2024-12-18 02:46:18 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b85da6096998aefba65d432607c12748efccc907

commit b85da6096998aefba65d432607c12748efccc907
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-18 02:45:05 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-18 02:45:05 +0000

    toolchain.eclass: handle nvptx multilib changes in 15
    
    GCC trunk recently changed its default multilib for nvptx. Make the
    `mv` there nonfatal with some comments added. We may want to enable
    all multilibs in future.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/toolchain.eclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Comment 137 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-18 02:50:05 UTC
Updated TODO:
* Fix needing to add -fno-stack-protector (**)
* Fix F_S (**)
* Fix cet still being added (**)
* Do we need to backport the PIE patch from jakub or is -z,notext good
  enough for now (doubt and more awkward to implement, even)?

(**) Partially done
Comment 138 Benjamin Schulz 2024-12-24 11:39:56 UTC
Created attachment 914813 [details]
log in txt form
Comment 139 Benjamin Schulz 2024-12-24 11:40:28 UTC
Created attachment 914814 [details]
stage 1 log.xz
Comment 140 Benjamin Schulz 2024-12-24 11:40:51 UTC
Created attachment 914815 [details]
gcc config logs
Comment 141 Benjamin Schulz 2024-12-24 11:43:18 UTC
make[2]: Entering directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
/bin/sh /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-opt.sh "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx" \
  > tmp-nvptx-gen.opt
make[2]: *** [/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/t-nvptx:28: s-nvptx-gen-opt] Error 1
make[2]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
make[2]: *** Waiting for unfinished jobs....
Comment 142 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-24 11:47:42 UTC
Huh. Can you run:
cd /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc && /bin/sh /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-opt.sh "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx" ; echo $?

and show the output?

If it's empty, please run:

cd /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc && /bin/bash -x /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-opt.sh "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx" ; echo $?
Comment 143 Benjamin Schulz 2024-12-24 12:03:02 UTC
cd /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc && /bin/sh /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-opt.sh "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx" ; echo $?
; -*- buffer-read-only: t -*-
; Generated automatically by gen-opt.sh from nvptx-sm.def.

Unknown style: "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx"
1
Comment 144 Benjamin Schulz 2024-12-24 12:03:59 UTC
the second command yields

d /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc && /bin/bash -x /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-opt.sh "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx" ; echo $?
+ nvptx_sm_def=/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/nvptx-sm.def
+ gen_copyright_sh=/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-copyright.sh
++ grep '^NVPTX_SM' /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/nvptx-sm.def
++ sed 's/.*(//;s/,.*//'
+ sms='30
35
53
70
75
80'
+ last=
+ for sm in $sms
+ last=30
+ for sm in $sms
+ last=35
+ for sm in $sms
+ last=53
+ for sm in $sms
+ last=70
+ for sm in $sms
+ last=75
+ for sm in $sms
+ last=80
+ cat
; -*- buffer-read-only: t -*-
; Generated automatically by gen-opt.sh from nvptx-sm.def.
+ echo

+ NVPTX_GEN_COPYRIGHT=opt
+ . /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-copyright.sh
++ style=/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx
++ case $style in
++ echo 'Unknown style: "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx"'
Unknown style: "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx"
++ exit 1
1
Comment 145 Benjamin Schulz 2024-12-24 12:10:59 UTC
i guess its that bash problem again.. should I apply some patch?

I have removed the gcc-config patch of course, since otherwise it would not compile and because I thought that fix was included by now into portage...
Comment 146 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-24 12:12:01 UTC
I see the problem, I'll have it fixed shortly
Comment 147 Benjamin Schulz 2024-12-24 13:17:17 UTC
thank you for your fast reply.
Comment 148 Larry the Git Cow gentoo-dev 2024-12-24 20:48:02 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=afe723f516bec463e75e08da80cf1b8b093336c7

commit afe723f516bec463e75e08da80cf1b8b093336c7
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-24 20:47:40 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-24 20:47:56 +0000

    15.0.0: update bashisms patch
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 ...PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch | 2 +-
 15.0.0/gentoo/README.history                                          | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e1f3439619beb54addc075864c61b15f9d775332

commit e1f3439619beb54addc075864c61b15f9d775332
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-24 20:47:02 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-24 20:47:02 +0000

    14.2.0: update bashisms patch
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 ...PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch | 2 +-
 14.2.0/gentoo/README.history                                          | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
Comment 149 Larry the Git Cow gentoo-dev 2024-12-24 20:49:55 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6a1118133f5c5c13ef564404b96c54c4f8a5f3ca

commit 6a1118133f5c5c13ef564404b96c54c4f8a5f3ca
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-24 20:49:15 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-24 20:49:15 +0000

    sys-devel/gcc: update nvptx bashisms patch
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/gcc/Manifest                      | 3 ++-
 sys-devel/gcc/gcc-14.2.1_p20241221.ebuild   | 2 +-
 sys-devel/gcc/gcc-15.0.0_pre20241222.ebuild | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
Comment 150 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-24 20:51:28 UTC
(In reply to Benjamin Schulz from comment #145)
> I have removed the gcc-config patch of course, since otherwise it would not
> compile and because I thought that fix was included by now into portage...

It is included, just not yet in stable gcc-config. I'll file the stablereq for it soon but it's a critical component so breakage in it can be pretty rough, so didn't want to rush it.
Comment 151 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-24 21:00:49 UTC
(In reply to Sam James from comment #146)
> I see the problem, I'll have it fixed shortly

For completeness, the issue was that in 14 vs 15, the semantics are different as of:

commit 61da068638779580684c59d6d330f58c016a2268
Author: Thomas Schwinge <tschwinge@baylibre.com>
Date:   Mon Dec 2 16:42:14 2024 +0100

    'gcc/config/nvptx/gen-*.sh': Simplify interface

    What we currently pass in as '$1' is simply 'dirname "$0"'.

            gcc/
            * config/nvptx/gen-h.sh: Don't pass in '$1'; compute it locally.
            * config/nvptx/gen-multilib-matches.sh: Likewise.
            * config/nvptx/gen-omp-device-properties.sh: Likewise.
            * config/nvptx/gen-opt.sh: Likewise.
            * config/nvptx/t-nvptx (s-nvptx-gen-h:, s-nvptx-gen-opt:)
            (t-nvptx-gen-multilib-matches:): Adjust.
            * config/nvptx/t-omp-device (omp-device-properties-nvptx):
            Likewise.
Comment 152 Benjamin Schulz 2024-12-24 22:56:59 UTC
by the way, i have set crossdev-9999 into the package.keywords directory.

I think crossdev then had installed a file called  cross-nvptx-none in the /etc/portage/accept-keywords directory. There, one can find

cross-nvptx-none/newlib * ~* -amd64 -~amd64
cross-nvptx-none/nvptx-tools * ~* -amd64 -~amd64
cross-nvptx-none/gcc * ~* -amd64 -~amd64
cross-nvptx-none/gdb * ~* -amd64 -~amd64


which looks ok. but there is also a file with the same name in /etc/portage/package.use/

In /etc/portage/package.use/cross-nvptx-none, i can find

cross-nvptx-none/nvptx-tools multilib
cross-nvptx-none/gcc cxx openmp fortran -hardened -default-stack-clash-protection -ssp zlib zstd -sanitize -vtv -selinux -d -objc -objc++ -objc-gc -vtv -fortran -go -jit -cxx -openmp -sanitize -zstd -z>


I do not know what that means. First openmp and then -openmp, or fortran and then -fortran?

I have of course 
openmp and fortran as + in my make.conf


now when I type emerge -uUDNpv world, then I see this:

[ebuild     U  ] cross-nvptx-none/gcc-14.2.1_p20241221:14::crossdev [14.2.1_p20241116:14::crossdev] USE="lto (multilib) nls pie systemtap (-ada) (-cet) -custom-cflags -cxx* (-d) -debug (-default-stack-clash-protection) -default-znow -doc -fixed-point -fortran* (-go) (-graphite) (-hardened) -ieee-long-double -jit* -libssp (-modula2) -objc -objc++ -objc-gc -openmp* (-pch) -pgo (-rust) -sanitize (-ssp) -test (-time64) -valgrind -vanilla -vtv -zstd*" 0 KiB

I thought that only crossdev should emerge this, not portage -uUDN world, but why do I see there -openmp and why -fortran? 

sys-devel gcc would install with this:

sys-devel/gcc-14.2.1_p20241221:14::gentoo  USE="cet (cxx) d (default-stack-clash-protection) (default-znow) fortran go graphite jit lto modula2 (multilib) nls objc objc++ openmp (pie) rust sanitize ssp systemtap vtv zstd -ada (-custom-cflags) -debug -doc (-fixed-point) -hardened (-ieee-long-double) (-libssp) -objc-gc (-pch) -pgo -test (-time64) -valgrind -vanilla" 0 KiB


anyway, crossdev -t nvptx-none would lead to an error described in the following logs. I have of course done an emerge --sync before... twice...
Comment 153 Benjamin Schulz 2024-12-24 22:57:31 UTC
Created attachment 914827 [details]
info.log
Comment 154 Benjamin Schulz 2024-12-24 22:57:52 UTC
Created attachment 914828 [details]
log.xz
Comment 155 Benjamin Schulz 2024-12-24 22:58:14 UTC
Created attachment 914829 [details]
logs.tar.xz
Comment 156 Benjamin Schulz 2024-12-24 22:59:21 UTC
your patch by the way seemed to work:

So the last error is due to something else...

-opt.sh "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx" ; echo $?
+ nvptx_sm_def=/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/nvptx-sm.def
+ gen_copyright_sh=/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-copyright.sh
++ grep '^NVPTX_SM' /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/nvptx-sm.def
++ sed 's/.*(//;s/,.*//'
+ sms='30
35
53
70
75
80'
+ last=
+ for sm in $sms
+ last=30
+ for sm in $sms
+ last=35
+ for sm in $sms
+ last=53
+ for sm in $sms
+ last=70
+ for sm in $sms
+ last=75
+ for sm in $sms
+ last=80
+ cat
; -*- buffer-read-only: t -*-
; Generated automatically by gen-opt.sh from nvptx-sm.def.
+ echo

+ NVPTX_GEN_COPYRIGHT=opt
+ . /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-copyright.sh
++ style=opt
++ case $style in
++ cat
++ read line
++ case $style in
++ '[' 'Copyright (C) 2022-2024 Free Software Foundation, Inc.' = '' ']'
++ echo '; Copyright (C) 2022-2024 Free Software Foundation, Inc.'
; Copyright (C) 2022-2024 Free Software Foundation, Inc.
++ read line
++ case $style in
++ '[' '' = '' ']'
++ echo ';'
;
++ read line
++ case $style in
++ '[' 'This file is part of GCC.' = '' ']'
++ echo '; This file is part of GCC.'
; This file is part of GCC.
++ read line
++ case $style in
++ '[' '' = '' ']'
++ echo ';'
;
++ read line
++ case $style in
++ '[' 'GCC is free software; you can redistribute it and/or modify it under' = '' ']'
++ echo '; GCC is free software; you can redistribute it and/or modify it under'
; GCC is free software; you can redistribute it and/or modify it under
++ read line
++ case $style in
++ '[' 'the terms of the GNU General Public License as published by the Free' = '' ']'
++ echo '; the terms of the GNU General Public License as published by the Free'
; the terms of the GNU General Public License as published by the Free
++ read line
++ case $style in
++ '[' 'Software Foundation; either version 3, or (at your option) any later' = '' ']'
++ echo '; Software Foundation; either version 3, or (at your option) any later'
; Software Foundation; either version 3, or (at your option) any later
++ read line
++ case $style in
++ '[' version. = '' ']'
++ echo '; version.'
; version.
++ read line
++ case $style in
++ '[' '' = '' ']'
++ echo ';'
;
++ read line
++ case $style in
++ '[' 'GCC is distributed in the hope that it will be useful, but WITHOUT ANY' = '' ']'
++ echo '; GCC is distributed in the hope that it will be useful, but WITHOUT ANY'
; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
++ read line
++ case $style in
++ '[' 'WARRANTY; without even the implied warranty of MERCHANTABILITY or' = '' ']'
++ echo '; WARRANTY; without even the implied warranty of MERCHANTABILITY or'
; WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ read line
++ case $style in
++ '[' 'FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License' = '' ']'
++ echo '; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License'
; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ read line
++ case $style in
++ '[' 'for more details.' = '' ']'
++ echo '; for more details.'
; for more details.
++ read line
++ case $style in
++ '[' '' = '' ']'
++ echo ';'
;
++ read line
++ case $style in
++ '[' 'You should have received a copy of the GNU General Public License' = '' ']'
++ echo '; You should have received a copy of the GNU General Public License'
; You should have received a copy of the GNU General Public License
++ read line
++ case $style in
++ '[' 'along with GCC; see the file COPYING3.  If not see' = '' ']'
++ echo '; along with GCC; see the file COPYING3.  If not see'
; along with GCC; see the file COPYING3.  If not see
++ read line
++ case $style in
++ '[' '<http://www.gnu.org/licenses/>.' = '' ']'
++ echo '; <http://www.gnu.org/licenses/>.'
; <http://www.gnu.org/licenses/>.
++ read line
++ case $style in
+ echo

+ cat
Enum
Name(ptx_isa) Type(int)
Known PTX ISA target architectures (for use with the -misa= option):
+ echo

+ for sm in $sms
+ cat
EnumValue
Enum(ptx_isa) String(sm_30) Value(PTX_ISA_SM30)
+ '[' 30 = 80 ']'
+ echo

+ for sm in $sms
+ cat
EnumValue
Enum(ptx_isa) String(sm_35) Value(PTX_ISA_SM35)
+ '[' 35 = 80 ']'
+ echo

+ for sm in $sms
+ cat
EnumValue
Enum(ptx_isa) String(sm_53) Value(PTX_ISA_SM53)
+ '[' 53 = 80 ']'
+ echo

+ for sm in $sms
+ cat
EnumValue
Enum(ptx_isa) String(sm_70) Value(PTX_ISA_SM70)
+ '[' 70 = 80 ']'
+ echo

+ for sm in $sms
+ cat
EnumValue
Enum(ptx_isa) String(sm_75) Value(PTX_ISA_SM75)
+ '[' 75 = 80 ']'
+ echo

+ for sm in $sms
+ cat
EnumValue
Enum(ptx_isa) String(sm_80) Value(PTX_ISA_SM80)
+ '[' 80 = 80 ']'
+ continue
0
Comment 157 Benjamin Schulz 2024-12-24 23:01:37 UTC
make[2]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
make[2]: Entering directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
/bin/sh /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/gen-opt.sh "/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx" \
  > tmp-nvptx-gen.opt
make[2]: *** [/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/t-nvptx:28: s-nvptx-gen-opt] Error 1
make[2]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
make[2]: *** Waiting for unfinished jobs....
make[2]: Entering directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
TARGET_CPU_DEFAULT="" \
HEADERS="auto-host.h ansidecl.h" DEFINES="" \
Comment 158 Benjamin Schulz 2024-12-24 23:08:09 UTC
ah no, wrong file

 /bin/sh ./libtool   --mode=install /usr/lib/portage/python3.12/ebuild-helpers/xattr/install -c   libatomic.la '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib'
libtool: install: /usr/lib/portage/python3.12/ebuild-helpers/xattr/install -c .libs/libatomic.lai /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/libatomic.la
libtool: install: /usr/lib/portage/python3.12/ebuild-helpers/xattr/install -c .libs/libatomic.a /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/libatomic.a
libtool: install: chmod 644 /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/libatomic.a
libtool: install: /usr/nvptx-none/bin/ranlib /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/libatomic.a
libtool: install: warning: remember to run `libtool --finish /usr/nvptx-none/lib'
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/nvptx-none/libatomic'
make[3]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/nvptx-none/libatomic'
make[2]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/nvptx-none/libatomic'
make[1]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build'
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/mgomp/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/mgomp/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/mptx-3.1/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/mptx-3.1/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/mgomp/mptx-3.1/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/nvptx-none/lib/mgomp/mptx-3.1/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/image/usr/lib/gcc/nvptx-none/14/*.spec': No such file or directory
 [31;01m*[0m ERROR: cross-nvptx-none/gcc-14.2.1_p20241221::crossdev failed (install phase):
 [31;01m*[0m   (no error message)
 [31;01m*[0m 
 [31;01m*[0m Call stack:
 [31;01m*[0m     ebuild.sh, line  136:  Called src_install
 [31;01m*[0m   environment, line 3728:  Called toolchain_src_install
 [31;01m*[0m   environment, line 5502:  Called gcc_movelibs
 [31;01m*[0m   environment, line 2215:  Called die
 [31;01m*[0m The specific snippet of code:
 [31;01m*[0m           mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/ || die;
 [31;01m*[0m 
 [31;01m*[0m If you need support, post the output of `emerge --info '=cross-nvptx-none/gcc-14.2.1_p20241221::crossdev'`,
 [31;01m*[0m the complete build log and the output of `emerge -pqv '=cross-nvptx-none/gcc-14.2.1_p20241221::crossdev'`.
 [31;01m*[0m 
 [31;01m*[0m Please include /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-build-logs.tar.xz in your bug report.
 [31;01m*[0m 
 [31;01m*[0m The complete build log is located at '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/temp/build.log'.
 [31;01m*[0m The ebuild environment file is located at '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/temp/environment'.
 [31;01m*[0m Working directory: '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build'
 [31;01m*[0m S: '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221'

>>> Failed to emerge cross-nvptx-none/gcc-14.2.1_p20241221, Log file:

>>>  '/var/tmp/portage/cross-nvptx-n
Comment 159 Benjamin Schulz 2024-12-24 23:08:57 UTC
Created attachment 914830 [details]
info.log
Comment 160 Benjamin Schulz 2024-12-24 23:09:20 UTC
Created attachment 914831 [details]
log.xz
Comment 161 Benjamin Schulz 2024-12-24 23:09:39 UTC
Created attachment 914832 [details]
tar.xz
Comment 162 Benjamin Schulz 2024-12-24 23:20:56 UTC
86_64-pc-linux-gnu-g++  -fPIE -c    -O2 -pipe     -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -fPIE -I. -I. -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/. -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/../include  -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/../libcpp/include -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/../libcody  -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/../libdecnumber -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/../libdecnumber/dpd -I../libdecnumber -I/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/../libbacktrace  -D_GENTOO_TIME64_FORCE=0 -o nvptx.o -MT nvptx.o -MMD -MP -MF ./.deps/nvptx.TPo /var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/nvptx.cc
/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/nvptx.cc: In function ‘void handle_ptx_version_option()’:
/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/gcc-14-20241221/gcc/config/nvptx/nvptx.cc:325:12: warning: unquoted identifier or keyword ‘sm_’ in format [-Wformat-diag]
  325 |     error ("PTX version (%<-mptx%>) needs to be at least %s to support selected"
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  326 |            " %<-misa%> (sm_%s)", ptx_version_to_string (first),
      |            ~~~~~~~~~~~~~~~~~~~~
make[2]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
make[2]: Entering directory '/var/tmp/portage/cross-nvptx-none/gcc-14.2.1_p20241221/work/build/gcc'
x86_64-pc-linux-gnu-g++  -fPIE -c    -O2 -pipe     -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-r
Comment 163 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-25 00:41:02 UTC
I don't get why you're hitting that now, as nothing's changed there, but this should fix it.
Comment 164 Larry the Git Cow gentoo-dev 2024-12-25 00:42:09 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=afc0f03b6e846e1c0aa104a809f86133bad55b6d

commit afc0f03b6e846e1c0aa104a809f86133bad55b6d
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-25 00:40:42 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-25 00:42:07 +0000

    crossdev: nvptx: force on openmp & fortran
    
    Without openmp, various critical files are missing. Offloading makes
    no sense without OpenMP.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 1 +
 1 file changed, 1 insertion(+)
Comment 165 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-25 00:43:04 UTC
(In reply to Sam James from comment #163)
> I don't get why you're hitting that now, as nothing's changed there, but
> this should fix it.

It's possible you hit it because those things are stabled for *stage1* but need to be re-enabled later, actually, which also means my fix is wrong and needs to be reverted.
Comment 166 Larry the Git Cow gentoo-dev 2024-12-25 00:43:33 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=a63705c41afcca7b8cf07fe26076363d4d21e080

commit a63705c41afcca7b8cf07fe26076363d4d21e080
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-25 00:43:14 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-25 00:43:14 +0000

    Revert "crossdev: nvptx: force on openmp & fortran"
    
    This reverts commit afc0f03b6e846e1c0aa104a809f86133bad55b6d.
    
    We have to be able to turn these off for stage1 but we need them
    on for stage2... need to figure out how to do that.
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 1 -
 1 file changed, 1 deletion(-)
Comment 167 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-25 00:44:46 UTC
(In reply to Sam James from comment #165)
> (In reply to Sam James from comment #163)
> > I don't get why you're hitting that now, as nothing's changed there, but
> > this should fix it.
> 
> It's possible you hit it because those things are stabled for *stage1* but
> need to be re-enabled later, actually, which also means my fix is wrong and
> needs to be reverted.

If you do crossdev -C nvptx-none, then retry, now that stage1 doesn't fail on the bash/nvptx thing, it should be OK.
Comment 168 Larry the Git Cow gentoo-dev 2024-12-25 00:45:22 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=a95616adbecd27e9f88539a588f95d2560eb9819

commit a95616adbecd27e9f88539a588f95d2560eb9819
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-25 00:44:52 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-25 00:44:52 +0000

    crossdev: nvptx: add comment wrt GFORCE and openmp/fortran
    
    Bug: https://bugs.gentoo.org/945296
    Signed-off-by: Sam James <sam@gentoo.org>

 crossdev | 2 ++
 1 file changed, 2 insertions(+)
Comment 169 Benjamin Schulz 2024-12-25 09:44:49 UTC
thanks. after crossdev -C nvptx-none, the command crossdev -t nvptx-none worked and it compiled some test programs.
Comment 170 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-25 09:45:39 UTC
Thank you too! I'm going to file a bug for the change to crossdev to make it more robust.
Comment 171 Benjamin Schulz 2024-12-27 16:53:38 UTC
by the way, why -graphite?

For gpu offload, I guess one would like loop optimizations if they can not be tackeld by openmp parallel directives. can't it handle graphite or is graphite incompatible with openmp?
Comment 172 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-27 16:57:37 UTC
I don't remember if I tried it and found it broken or if it was pre-emptive to avoid failures. You're free to try it, although really, both graphite (and polly in llvm) don't get much love and the focus these days is usually on getting those kinds of optimisations to be native as part of the usual passes.
Comment 173 Benjamin Schulz 2024-12-27 18:11:30 UTC
ah well, i see the recent useflags are these 


cross-nvptx-none/nvptx-tools multilib
cross-nvptx-none/newlib -selinux -libraries multilib
cross-nvptx-none/gcc cxx openmp fortran -hardened -default-stack-clash-protection -ssp zlib zstd -sanitize -vtv -selinux -d -objc -objc++ -objc-gc -vtv -sanitize multilib

that looks reasonable to me.
Comment 174 Benjamin Schulz 2025-01-15 19:19:57 UTC
hm for the attached files, gcc claims "alias definitions would not be supported". He points to these, but i do not think that these are "alias" constructors. They have obviously different arguments:

#pragma omp begin declare target
template<typename T> datastruct<T>::datastruct(
    T* data,
    size_t pdatalength,
    bool rowm,
    size_t rank,
    size_t* extents,
    size_t* strides,
    bool compute_datalength,
    bool compute_strides_from_extents
) : pdata(data),
    pextents(extents),
    pstrides(strides),
    pdatalength(pdatalength),
    prank(rank),
    prowmayor(rowm)

{
    if(compute_strides_from_extents==true && pextents!=nullptr && pstrides!=nullptr && rank !=0)
    {
        fill_strides(pextents,pstrides,rank,rowm);
    }
    if(compute_datalength==true && pextents!=nullptr && pstrides!=nullptr && rank !=0)
    {
        pdatalength=compute_data_length(pextents,pstrides,rank);
    }
}
#pragma omp end declare target


#pragma omp begin declare target
template<typename T> datastruct<T>::datastruct(
    T* data,
    size_t datalength,
    bool rowm,
    size_t rows,
    size_t cols,
    size_t* extents,
    size_t* strides,
    bool compute_datalength,
    bool compute_strides_from_extents
) : pdata(data),
    pextents(extents),
    pstrides(strides),
    pdatalength(datalength),
    prank(2),
    prowmayor(rowm)
{
    if(extents!=nullptr)
    {
        pextents[0]=(rowm==true)?rows:cols;
        pextents[1]=(rowm==true)?cols:rows;
    }
    if(pstrides!=nullptr && compute_strides_from_extents)
    {
        pstrides[0]=(rowm==true)? cols:1;
        pstrides[1]=(rowm==true)?1: rows;
    }
    if(compute_datalength==true && extents!=nullptr && strides!=nullptr)
    {
        pdatalength=(rows-1) * strides[0]+(cols-1)*strides[1]+1;
    }
}
#pragma omp end declare target

#pragma omp begin declare target
template<typename T> datastruct<T>::datastruct(
    T* data,
    size_t datalength,
    bool rowm,
    bool rowvector,
    size_t noelements,
    size_t* extents,
    size_t* strides,
    bool compute_datalength,
    bool compute_strides_from_extents
) : pdata(data),
    pextents(extents),
    pstrides(strides),
    pdatalength(datalength),
    prank(1),
    prowmayor(true)
{
    if(extents!=nullptr)
    {
        pextents[0]=noelements;
    }
    if(pstrides!=nullptr && compute_strides_from_extents)
    {
        if(rowvector)
            pstrides[0]=(rowm==true)? 1:noelements;
        else
            pstrides[0]=(rowm==true)? noelements:1;
    }
    if(compute_datalength==true && strides!=nullptr)
    {
        pdatalength=(noelements-1) * strides[0]+1;
    }
}
Comment 175 Benjamin Schulz 2025-01-15 19:20:27 UTC
Created attachment 916622 [details]
arraytestclass
Comment 176 Benjamin Schulz 2025-01-15 19:20:51 UTC
Created attachment 916623 [details]
arraytest-main
Comment 177 Benjamin Schulz 2025-01-15 19:21:19 UTC
Created attachment 916624 [details]
cmakelists.txt
Comment 178 Benjamin Schulz 2025-01-15 19:22:33 UTC
i just report this because i think i remember have seen a situation where gcc claimed this erroneously. But i am not sure if that is still there as a compiler bug and if that is something for upstream....
Comment 179 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-01-15 19:25:10 UTC
I think it'll need reporting upstream to GCC indeed.
Comment 180 Benjamin Schulz 2025-01-22 00:25:48 UTC
because of this gcc 14 regression https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118590

I tried to build gcc 13 as a cross compiler, where this regression is said not to occur by upstream. That failed

* crossdev version:      9cc43baef9c8a70213a48815d38cc395084f3902
 * Host Portage ARCH:     amd64
 * Host Portage System:   x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu)
 * Target Portage ARCH:   *
 * Target System:         nvptx-none
 * Stage:                 4 (C/C++ compiler)
 * USE=multilib:          yes
 * Target ABIs:           default

 * binutils:              nvptx-tools-[latest]
 * gcc:                   gcc-13
 * libc:                  newlib-[latest]

 * CROSSDEV_OVERLAY:      /var/db/repos/crossdev
 * PORT_LOGDIR:           /var/log/portage
 * PORTAGE_CONFIGROOT:    /
 * Portage flags:         
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  
 * leaving sys-libs/newlib in /var/db/repos/crossdev
 * leaving sys-devel/nvptx-tools in /var/db/repos/crossdev
 * leaving sys-devel/gcc in /var/db/repos/crossdev
 * leaving dev-debug/gdb in /var/db/repos/crossdev
 * leaving metadata/layout.conf alone in /var/db/repos/crossdev
  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  ~  -  _  -  
 * Log: /var/log/portage/cross-nvptx-none-nvptx-tools.log
 * Emerging cross-nvptx-tools ...                                                                                                                                                                                                     [ ok ]
 * Log: /var/log/portage/cross-nvptx-none-gcc-stage1.log
 * Emerging cross-gcc-stage1 ...
Comment 181 Benjamin Schulz 2025-01-22 00:26:17 UTC
Created attachment 917292 [details]
info.log
Comment 182 Benjamin Schulz 2025-01-22 00:26:43 UTC
Created attachment 917293 [details]
log.gz
Comment 183 Benjamin Schulz 2025-01-22 00:27:12 UTC
Created attachment 917294 [details]
gcc-config.log
Comment 184 Benjamin Schulz 2025-01-22 00:31:31 UTC
what i tried was this command

crossdev -t nvptx-none --gcc 13

the error seems to be this:

checking linker --sysroot support... no
checking __stack_chk_fail in target C library... yes
checking sys/sdt.h in the target C library... no
configure: error: sys/sdt.h was not found
make[1]: *** [Makefile:4535: configure-gcc] Error 1
make[1]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-12.5.9999/work/build'
make: *** [Makefile:1014: all] Error 2
 [31;01m*[0m ERROR: cross-nvptx-none/gcc-12.5.9999::crossdev failed (compile phase):
 [31;01m*[0m   emake failed
 [31;01m*[0m 
 [31;01m*[0m If you need support, 


I do not know why it tried to emerge 12.5.9999, as i asked for 13... but well,

I do not know if this is possible at all? does eselect gcc support to have various offlload compilers?
Comment 185 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-01-22 00:38:58 UTC
Try --gcc "13.4" or so.
Comment 186 Benjamin Schulz 2025-01-22 01:06:26 UTC
Created attachment 917295 [details]
stage1 log
Comment 187 Benjamin Schulz 2025-01-22 01:06:49 UTC
Created attachment 917296 [details]
config log
Comment 188 Benjamin Schulz 2025-01-22 01:07:18 UTC
Created attachment 917297 [details]
info.log
Comment 189 Benjamin Schulz 2025-01-22 01:08:45 UTC
 crossdev -t nvptx-none --gcc 13.4
failed at install phase apparently

btool: install: /usr/lib/portage/python3.12/ebuild-helpers/xattr/install -c .libs/libatomic.lai /var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/libatomic.la
libtool: install: /usr/lib/portage/python3.12/ebuild-helpers/xattr/install -c .libs/libatomic.a /var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/libatomic.a
libtool: install: chmod 644 /var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/libatomic.a
libtool: install: /usr/nvptx-none/bin/ranlib /var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/libatomic.a
libtool: install: warning: remember to run `libtool --finish /usr/nvptx-none/lib'
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/work/build/nvptx-none/libatomic'
make[3]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/work/build/nvptx-none/libatomic'
make[2]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/work/build/nvptx-none/libatomic'
make[1]: Leaving directory '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/work/build'
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/mgomp/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/mgomp/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/mptx-3.1/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/mptx-3.1/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/mgomp/mptx-3.1/*.a': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/nvptx-none/lib/mgomp/mptx-3.1/*.spec': No such file or directory
mv: cannot stat '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/image/usr/lib/gcc/nvptx-none/13/*.spec': No such file or directory
 [31;01m*[0m ERROR: cross-nvptx-none/gcc-13.3.1_p20250117::crossdev failed (install phase):
 [31;01m*[0m   (no error message)
 [31;01m*[0m 
 [31;01m*[0m Call stack:
 [31;01m*[0m     ebuild.sh, line  136:  Called src_install
 [31;01m*[0m   environment, line 3728:  Called toolchain_src_install
 [31;01m*[0m   environment, line 5504:  Called gcc_movelibs
 [31;01m*[0m   environment, line 2215:  Called die
 [31;01m*[0m The specific snippet of code:
 [31;01m*[0m           mv "${ED}"/usr/lib/gcc/nvptx-none/${GCCMAJOR}/*.{a,spec} "${ED}"/usr/lib/gcc/${CHOST}/${GCCMAJOR}/accel/nvptx-none/ || die;
 [31;01m*[0m 
 [31;01m*[0m If you need support, post the output of `emerge --info '=cross-nvptx-none/gcc-13.3.1_p20250117::crossdev'`,
 [31;01m*[0m the complete build log and the output of `emerge -pqv '=cross-nvptx-none/gcc-13.3.1_p20250117::crossdev'`.
 [31;01m*[0m 
 [31;01m*[0m Please include /var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/work/gcc-build-logs.tar.xz in your bug report.
 [31;01m*[0m 
 [31;01m*[0m The complete build log is located at '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/temp/build.log'.
 [31;01m*[0m The ebuild environment file is located at '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/temp/environment'.
 [31;01m*[0m Working directory: '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/work/build'
 [31;01m*[0m S: '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/work/gcc-13-20250117'

>>> Failed to emerge cross-nvptx-none/gcc-13.3.1_p20250117, Log file:

>>>  '/var/tmp/portage/cross-nvptx-none/gcc-13.3.1_p20250117/temp/build.log'
 * Messages for package cross-nvptx-none/gcc-13.3.1_p20250117:
 * ERROR: cross-nvptx-none/gcc-13.3.1_p20250117::crossdev failed (install phase):
 *   (no error message)
 *
Comment 190 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-01-22 02:30:33 UTC
Not clear to me why it failed, but note that for offloading, you need the system compiler to be 13 as well (at least for building it), so you need to temporarily `gcc-config` your main compiler to be 13 too.
Comment 191 Benjamin Schulz 2025-01-23 21:39:02 UTC
Hi it appears that before I emerge a new cross compiler, i have to delete the old one.

Unfortunately, what is more, gcc 13.4 also appears to have that bug which I reported. Gcc's bugzilla says that 13.2 would be bug free. 

However, if i eselect gcc 13 and then emerge 13.2 as a cross compiler, and when I then want to compile a sample program, i get this:

[ 50%] Linking CXX executable arraytest
/usr/bin/cmake -E cmake_link_script CMakeFiles/arraytest.dir/link.txt --verbose=1
lto1: severe error: bydecode stream in file »CMakeFiles/arraytest.dir/main_acc.cpp.o« with LTO-Version 13.1 instead of the expected 13.0 created.
compilation stopped.


Additionally, by the way, nvc++ and clang can not find the header openacc.h. Do you know where this is? and the associated openacc runtime? And,yes gcc also has problems finding that file when i want to compile something with an offload gcc 14 compiler and call acc_malloc for which i have to #include <openacc.h>

So at the moment nothing works on my end..
Comment 192 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-01-23 21:57:56 UTC
(In reply to Benjamin Schulz from comment #191)
> Hi it appears that before I emerge a new cross compiler, i have to delete
> the old one.
> 
> Unfortunately, what is more, gcc 13.4 also appears to have that bug which I
> reported. Gcc's bugzilla says that 13.2 would be bug free. 

I'm not sure where you're seeing that.

> 
> However, if i eselect gcc 13 and then emerge 13.2 as a cross compiler, and
> when I then want to compile a sample program, i get this:
> 
> [ 50%] Linking CXX executable arraytest
> /usr/bin/cmake -E cmake_link_script CMakeFiles/arraytest.dir/link.txt
> --verbose=1
> lto1: severe error: bydecode stream in file
> »CMakeFiles/arraytest.dir/main_acc.cpp.o« with LTO-Version 13.1 instead of
> the expected 13.0 created.
> compilation stopped.

You'd have to make sure that the two versions mathc.

> 
> 
> Additionally, by the way, nvc++ and clang can not find the header openacc.h.
> Do you know where this is? and the associated openacc runtime? And,yes gcc
> also has problems finding that file when i want to compile something with an
> offload gcc 14 compiler and call acc_malloc for which i have to #include
> <openacc.h>

I've no idea on that.