# --- ROCK-COPYRIGHT-NOTE-BEGIN --- # # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # Please add additional copyright information _after_ the line containing # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by # the ./scripts/Create-CopyPatch script. Do not edit this copyright text! # # ROCK Linux: rock-src/package/base/gcc/gcc.conf # ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. A copy of the GNU General Public # License can be found at Documentation/COPYING. # # Many people helped and are helping developing ROCK Linux. Please # have a look at https://www.rocklinux.org/ and the Documentation/TEAM # file for details. # # --- ROCK-COPYRIGHT-NOTE-END --- pkg_gcc_version=${xpkg#gcc} pkg_gcc_target=${arch_target} pkg_gcc_cross="" case "$xpkg" in gcc?-cross-*|gcc??-cross-*) pkg_gcc_cross="${xpkg#gcc*-cross-}" pkg_gcc_version=${pkg_gcc_version%-cross-*} pkg_gcc_target="${pkg_gcc_cross}-unknown-linux-gnu" var_append confopt " " "--target=$pkg_gcc_target" echo_status "Preparing to build a cross-gcc package for $pkg_gcc_cross." var_append INSTALL_WRAPPER_FILTER "|" 'sed -r "\,/share/(info|locale)/, d"' ;; gcc?|gcc??) ;; *) echo_error "Not supported $pkg package name: $xpkg" exit 1 ;; esac patchfiles="`ls $confdir/gcc$pkg_gcc_version/*.patch \ $confdir/gcc$pkg_gcc_version/*.patch.$arch 2>/dev/null | tr '\n' ' '` $patchfiles" create_links() { for x ; do if [ -f "$root/$prefix/bin/$x-${pkg_gcc_version}" ] ; then rm -vf $root/$prefix/bin/$x ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x fi x="${pkg_gcc_target}-$x" if [ -f $root/$prefix/bin/$x-${pkg_gcc_version} ] ; then rm -vf $root/$prefix/bin/$x ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x fi done } genrockspecs() { # Hint for the reader: # The options are listed in _inverse_ order here. x="$base/build/$ROCKCFG_ID" tr '\n' '@' < specs | sed \ -e "s|@\\*link:@|@*link:@-L $x/usr/$arch_target/lib |" \ -e "s|@\\*link:@|@*link:@-L $x/usr/local/lib |" \ -e "s|@\\*link:@|@*link:@-L $x/usr/lib |" \ -e "s|@\\*link:@|@*link:@-L $x/lib |" \ -e "s|@\\*link:@|@*link:@-L $x/ROCK/tools.cross/$arch_target/lib |" \ -e "s|@\\*link:@|@*link:@-rpath-link $x/lib:$x/usr/lib |" \ -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \ -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/local/include |" \ -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/include |" \ | tr '@' '\n' > specs.cross tr '\n' '@' < specs | sed \ -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /ROCK/tools.cross/$arch_target/lib |" \ -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/$arch_target/lib |" \ -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/local/lib |" \ -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/lib |" \ -e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /lib |" \ -e "s|@\\*link:@|@*link:@-rpath-link /lib:/usr/lib |" \ -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \ -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/local/include |" \ -e "s|@\\*cpp:@|@*cpp:@-I $x/usr/include |" \ | tr '@' '\n' > specs.chroot } custmain() { # Apply the respective gcc-2 or gcc-3 stack protector patch. . $base/package/base/gcc/apply-protector.sh $base gcc${pkg_gcc_version} "$desc_D" hook_eval preconf # In stage 1 we only build a normal c compiler (no c++, etc) # if [ $stagelevel -le 1 ] ; then echo 'Setting LANGUAGES="c" in Makefile.in.' sed -i -e 's/LANGUAGES="[^"]*"/LANGUAGES="c"/g' \ Makefile.in elif [ "$ROCKCFG_DEBUG" = 1 ] ; then if [ -f libstdc++*/configure ] ; then echo "Setting DEBUG_FLAGS='-s' in libstdc++ configure." sed -i -e "s/DEBUG_FLAGS='-g'/DEBUG_FLAGS='-s'/g" libstdc++*/configure fi MAKE="$MAKE LIBGCC2_DEBUG_CFLAGS=-s LDFLAGS=-Wl,-s JCFLAGS=-s" fi # GCC rebuilds itself using the xgcc which is build first. xgcc # should also use the cc-wrapper. It might be better to patch big # ammounts of the gcc sources - but this should also do the job. # export CFLAGS="$(exec -a echo bash \ -c ". gcc-${pkg_gcc_version}" 2> /dev/null)" export CXXFLAGS="$(exec -a echo bash \ -c ". g++-${pkg_gcc_version}" 2> /dev/null)" # echo "Setting \$CFLAGS to '$CFLAGS'." echo "Setting \$CXXFLAGS to '$CXXFLAGS'." mkdir objdir ; cd objdir # We install binaries, info-files and man-pages in temporary # directories so we can rename it (adding version suffix) before # moving them to their final directories. # makeinstopt="" for x in bin info man data ; do mkdir -p $builddir/inst_$x makeinstopt="$makeinstopt ${x}dir=$builddir/inst_$x" done # NAMING VARIANT!? INTRODUCED IN GCC-3.2.1 if [ $arch = powerpc ] ; then ln -s ppc-nocross-linux-gnu powerpc-nocross-linux-gnu fi # add the multi-lib config if [ "$ROCKCFG_MULTILIB" = 1 ] ; then confopt="$confopt --enable-multilib" else confopt="$confopt --disable-multilib" fi # do not install gc headers if [ "$xpkg" != "gcc2" ] ; then sed -i 's, install-includeHEADERS,,;' ../boehm-gc/include/Makefile.in fi # In stage 1 everything is a little bit more complicated # if [ $stagelevel -le 1 ] ; then create_config_cache > config.cache eval $configprefix bash ../configure $confopt --enable-languages=c # creating native libiberty for build system # (needed to build helper apps like gengenrtl) # mkdir -p $arch_build ; cd $arch_build CC=$BUILDCC bash ../../configure make all-libiberty ; cd .. MAKE="$MAKE LANGUAGES=c" # GCC thinks it can share object files between build and # target if the CPUs are compatible, which isn't true if we # are cross-building from glibc to dietlibc. So we also build # helper programs with dietlibc if this is not a cross build # between cpu architectures. # if ! [ "$pkg_dietlibc_useit" = 1 -a "$ROCKCFG_CROSSBUILD" = 0 ] then MAKE="$MAKE CC_FOR_BUILD='$BUILDCC'" fi # Fixincludes doesn't run when cross-building, but we # need a syslimits.h for a working gcc # mkdir -p gcc/include echo '#include_next ' > gcc/include/syslimits.h hook_eval premake # Build and install # eval $MAKE prefix=/$prefix libdir=/$prefix/lib hook_eval inmake eval $MAKE prefix=$root/$prefix $makeinstopt install # This stuff needs manual installation # echo "Creating /$prefix/${pkg_gcc_target} ..." mkdir -p $root/$prefix/${pkg_gcc_target}/lib cd $root/$prefix/${pkg_gcc_target}/lib for x in Mcrt1.o crti.o gcrt1.o crt1.o crtn.o do ln -sf ../../lib/$x . ; done if [ -f ../../../lib/ld-linux-$arch_machine.so.2 ] ; then ln -sf ../../../lib/ld-linux-$arch_machine.so.2 . elif [ -f ../../../lib/ld-linux.so.2 ] ; then ln -sf ../../../lib/ld-linux.so.2 . fi else if [ $xpkg = gcc2 -a "$ROCKCFG_PKG_GCC2_NO_CHILL" != 0 ] ; then # gcc-2.x contains no java compiler confopt="$confopt --enable-languages=c,c++,objc,f77" elif [ "$ROCKCFG_DIETLIBC_ALL" = 1 -o "$ROCKCFG_DIETLIBC_gcc3" = 1 ] ; then # FIXME: c++ and java are not working with dietlibc confopt="$confopt --enable-languages=c,objc" elif [ $xpkg = gcc32 -a "$ROCKCFG_PKG_GCC32_NO_JAVA" != 0 ] || \ [ $xpkg = gcc33 -a "$ROCKCFG_PKG_GCC33_NO_JAVA" != 0 ] || \ [ $xpkg = gcc34 -a "$ROCKCFG_PKG_GCC34_NO_JAVA" != 0 ]; then # gcc-3.x contains no chill compiler confopt="$confopt --enable-languages=c,c++,objc,f77" elif [ "$arch" = mips ] ; then # FIXME: MIPS doesn't like the Java compiler confopt="$confopt --disable-libgcj" fi # See https://gcc.gnu.org/gcc-3.2/c++-abi.html # and https://www.codesourcery.com/cxx-abi/. if [ $xpkg != gcc2 ] ; then confopt="$confopt --enable-__cxa_atexit" fi # Set enable-shared if [ "$diet_dynamic_static" == "static" ] ; then confopt="$confopt --enable-shared=no" else confopt="$confopt --enable-shared=yes" fi # Configure, build and install as usual # eval $configprefix bash ../configure $confopt --with-gnu-as \ --enable-version-specific-runtime-libs \ --with-gnu-ld --enable-threads=posix hook_eval premake if [ $xpkg = gcc34 -a "$ROCKCFG_PKG_GCC34_PROFILED" != 0 ]; then eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap" else eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" all" fi hook_eval inmake eval "$MAKE $makeinstopt install" # Fix the location of any improperly installed (F77) libraries mv -vf $root/$prefix/lib/$gcc_lib_dir/../lib* \ $root/$prefix/lib/$gcc_lib_dir || true fi hook_eval postmake # Rename and install binaries # cd $builddir/inst_bin ; mkdir -p $root/$prefix/bin for y in c++ c++filt g++ cpp f77 g77 gcc gcov ; do for x in $y ${pkg_gcc_target}-$y ; do if [ -f "$x" ] ; then mv -v $x $root/$prefix/bin/${x}-${pkg_gcc_version} fi done done # gcc2 does not contain an own c++filt ... - so use the binutils one # if [ "$xpkg" = gcc2 ] ; then ln -vsf $root/$prefix/bin/c++filt-2 c++filt-binutils fi # Rename and install info-files # cd $builddir/inst_info ; mkdir -p $root/$prefix/info for x in * ; do [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow fn=$( echo $x | sed "s,\([a-z0-9]*\),\1-${pkg_gcc_version}," ) infoname=$( echo $x | sed "s,\([a-z0-9]*\).*,\1," ) echo "$x -> $root/$prefix/info/$fn" sed "s,$infoname.info,$infoname-${pkg_gcc_version}.info," < $x \ > $root/$prefix/info/$fn if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then cp -v $x $root/$prefix/info/$x fi true done # Rename and install man-pages # cd $builddir/inst_man/man1 mkdir -p $root/$prefix/man/man1 for x in * ; do [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow mv -v $x $root/$prefix/man/man1/${x%.1}-${pkg_gcc_version}.1 if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then ln -sf ${x%.1}-${pkg_gcc_version}.1 $root/$prefix/man/man1/$x fi true done # Rename and install locales # if [ -d "$builddir/inst_data/locale" ] ; then cd $builddir/inst_data/locale for x in */LC_MESSAGES/*.mo ; do [ ! -f "$x" ] && continue # e.g. if $x becomes '*' somehow y="$root/$prefix/share/locale/$x" y="${y%.mo}-${pkg_gcc_version}.mo" mkdir -p ${y%/*} echo "$x -> $y" mv $x $y if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then echo "symlink $x -> $y" ln -svf ${y##*/} $root/$prefix/share/locale/$x fi true done fi hook_eval postdoc # Create various symlinks for cc, c++, cpp and f77. # if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then create_links gcc cpp gcov rm -f $root/$prefix/bin/cc if [ "$ROCKCFG_DIETLIBC_ALL" = 1 ]; then cat <<- 'EOT' > $root/$prefix/bin/cc #!/bin/sh exec diet gcc "$@" EOT chmod +x $root/$prefix/bin/cc else ln -svf gcc $root/$prefix/bin/cc fi ln -vsf ../$prefix/bin/cpp $root/lib/cpp fi ln -sf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc-${pkg_gcc_version} if [ $ROCKCFG_DEFAULT_KCC = $xpkg ] ; then ln -vsf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc fi if [ $ROCKCFG_DEFAULT_CXX = $xpkg ] ; then create_links c++ c++filt g++ fi if [ $ROCKCFG_DEFAULT_F77 = $xpkg ] ; then create_links g77 if [ -f $root/$prefix/bin/g77 ] ; then rm -vf $root/$prefix/bin/f77 ln -vsf g77 $root/$prefix/bin/f77 fi fi # Inject our default optimisation options so when the user calls # gcc/g++ they match the ones used to precompile the headers ... # Save the options affectioning optimization only. # if [ $ROCKCFG_DEFAULT_CC = $xpkg ]; then echo "Creating /etc/profile.d/gcc ..." { echo "export CFLAGS_SIZE=\"$(echo $( eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' ))\"" echo "export CFLAGS_SPEED=\"$(echo $( eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' ))\"" echo "export CFLAGS=\"\$CFLAGS_SIZE\"" } > $root/etc/profile.d/gcc fi if [ $ROCKCFG_DEFAULT_CXX = $xpkg ]; then echo "Creating /etc/profile.d/gxx ..." { echo "export CXXFLAGS_SIZE=\"$(echo $( eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' ))\"" echo "export CXXFLAGS_SPEED=\"$(echo $( eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ \$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ -e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' ))\"" echo "export CXXFLAGS=\"\$CFLAGS_SIZE\"" } > $root/etc/profile.d/gxx fi # Create symlinks for runtime libraries so they can be found by # the dynamic loader and force rebuilding of the wrapper links # if [ $stagelevel -gt 1 ] ; then [ $ROCKCFG_DEFAULT_CC = $xpkg ] && \ ( mkdir -p $root/$prefix/lib ; cd $root/$prefix/lib ; \ ln -vfs ${gcc_lib_dir}/*.so.* . ; ) rm -fv $base/build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate fi if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then echo "Adapting gcc specs file..." cd $root/$prefix/lib/${gcc_lib_dir} genrockspecs # echo "Linking gcc libs to tools.cross..." # cd $root/ROCK/tools.cross/lib/${gcc_lib_dir}/ # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.a . # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.la . # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so . # ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so.* . fi true } gcc_cross() { # Apply the respective gcc-2 or gcc-3 stack protector patch. . $base/package/base/gcc/apply-protector.sh $base gcc${pkg_gcc_version} "$desc_D" mkdir -p $root/$prefix/$pkg_gcc_target/{bin,lib} if [ "$stagelevel" -eq 0 ] then rm -f $root/$prefix/$pkg_gcc_target/include if [ -f $root/$prefix/include/stdio.h ]; then ln -s ../include $root/$prefix/$pkg_gcc_target/include elif [ -f $root/$prefix/diet-include/stdio.h ]; then ln -s ../diet-include $root/$prefix/$pkg_gcc_target/include fi bindir="$root/$prefix/crosscc" mkdir -p $root/$prefix/crosscc fi if [ "$pkg_gcc_version" != "2" ]; then if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then confopt="$confopt --enable-languages=c,c++" else confopt="$confopt --enable-languages=c" fi fi mkdir objdir ; cd objdir ; hook_eval preconf eval bash ../configure --program-prefix=${pkg_gcc_target}- --disable-cpp \ --disable-shared --disable-multilib $confopt if [ -d libiberty ]; then make -C libiberty; fi if [ -d texinfo ]; then make -C texinfo; fi hook_eval premake if [ "$xpkg" = "gcc2" ] ; then make -C gcc all LANGUAGES="c" hook_eval inmake make -C gcc install LANGUAGES="c" else # workaround for at least gcc-3.2.3 mkdir -p $root/$prefix/lib/${gcc_lib_dir} if [ -d gcc ]; then make -C gcc all hook_eval inmake make -C gcc install else make all-gcc hook_eval inmake make install-gcc fi fi hook_eval postmake if [ -f $root/$prefix/lib/${gcc_lib_dir}/libgcc.a ]; then ${pkg_gcc_target}-ranlib \ $root/$prefix/lib/${gcc_lib_dir}/libgcc.a fi if [ "$stagelevel" -eq 0 ]; then x="$root/$prefix/crosscc/${arch_target}" ln -svf ${arch_target}-gcc $x-gcc-${pkg_gcc_version} ln -svf ${arch_target}-g++ $x-g++-${pkg_gcc_version} ln -svf ${arch_target}-gcc $x-kcc-${pkg_gcc_version} ln -svf ${arch_target}-gcc $x-kcc ln -svf ${arch_target}-gcc $x-cc rm -vf "$root/$prefix/crosscc/gcc" rm -vf "$root/$prefix/crosscc/gcj" cd $root/$prefix/$arch_target/lib for x in Mcrt1.o crt1.o crti.o crtn.o gcrt1.o \ libc.a libc.so libc_nonshared.a do if [ ! -e $x ]; then ln -fvs $root/../../usr/lib/$x $x fi done for x in ld-linux{,-$arch_machine}.so.2 ld.so.1 libc.so.{6,6.1} do ln -fvs $root/../../lib/$x $x ; done # glibc uses -lgcc_s with --as-needed, which fails if libgcc_s.{so,a} # is not even there. -- clifford & fake # # the shared object is not really needed. #if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so ]; then # ${pkg_gcc_target}-gcc -shared -nostdlib \ # -o $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so -x c /dev/null #fi if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a ]; then ${pkg_gcc_target}-gcc -x c /dev/null -c -o null.o ${pkg_gcc_target}-ar q null.a null.o; rm -f null.o ${pkg_gcc_target}-ranlib null.a mv null.a $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a fi rm -f $root/$prefix/.lastupdate fi if [ "$stagelevel" -eq 0 -o "$ROCKCFG_PSEUDONATIVE" = 1 ]; then echo "Adapting gcc specs file..." cd $root/$prefix/lib/${gcc_lib_dir} genrockspecs fi true } if [ "$stagelevel" -eq 0 -o -n "$pkg_gcc_cross" ] then custmain="gcc_cross" else custmain="custmain" fi gcc_lib_dir="gcc-lib/${pkg_gcc_target}/${ver%%-*}" [ $pkg_gcc_version = 34 ] && gcc_lib_dir="gcc/${pkg_gcc_target}/${ver%%-*}"