1.1 --- a/gcc/gcc.spec Tue Mar 29 19:46:35 2011 +0200 1.2 +++ b/gcc/gcc.spec Tue Mar 29 20:04:34 2011 +0200 1.3 @@ -131,8 +131,11 @@ 1.4 -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \ 1.5 `find . -name Makefile.in -type f -print` 1.6 fi 1.7 + %{l_shtool} subst \ 1.8 + -e 's;^\(do-compare\) *\(=.*\);#\1-shouldnt-be-defined-here \2;' \ 1.9 + config/*.mk 1.10 case "%{l_platform -t}" in 1.11 - amd64*-linux* ) 1.12 + amd64-linux* ) 1.13 %{l_shtool} subst \ 1.14 -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \ 1.15 -e 's/test x.gcc_no_link = xyes/false/g' \ 1.16 @@ -144,21 +147,19 @@ 1.17 libstdc++-v3/include/ext/codecvt_specializations.h 1.18 1.19 %build 1.20 - # create build sub-directory 1.21 + # create build subdirectory 1.22 %{l_shtool} mkdir -p obj 1.23 cd obj 1.24 1.25 - # solve strange compatability problems 1.26 + # locate ld(1) and as(1) accordingly 1.27 %if "%{with_binutils}" == "yes" 1.28 - # determine ld(1) and as(1) usage, allowing either 1.29 - # one to be from the GNU distribution of binutils 1.30 + # allow OpenPKG binutils 1.31 LD=%{l_tool_locate ld ld} 1.32 AS=%{l_tool_locate as as} 1.33 %else 1.34 - # locate ld(1) and as(1), using the GNU assembler 1.35 - # but ignoring the presence of any OpenPKG linker 1.36 - LD=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin which ld` 1.37 - AS=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin which as` 1.38 + # ignore OpenPKG binutils 1.39 + LD=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin:/usr/local/bin:/usr/local/sbin which ld` 1.40 + AS=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin:/usr/local/bin:/usr/local/sbin which as` 1.41 %endif 1.42 l_with_gnu_ld_as="" 1.43 echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="--with-ld=$LD" 1.44 @@ -166,14 +167,14 @@ 1.45 $LD --version </dev/null 2>/dev/null | grep "^GNU ld " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld" || l_with_gnu_ld_as="${l_with_gnu_ld_as} --without-gnu-ld" 1.46 $AS --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as" || l_with_gnu_ld_as="${l_with_gnu_ld_as} --without-gnu-as" 1.47 1.48 - # determine threads usage 1.49 + # determine threads use 1.50 %if "%{with_threads}" == "yes" 1.51 l_enable_threads="posix" 1.52 %else 1.53 l_enable_threads="single" 1.54 %endif 1.55 1.56 - # determine language usage 1.57 + # determine language use 1.58 l_enable_languages="c" 1.59 %if "%{with_cxx}" == "yes" 1.60 l_enable_languages="${l_enable_languages},c++" 1.61 @@ -188,14 +189,14 @@ 1.62 l_enable_languages="${l_enable_languages},f95" 1.63 %endif 1.64 1.65 - # disable GNU iconv usage 1.66 + # disable GNU iconv use 1.67 ( echo "am_cv_func_iconv=no" 1.68 echo "am_cv_lib_iconv=no" 1.69 ) >config.cache 1.70 - 1.71 - # platform specific config logic 1.72 + # platforms failing 'compare' make target (see prep as well) 1.73 case "%{l_platform -t}" in 1.74 - *i?86-sunos* ) echo "gcc_cv_prog_cmp_skip=true" >>config.cache;; 1.75 + *i?86-sunos* ) echo "gcc_cv_prog_cmp_skip=true" >>config.cache ;; 1.76 + *amd64-linux* ) echo "gcc_cv_prog_cmp_skip=true" >>config.cache ;; 1.77 esac 1.78 1.79 # configure the package 1.80 @@ -259,50 +260,67 @@ 1.81 l_libcxxflags="$l_libcxxflags -pipe" 1.82 } 1.83 %if "%{with_optimize}" == "yes" 1.84 + # GCC authors are not keeping up with optimized portability expectations 1.85 + ( echo "As GCC advances its optimization logic becomes increasingly complex (and" 1.86 + echo "buggy?) Since at least GCC 4.5, problems have been reported using arguments" 1.87 + echo "-O, -mtune, or -march implicitly or explicitly during different bootstrap" 1.88 + echo "stages as well as stage comparison and even the final installation." 1.89 + echo "" 1.90 + echo "Pay attention when building on one computer and installing on another as" 1.91 + echo "problems may be platform specific. If in doubt, disable optimization." 1.92 + ) | %{l_rpmtool} msg -b -t warn 1.93 if [ ".$l_ccisgcc" = .yes ]; then 1.94 - l_ia32=native 1.95 + l_archia32=native; l_archia64=native; l_archamd64=native 1.96 else 1.97 - l_ia32=pentium3 1.98 + # CPU native detection only works with GCC (see driver-i386.c) 1.99 + ( echo "Platform specific optimization is enabled, but detection of appropriate" 1.100 + echo "native architecture is only possible when bootstrapping GCC using a pre-" 1.101 + echo "installed GCC. The current build is using a different compiler, so to" 1.102 + echo "provide any optimization at all a wild guess is made and a CPU type" 1.103 + echo "hardcoded instead of using accurate native detection." 1.104 + echo "" 1.105 + echo "To achieve accurate optimization of GCC please install GCC first. Then" 1.106 + echo "build this package a second time which will use GCC to bootstrap itself." 1.107 + ) | %{l_rpmtool} msg -b -t notice 1.108 + 1.109 + # guess lowest common denominator CPU types 1.110 + # http://en.wikipedia.org/wiki/(X86|X64-64) 1.111 + # http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html 1.112 + l_archia32=pentium3; l_archia64=nocona; l_archamd64=k8 1.113 fi 1.114 + # this optimization logic is unportable and could cause problems 1.115 + # if installing the resulting binary package on a different host! 1.116 case "%{l_platform -t}" in 1.117 - *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=$l_ia32" ;; 1.118 *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;; 1.119 + *sun-* ) l_boot_cflags="$l_boot_cflags -mtune=v8" ;; 1.120 + *i?86-* ) l_boot_cflags="$l_boot_cflags -march=$l_archia32" ;; 1.121 + *ia64-* ) l_boot_cflags="$l_boot_cflags -march=$l_archia64" ;; 1.122 + *amd64-* ) l_boot_cflags="$l_boot_cflags -march=$l_archamd64" ;; 1.123 + * ) l_boot_cflags="$l_boot_cflags -mtune=generic" ;; 1.124 esac 1.125 l_cflags="$l_cflags -O" 1.126 l_boot_cflags="$l_boot_cflags -O3 -fomit-frame-pointer" 1.127 l_libcxxflags="$l_libcxxflags -O3 -fno-implicit-templates" 1.128 %else 1.129 -%if "%{with_optimize}" == "port" 1.130 - # conservatively optimize the generated program code for portable use, 1.131 - # also _tune_ for particular CPUs, but _without_ requiring these CPUs! 1.132 - case "%{l_platform -t}" in 1.133 - *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=generic" ;; 1.134 - *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v8" ;; 1.135 - esac 1.136 - l_cflags="$l_cflags -O" 1.137 - l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer" 1.138 - l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates" 1.139 -%else 1.140 - # do not optimize at all to avoid problems 1.141 + # don't optimize at all to avoid problems 1.142 l_boot_cflags="$l_boot_cflags -O0" 1.143 l_libcxxflags="$l_libcxxflags -O0" 1.144 %endif 1.145 -%endif 1.146 +%if "%{with_profile}" == "yes" 1.147 + maketarget="profiledbootstrap" 1.148 + loc_makeflags="%{l_mflags}" 1.149 + if [ ".$l_ccisgcc" != .yes ]; then 1.150 + ( echo "A preinstalled GCC is recommended when bootstrapping a profiled GCC. If the" 1.151 + echo "compiler used to bootstrap GCC doesn't support 64-bit arithmetic, then" 1.152 + echo "either runtime or buildtime errors could occur. Regardless of this," 1.153 + echo "parallel make logic is disabled according to profiling requirements." 1.154 + echo "" 1.155 + echo "If in doubt, stop now and start the build again with profiling disabled." 1.156 + ) | %{l_rpmtool} msg -b -t warn 1.157 + fi 1.158 +%else 1.159 maketarget="bootstrap" 1.160 -%if "%{with_profile}" == "yes" 1.161 - # GCC >= 3.4 supports a "profiledbootstrap" target to build an 1.162 - # optimized version of itself through profiling. Because this 1.163 - # requires a (bootstrapping) C compiler with 64-bit arithmetic, 1.164 - # the whole approach is currently supported only if already 1.165 - # building with GCC as the bootstrapping C compiler. 1.166 - if [ ".$l_ccisgcc" = .yes ]; then 1.167 - maketarget="profiledbootstrap" 1.168 - else 1.169 - ( echo "Building a profiled GCC requires GCC. Please install GCC" 1.170 - echo "first and then build again with the profile option enabled." 1.171 - ) | %{l_rpmtool} msg -b -t error 1.172 - exit 1 1.173 - fi 1.174 + loc_makeflags="%{l_mflags -O}" 1.175 %endif 1.176 case "%{l_platform -t}" in 1.177 *64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;; 1.178 @@ -315,10 +333,10 @@ 1.179 %endif 1.180 1.181 # build the package 1.182 - MAKE="%{l_make} %{l_mflags -O}" \ 1.183 - %{l_make} %{l_mflags -O} \ 1.184 + MAKE="%{l_make} ${loc_makeflags}" \ 1.185 + %{l_make} ${loc_makeflags} \ 1.186 GREP="grep" \ 1.187 - MAKE="%{l_make} %{l_mflags -O}" \ 1.188 + MAKE="%{l_make} ${loc_makeflags}" \ 1.189 BOOT_CFLAGS="${l_boot_cflags}" \ 1.190 CFLAGS="${l_cflags}" \ 1.191 CXXFLAGS="${l_cxxflags}" \