%define gcc_target_platform %{_target_platform} %define gcc_major_version 13 %define branch 13 %define ver 13.3 %define rel 0 %define build_check 0 # Avoid forcing RPM flags #undefine _auto_set_build_flags %{expand: %{?_without_check: %%global build_check 0}} # versioned libstdcxx_includedir %define libstdcxx_includedir %{target_cpu}-%{_real_vendor}-linux%{gnuext}/include/c++/%{branch} # There are currently 3 alternative ways of getting the sources: # # 1) use the snapshot version from https://gcc.gnu.org/pub/gcc/snapshots/ (and set bcond_without use_snapshot below) # 2) use the git version (obtained from the script %%SOURCE1) # 3) use standard release plus patches # with=do not use snapshot, without=use snapshot %bcond_without use_snapshot # with=do not use git version, without=use git version %bcond_with use_git # with=do not use git patch against standard release, without=use git patch against standard release %bcond_with use_git_patch # # define the snapshot version to use from from https://gcc.gnu.org/pub/gcc/snapshots/ %define snapshot 20250103 # # define the git date and hash to use current patch from release to git with %%{SOURCE1} script %define gitpatch_date 20211113 %define gitpatch_hash 5226c9f5b0f %if %{with use_snapshot} %define source_package gcc-%{branch}-%{snapshot} %define source_dir gcc-%{branch}-%{snapshot} %else %define source_package gcc-%{version} %define source_dir gcc-%{version} %endif Summary: Compatible GNU Compiler Collection v11.x Name: compat-cuda-gcc13 Version: %{ver} %if %{with use_snapshot} Release: %mkrel %rel.%{snapshot} %else %if %{with use_git} Release: %mkrel %rel.%{gitdate}.git %else %if %{with use_patch} Release: %mkrel %rel.%{gitpatch_date}.gitpatch %else Release: %mkrel %rel %endif %endif %endif License: GPLv3+ Group: Development/C URL: https://gcc.gnu.org/ %if %{with use_snapshot} Source0: https://gcc.gnu.org/pub/gcc/snapshots/%{branch}-%{snapshot}/gcc-%{branch}-%{snapshot}.tar.xz %else %if %{with use_git} # current git version (get with %%SOURCE1 script) Source: gcc-%{version}-%{gitdate}.git.%{githash}.tar.xz %else # standard release source Source0: https://ftpmirror.gnu.org/gcc/gcc-%{version}/gcc-%{version}.tar.xz %endif %endif # script for getting the current git version or diff from a tagged release Source1: gcc-%{branch}-get-from-git.sh # Patches # # From git://gcc.gnu.org/git/gcc.git # # upstream gcc-9 branch, numbered from 1 %if %{with use_gitpatch} Patch1: gcc-%{version}-%{gitpatch_date}.git.%{gitpatch_hash}.patch %endif # upstream master branch, numbered from 101 # Mageia patches, numbered from 201 # # build 32 bits code when running through linux32 Patch201: gcc-11.2-linux32-new.patch # slibdir is either /lib or /lib64 Patch202: gcc-11.2-pass-slibdir.patch # pass libdir around Patch203: gcc-11.2-multi-do-libdir.patch # # Fedora patches, numbered from 501 # "fix" liberated from Fedora # Fedora technical explanation: "libtool sucks" # TODO: really figure it out #Patch504: gcc-11.2-libtool-no-rpath.patch %define binutils_version 1:2.33.1-1 BuildRequires: python3 Requires: binutils >= %{binutils_version} BuildRequires: binutils >= %{binutils_version} BuildRequires: gcc >= 8.3.0-1 # c++ is mandatory to build gcc BuildRequires: gcc-c++ >= 8.3.0-1 # make sure gdb will understand DW_FORM_strp Conflicts: gdb < 5.1.1 BuildRequires: chrpath BuildRequires: zlib-devel # isl is used for Graphite support (optimizations) # see https://gcc.gnu.org/wiki/Graphite BuildRequires: isl-devel >= 0.14 # needed for lto support BuildRequires: elfutils-devel BuildRequires: gettext BuildRequires: flex BuildRequires: bison BuildRequires: texinfo >= 4.1 BuildRequires: texinfo-tex # needs a GNU awk recent enough to correctly generate options.h BuildRequires: gawk >= 3.1.4 Requires: glibc-devel >= 2.4-1 BuildRequires: glibc-devel >= 2.4-1 # for make check %if %{build_check} BuildRequires: glibc-static-devel BuildRequires: autogen BuildRequires: dejagnu BuildRequires: pkgconfig(libzstd) BuildRequires: sharutils #BuildRequires: systemtap %endif # BuildRequires: gmp-devel BuildRequires: pkgconfig(mpfr) BuildRequires: libmpc-devel AutoReq: false AutoProv: false ExclusiveArch: x86_64 Obsoletes: compat-cuda-gcc9 < %{version}-%{release} Provides: compat-cuda-gcc9 = %{version}-%{release} Obsoletes: compat-cuda-gcc11 < %{version}-%{release} Provides: compat-cuda-gcc11 = %{version}-%{release} %description A compiler aimed at integrating all the optimizations and features necessary for a high-performance and stable development environment. This package is required for all other GCC compilers, namely C++, Fortran 95. This is a special gcc version for compatibility with cuda-11.8. Example of usage with nvcc: nvcc -ccbin g++-13 nvcc -ccbin gcc-13 %prep %setup -q -n %{source_dir} %autopatch -p1 %build %define python_dir %(echo "%{python3_sitelib}" | sed 's!^%{_prefix}!!g') # Prepare OPT_FLAGS OPT_FLAGS=$(echo %{optflags} | sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-mcpu=pentiumpro//g') # "-Wformat -Werror=format-security" from the above flags causes some fail # in "libcpp/macro.c:164:23: error: format not a string literal". Drop for now. To be reviewed. OPT_FLAGS=$(echo $OPT_FLAGS | sed -e 's/-Wformat//g' -e 's/-Werror=format-security//g') # Simpler flags: "-O2 -g -pipe" for now. #OPT_FLAGS="-O2 -g -pipe" # don't build crt files with -fasynchronous-unwind-tables case " $OPT_FLAGS " in *" -fasynchronous-unwind-tables "*) perl -pi -e 's/-fno-exceptions /-fno-exceptions -fno-asynchronous-unwind-tables /' gcc/Makefile.in ;; esac # Force a seperate object dir rm -rf obj-%{gcc_target_platform} mkdir obj-%{gcc_target_platform} cd obj-%{gcc_target_platform} LANGUAGES="c,c++,fortran,lto" LANGUAGES="c,c++,lto" LIBSTDCXX_FLAGS="--enable-long-long --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu" #LIBSTDCXX_FLAGS="$LIBSTDCXX_FLAGS --with-gxx-include-dir=%{libstdcxx_includedir}" SSP_FLAGS="--enable-ssp --disable-libssp" ISL_FLAGS="--with-isl" LIBFFI_FLAGS="--disable-libffi" LIBC_FLAGS="--enable-threads=posix --with-linker-hash-style=gnu --enable-shared" # target specific flags #CROSS_FLAGS="--target=%{gcc_target_platform}" TARGET_FLAGS="--with-cpu=generic" #PROGRAM_SUFFIX="--program-suffix=-%{gcc_major_version}" %define python_dir %(echo "%{python3_sitelib}" | sed 's!^%{_prefix}!!g') CC="%{__cc}" \ CFLAGS="$OPT_FLAGS" \ CXXFLAGS="$OPT_FLAGS" \ XCFLAGS="$OPT_FLAGS" \ TCFLAGS="$OPT_FLAGS" \ EGREP="grep -E" \ ../configure \ --prefix=%{_prefix}/lib/%{name} \ --libexecdir=%{_prefix}/lib/%{name}/lib \ --with-slibdir=/%{_lib} \ --with-pkgversion="Mageia %{version}-%{release}" \ --with-bugurl=https://bugs.mageia.org/ \ --enable-checking=release \ --enable-languages="$LANGUAGES" \ --enable-linker-build-id \ --build=%{_target_platform} \ --host=%{_target_platform} \ $CROSS_FLAGS \ $TARGET_FLAGS \ $PROGRAM_SUFFIX \ $LIBC_FLAGS \ $LIBOBJC_FLAGS \ $LIBSTDCXX_FLAGS \ $SSP_FLAGS \ $ISL_FLAGS \ $LIBFFI_FLAGS \ $LIBGOMP_FLAGS \ $QUADMATH_FLAGS \ --with-system-zlib \ --disable-werror \ --with-python-dir=%{python_dir} \ --enable-lto \ --with-gcc-major-version-only touch ../gcc/c-gperf.h tick=$SECONDS # bootstrap-lean is similar to bootstrap except "object files from the stage1 # and stage2 of the 3-stage bootstrap of the compiler are deleted as soon as # they are no longer needed." %make_build bootstrap-lean BOOT_CFLAGS="$OPT_FLAGS" #make_build tock=$SECONDS elapsed=$(( $tock - $tick )) echo "Compilation time duration: $elapsed seconds" cd .. %check %if %{build_check} echo =================== BEGIN TESTING ================== pushd obj-%{gcc_target_platform} tick=$SECONDS export LC_ALL=C %make_build -k check || true tock=$SECONDS elapsed=$(( $tock - $tick )) echo "Testing time duration: $elapsed seconds" ../contrib/test_summary > ../test_summary.log popd echo =================== END TESTING ==================== %endif %install export QA_RPATHS=0x0020 pushd obj-%{gcc_target_platform} %make_install popd # expose versioned links to bindir install -m 755 -d %{buildroot}%{_bindir} for i in \ cpp \ g++ \ gcc \ gcc-ar \ gcc-nm \ gcc-ranlib \ gfortran \ x86_64-mageia-linux-gnu-ar \ x86_64-mageia-linux-gnu-gcc \ x86_64-mageia-linux-gnu-nm \ x86_64-mageia-linux-gnu-ranlib \ x86_64-mageia-linux-gnu-fortran \ ; do ln -sf %{_prefix}/lib/%{name}/bin/$i %{buildroot}%{_bindir}/$i-%{branch} done %files %license gcc/COPYING %doc gcc/*ChangeLog* %if %{build_check} %doc test_summary.log %endif %{_bindir}/* %{_prefix}/lib/%{name}