public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compiling GCC with nvptx offloading
@ 2023-07-18  7:24 Sisak, Janos Mihaly
  2023-07-18  7:33 ` Xi Ruoyao
  2023-08-03 14:54 ` Andrew Stubbs
  0 siblings, 2 replies; 4+ messages in thread
From: Sisak, Janos Mihaly @ 2023-07-18  7:24 UTC (permalink / raw)
  To: gcc-help


[-- Attachment #1.1: Type: text/plain, Size: 1231 bytes --]

Good day everyone!

I’ve been trying to compile GCC 13.1 with nvptx offloading but I’m having no success.
The host machine is an Ubuntu 20.04.6 LTS, with GCC 11.1 from the repositories.

I compile and install binutils, nvptx-tools then I try to configure and buil gcc with target=nvptx-none. It fails during libatomic or libbacktrace with this error:
configure:3721: /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include    -V >&5
xgcc: error: unrecognized command-line option '-V'
xgcc: fatal error: no input files
compilation terminated.

I tried to google the error and I found that maybe my newlib is wrong. I tried both the mentorgraphics repo (marked obsolete) and the Cygwin repo (release cygwin-3.4.7). No success.

I attached the failing log, the script used for downloading the repos and the script used for compiling the sources. If you have five minutes and can help, please do, would be very much appreciated.




Internal

[-- Attachment #2: build-gcc-acc.sh --]
[-- Type: application/octet-stream, Size: 2024 bytes --]

#!/bin/sh

#
# Build GCC with support for offloading to NVIDIA GPUs.
#

clear

work_dir="/home/uig13265/offload/wrk"
install_dir="/home/uig13265/offload/install"

# Location of the installed CUDA toolkit
cuda_dir="/usr/local/cuda-12.2"
cuda_include="/usr/local/cuda-12.2/include"
cuda_libs="/usr/local/cuda-12.2/lib64"

# Init dirs
mkdir -p "$install_dir"
mkdir -p "$work_dir"
rm -rf "$install_dir"/*
rm -rf "$work_dir"/build-*
# async rm in cygwin
sleep 1


cd "$work_dir"

rm ./gcc/newlib

export PREFIX="$install_dir"

mkdir -p "$PREFIX/bin"
export PATH="$PREFIX/bin:$PATH"

mkdir build-binutils
cd build-binutils
../binutils/configure \
    --build=x86_64-pc-linux-gnu \
    --host=x86_64-pc-linux-gnu \
    --target=x86_64-pc-linux-gnu \
    --prefix="$PREFIX" \
    --disable-nls
make -j8 || exit 1
make install || exit 1
cd ..

# The $PREFIX/bin dir _must_ be in the PATH. We did that above.
which -- $TARGET-as || echo $TARGET-as is not in the PATH

mkdir build-nvptx-tools
cd build-nvptx-tools
../nvptx-tools/configure \
    --with-cuda-driver="$cuda_dir" \
    --prefix="$PREFIX"
make -j8 || exit 1
make install || exit 1
cd ..

ln -s ./nvptx-newlib/newlib ./gcc/newlib

mkdir build-gcc-nvptx
cd build-gcc-nvptx
../gcc/configure \
    --build=x86_64-pc-linux-gnu \
    --host=x86_64-pc-linux-gnu \
    --target=nvptx-none \
    --with-build-time-tools="$PREFIX/nvptx-none/bin" \
    --enable-as-accelerator-for=x86_64-pc-linux-gnu \
    --enable-languages="c,c++" \
    --disable-sjlj-exceptions \
    --enable-newlib-io-long-long \
    --prefix="$PREFIX"
make -j8 || exit 1
make install || exit 1
cd ..

rm ./gcc/newlib

mkdir build-gcc-acc
cd build-gcc-acc
../gcc/configure \
    --build=x86_64-pc-linux-gnu \
    --host=x86_64-pc-linux-gnu \
    --target=x86_64-pc-linux-gnu \
    --prefix="$PREFIX" \
    --enable-offload-targets=nvptx-none="$PREFIX/nvptx-none" \
    --with-cuda-driver="$cuda_dir" \
    --disable-nls \
    --enable-languages="c,c++,lto"
make -j8 || exit 1
make install || exit 1
cd ..

exit

[-- Attachment #3: config.log --]
[-- Type: application/octet-stream, Size: 12614 bytes --]

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by GNU Atomic Library configure 1.0, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ /home/uig13265/offload/wrk/gcc/libatomic/configure --srcdir=../../../gcc/libatomic --cache-file=./config.cache --enable-multilib --with-cross-host=x86_64-pc-linux-gnu --with-build-time-tools=/home/uig13265/offload/install/nvptx-none/bin --enable-as-accelerator-for=x86_64-pc-linux-gnu --disable-sjlj-exceptions --enable-newlib-io-long-long --prefix=/home/uig13265/offload/install --enable-languages=c,c++,lto --program-transform-name=s&^&nvptx-none-& --disable-option-checking --with-target-subdir=nvptx-none --build=x86_64-pc-linux-gnu --host=nvptx-none --target=nvptx-none

## --------- ##
## Platform. ##
## --------- ##

hostname = uudanmwu
uname -m = x86_64
uname -r = 5.15.0-73-generic
uname -s = Linux
uname -v = #80~20.04.1-Ubuntu SMP Wed May 17 14:58:14 UTC 2023

/usr/bin/uname -p = x86_64
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /home/uig13265/offload/install/bin
PATH: /home/uig13265/.local/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /snap/bin
PATH: /opt/puppetlabs/bin


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2428: creating cache ./config.cache
configure:2511: checking for --enable-version-specific-runtime-libs
configure:2526: result: no
configure:2534: checking for --enable-generated-files-in-srcdir
configure:2549: result: no
configure:2611: checking build system type
configure:2625: result: x86_64-pc-linux-gnu
configure:2645: checking host system type
configure:2658: result: nvptx-unknown-none
configure:2678: checking target system type
configure:2691: result: nvptx-unknown-none
configure:2748: checking for a BSD-compatible install
configure:2816: result: /usr/bin/install -c
configure:2827: checking whether build environment is sane
configure:2882: result: yes
configure:2939: checking for nvptx-none-strip
configure:2966: result: nvptx-none-strip
configure:3031: checking for a thread-safe mkdir -p
configure:3070: result: /usr/bin/mkdir -p
configure:3077: checking for gawk
configure:3104: result: gawk
configure:3115: checking whether make sets $(MAKE)
configure:3137: result: yes
configure:3166: checking whether make supports nested variables
configure:3183: result: yes
configure:3416: checking for nvptx-none-gcc
configure:3443: result: /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include   
configure:3712: checking for C compiler version
configure:3721: /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include    --version >&5
xgcc (GCC) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3732: $? = 0
configure:3721: /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include    -v >&5
Reading specs from /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/specs
COLLECT_GCC=/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc
COLLECT_LTO_WRAPPER=/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/lto-wrapper
Target: nvptx-none
Configured with: ../gcc/configure --target=nvptx-none --with-build-time-tools=/home/uig13265/offload/install/nvptx-none/bin --enable-as-accelerator-for=x86_64-pc-linux-gnu --enable-languages=c,c++ --disable-sjlj-exceptions --enable-newlib-io-long-long --prefix=/home/uig13265/offload/install
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 13.1.0 (GCC) 
configure:3732: $? = 0
configure:3721: /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include    -V >&5
xgcc: error: unrecognized command-line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3732: $? = 1
configure:3721: /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include    -qversion >&5
xgcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
xgcc: fatal error: no input files
compilation terminated.
configure:3732: $? = 1
configure:3752: checking whether the C compiler works
configure:3774: /home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include    -g -O2   conftest.c  >&5
error resolving libg.a
collect2: error: ld returned 1 exit status
configure:3778: $? = 1
configure:3816: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU Atomic Library"
| #define PACKAGE_TARNAME "libatomic"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU Atomic Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libatomic/"
| #define PACKAGE "libatomic"
| #define VERSION "1.0"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3821: error: in `/home/uig13265/offload/wrk/build-gcc-nvptx/nvptx-none/libatomic':
configure:3823: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=x86_64-pc-linux-gnu
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_build_alias_set=set
ac_cv_env_build_alias_value=x86_64-pc-linux-gnu
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=nvptx-none
ac_cv_env_target_alias_set=set
ac_cv_env_target_alias_value=nvptx-none
ac_cv_host=nvptx-unknown-none
ac_cv_path_mkdir=/usr/bin/mkdir
ac_cv_prog_AWK=gawk
ac_cv_prog_CC='/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include   '
ac_cv_prog_STRIP=nvptx-none-strip
ac_cv_prog_make_make_set=yes
ac_cv_target=nvptx-unknown-none
am_cv_make_support_nested_variables=yes

## ----------------- ##
## Output variables. ##
## ----------------- ##

ACLOCAL='${SHELL} /home/uig13265/offload/wrk/gcc/missing aclocal-1.15'
AMDEPBACKSLASH=''
AMDEP_FALSE=''
AMDEP_TRUE=''
AMTAR='$${TAR-tar}'
AM_BACKSLASH='\'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
AM_DEFAULT_VERBOSITY='1'
AM_V='$(V)'
AR='/home/uig13265/offload/install/nvptx-none/bin/ar'
ARCH_AARCH64_LINUX_FALSE=''
ARCH_AARCH64_LINUX_TRUE=''
ARCH_ARM_LINUX_FALSE=''
ARCH_ARM_LINUX_TRUE=''
ARCH_I386_FALSE=''
ARCH_I386_TRUE=''
ARCH_X86_64_FALSE=''
ARCH_X86_64_TRUE=''
AUTOCONF='${SHELL} /home/uig13265/offload/wrk/gcc/missing autoconf'
AUTOHEADER='${SHELL} /home/uig13265/offload/wrk/gcc/missing autoheader'
AUTOMAKE='${SHELL} /home/uig13265/offload/wrk/gcc/missing automake-1.15'
AWK='gawk'
CC='/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/xgcc -B/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/ -B/home/uig13265/offload/install/nvptx-none/bin/ -B/home/uig13265/offload/install/nvptx-none/lib/ -isystem /home/uig13265/offload/install/nvptx-none/include -isystem /home/uig13265/offload/install/nvptx-none/sys-include   '
CCAS=''
CCASDEPMODE=''
CCASFLAGS=''
CCDEPMODE=''
CFLAGS='-g -O2'
CPP=''
CPPFLAGS=''
CYGPATH_W='echo'
DEFS=''
DEPDIR=''
DSYMUTIL='nvptx-none-dsymutil'
DUMPBIN=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
FGREP=''
GENINSRC_FALSE=''
GENINSRC_TRUE='#'
GREP=''
HAVE_IFUNC_FALSE=''
HAVE_IFUNC_TRUE=''
INSTALL_DATA='/usr/bin/install -c -m 644'
INSTALL_PROGRAM='/usr/bin/install -c'
INSTALL_SCRIPT='/usr/bin/install -c'
INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
LD='/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/collect-ld'
LDFLAGS=''
LIBAT_BUILD_VERSIONED_SHLIB_FALSE=''
LIBAT_BUILD_VERSIONED_SHLIB_GNU_FALSE=''
LIBAT_BUILD_VERSIONED_SHLIB_GNU_TRUE=''
LIBAT_BUILD_VERSIONED_SHLIB_SUN_FALSE=''
LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE=''
LIBAT_BUILD_VERSIONED_SHLIB_TRUE=''
LIBOBJS=''
LIBS=''
LIBTOOL=''
LIPO='nvptx-none-lipo'
LN_S=''
LTLIBOBJS=''
MAINT=''
MAINTAINER_MODE_FALSE=''
MAINTAINER_MODE_TRUE=''
MAKEINFO='makeinfo --split-size=5000000'
MKDIR_P='/usr/bin/mkdir -p'
NM='/home/uig13265/offload/wrk/build-gcc-nvptx/./gcc/nm'
NMEDIT=''
OBJDUMP='nvptx-none-objdump'
OBJEXT=''
OPT_LDFLAGS=''
OTOOL64=''
OTOOL='nvptx-none-otool'
PACKAGE='libatomic'
PACKAGE_BUGREPORT=''
PACKAGE_NAME='GNU Atomic Library'
PACKAGE_STRING='GNU Atomic Library 1.0'
PACKAGE_TARNAME='libatomic'
PACKAGE_URL='http://www.gnu.org/software/libatomic/'
PACKAGE_VERSION='1.0'
PATH_SEPARATOR=':'
PERL=''
RANLIB='/home/uig13265/offload/install/nvptx-none/bin/ranlib'
SECTION_LDFLAGS=''
SED='/usr/bin/sed'
SET_MAKE=''
SHELL='/bin/sh'
SIZES=''
STRIP='nvptx-none-strip'
VERSION='1.0'
XCFLAGS=''
XLDFLAGS=''
ac_ct_CC=''
ac_ct_DUMPBIN=''
am__EXEEXT_FALSE=''
am__EXEEXT_TRUE=''
am__fastdepCCAS_FALSE=''
am__fastdepCCAS_TRUE=''
am__fastdepCC_FALSE=''
am__fastdepCC_TRUE=''
am__include=''
am__isrc=' -I$(srcdir)'
am__leading_dot='.'
am__nodep=''
am__quote=''
am__tar='$${TAR-tar} chof - "$$tardir"'
am__untar='$${TAR-tar} xf -'
bindir='${exec_prefix}/bin'
build='x86_64-pc-linux-gnu'
build_alias='x86_64-pc-linux-gnu'
build_cpu='x86_64'
build_os='linux-gnu'
build_vendor='pc'
config_path=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
enable_aarch64_lse=''
enable_shared=''
enable_static=''
exec_prefix='NONE'
get_gcc_base_ver=''
host='nvptx-unknown-none'
host_alias='nvptx-none'
host_cpu='nvptx'
host_os='none'
host_vendor='unknown'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_sh='${SHELL} /home/uig13265/offload/wrk/gcc/install-sh'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
libtool_VERSION=''
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
lt_host_flags=''
mandir='${datarootdir}/man'
mkdir_p='$(MKDIR_P)'
multi_basedir='../../../gcc/libatomic/..'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/home/uig13265/offload/install'
program_transform_name='s&^&nvptx-none-&'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target='nvptx-unknown-none'
target_alias='nvptx-none'
target_cpu='nvptx'
target_os='none'
target_vendor='unknown'
tmake_file=''
toolexecdir='$(exec_prefix)/$(target_alias)'
toolexeclibdir='$(toolexecdir)/lib'

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME "GNU Atomic Library"
#define PACKAGE_TARNAME "libatomic"
#define PACKAGE_VERSION "1.0"
#define PACKAGE_STRING "GNU Atomic Library 1.0"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL "http://www.gnu.org/software/libatomic/"
#define PACKAGE "libatomic"
#define VERSION "1.0"

configure: exit 77

[-- Attachment #4: dl-gcc-offload-nvptx.sh --]
[-- Type: application/octet-stream, Size: 905 bytes --]

#!/bin/sh

work_dir="/home/uig13265/offload/wrk"

rm -rf "$work_dir"
mkdir -p "$work_dir"
cd "$work_dir"

git clone --depth 1 https://github.com/MentorEmbedded/nvptx-tools nvptx-tools

git clone --depth 1 --branch cygwin-3.4.7 https://cygwin.com/git/newlib-cygwin.git nvptx-newlib
#git clone --depth 1 https://github.com/MentorEmbedded/nvptx-newlib.git nvptx-newlib

git clone --depth 1 --branch releases/gcc-13.1.0 git://gcc.gnu.org/git/gcc.git gcc

git clone --depth 1 --branch release/2.37/master https://sourceware.org/git/glibc.git

cd gcc
contrib/download_prerequisites
cd ..

wget https://ftp.gnu.org/gnu/binutils/binutils-2.40.tar.xz
tar -xf binutils-2.40.tar.xz
mv binutils-2.40 binutils

wget https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v11.0.0.zip/download
mv download mingw-w64-v11.0.0.zip
unzip mingw-w64-v11.0.0.zip
mv mingw-w64-v11.0.0 mingw-w64


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-03 15:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18  7:24 Compiling GCC with nvptx offloading Sisak, Janos Mihaly
2023-07-18  7:33 ` Xi Ruoyao
2023-08-03 14:54 ` Andrew Stubbs
2023-08-03 15:28   ` Patrick Begou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).