source: scripts/scripts/native-scripts/native-gcc.sh @ ad31873f

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since ad31873f was ad31873f, checked in by Jim Gifford <clfs@…>, 18 years ago

r2539@server (orig r1260): ryan | 2006-03-10 06:07:41 -0800

r1336@rei: lfs | 2006-03-11 01:06:05 +1100
Add GCC PR20425 fixes to 4.1.0 release.
This fixes a multitude of sins, most noticably with libtool on multilib systems.
Iterative path searches the gcc driver performs should now search multilib directories first.


Submitted By: Ryan Oliver <ryan at pha dot com dot au>
Date: 2006-03-10
Initial Package Version: 4.1.0
Origin: GCC SVN Revision 108635 (diffed against 4.1.0 release)
Upstream Status: In GCC trunk
Description: Fix for PR20425


From http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00818.html
---------------------------------8<------------------------------------
This gives the gcc driver a new path iteration function, for_each_path,
and uses it everywhere, making path iteration a little more consistent.
for_each_path uses the same path ordering as the existing find_file
function. I've also tweaked some of the existing find_a_file calls for
consistency, and uncovered and fixed some other bugs..


Functional changes are:


o %D library paths are printed in the same order as gcc uses elsewhere

when searching library directories, ie. all multilib paths are first.
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg02044.html effectively
reverted by the rewrite because I believe the same speedup is gained
by searching the right dirs first.


o gcc -print-search-dirs prints library multilib paths followed by

non-multilib paths where before we just printed non-multilib paths.


o LIBRARY_PATH_ENV similarly includes multilib directories.


o All searches of startfile_prefixes now look in multilib dirs first

followed by non-multilib dirs. This changes the dirs we search for
spec files, and %include and %include_noerr in specs. Previously
we only searched the non-multilib dirs for specs files. I think this
change is worthwhile just for consistency, and the extension is
reasonable. For instance, it would allow different spec files to be
used for gcc -m64 vs. gcc -m32. However, if others think this wrong,
I won't argue. Consistency isn't everything.


o Some attempt made to prevent searching of duplicate paths. The old

find_file would search some paths twice (when multilib_dir was NULL
but multilib_os_dir non-NULL). We still search twice in some cases,
eg. /usr/lib/../lib and /usr/lib are considered different paths.


o find_a_file with last param (do_multi) true now searches both

multilib and non-multilib paths. Before, do_multi (well, the old
param name was multilib) meant just search multilib paths. This
isn't a user-visible change as the only place where find_a_file was
invoked with the last param true was from find_file, where we
immediately followed with a non-multilib find_a_file.


o Memory leaks fixed in is_directory.


o LIBRARY_PATH_ENV and COMPILER_PATH now only have existing

directories, making LIBRARY_PATH_ENV closer to %D paths. The
following lines (which I remove) in is_directory meant that
is_directory didn't do much for LIBRARY_PATH_ENV, except on
SMALL_ARG_MAX machines.


4278 ian #ifndef SMALL_ARG_MAX
4278 ian if (! linker)
4278 ian return 1;
4278 ian #endif


I'll also remove mention of SMALL_ARG_MAX in config and doc files
when I commit this change as this is the only place it is used.


o gcc -Bnon-dir-prefix- now works properly. The previously mentioned

is_directory peculiarity affected the following code.


43664 nickc /* Catch the case where the user has forgotten to append a
46063 jsm28 directory separator to the path. Note, they may be using
43664 nickc -B to add an executable name prefix, eg "i386-elf-", in
43664 nickc order to distinguish between multiple installations of
43664 nickc GCC in the same directory. Hence we must check to see
43664 nickc if appending a directory separator actually makes a
43664 nickc valid directory name. */
43664 nickc if (! IS_DIR_SEPARATOR (value [len - 1])
43664 nickc && is_directory (value, "", 0))
43664 nickc {
43767 ghazi char *tmp = xmalloc (len + 2);
43767 ghazi strcpy (tmp, value);
43767 ghazi tmp[len] = DIR_SEPARATOR;
43767 ghazi tmp[++ len] = 0;
43767 ghazi value = tmp;
43664 nickc }


Bootstrapped and regression tested powerpc64-linux and powerpc-linux on
a previous iteration of this patch missing is_directory fixes.
Currently running tests on this patch.



  • Property mode set to 100755
File size: 9.6 KB
Line 
1#!/bin/bash
2
3# cross-lfs native gcc build
4# --------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9#
10
11cd ${SRC}
12
13LOG="gcc-native.log"
14
15set_libdirname
16setup_multiarch
17
18unpack_tarball gcc-${GCC_VER}
19
20if [ ! "${libdirname}" = "lib" ]; then
21   extra_conf="--libdir=/usr/${libdirname}"
22fi
23
24#3.0 20030427
25# Cannot trust ${GCC_VER} to supply us with the correct
26# gcc version (especially if cvs).
27# Grab it straight from version.c
28cd ${SRC}/${PKGDIR}
29target_gcc_ver=`grep version_string gcc/version.c | \
30                sed 's@.* = \(\|"\)\([0-9.]*\).*@\2@g'`
31# As of gcc4, the above doesn't cut it... check gcc/BASE-VER
32if [ -z "${target_gcc_ver}" -a -f gcc/BASE-VER ]; then
33   target_gcc_ver=`cat gcc/BASE-VER`
34fi
35
36# if target has no floating point unit, use soft float
37if [ "${WITHOUT_FPU}" = "Y" ]; then
38   extra_conf="${extra_conf} --with-float=soft"
39fi
40
41if [ ! "Y" = "${MULTIARCH}" ]; then
42   # If we are not multi-arch, disable multilib
43   extra_conf="${extra_conf} --enable-multilib=no"
44
45   # HACK: this sets abi to n32 with mips... this should be handled
46   # by the multiarch funcs somehow... and set according to DEFAULTENV
47   case ${TGT_ARCH} in
48      mips* )
49         extra_conf="${extra_conf} --with-abi=${DEFAULTENV}"
50      ;;
51   esac
52fi
53
54# if we are using gcc-3.4x, set libexecdir to /usr/${libdirname}
55case ${target_gcc_ver} in
56   3.4* | 4.* )
57      extra_conf="${extra_conf} --libexecdir=/usr/${libdirname}"
58   ;;
59esac
60
61# Set in build-init to enable version specific runtime libs, and whether
62# to use a program suffix
63if [ "Y" = "${USE_VER_SPEC_RT_LIBS}" ]; then
64   extra_conf="${extra_conf} --enable-version-specific-runtime-libs" ; fi
65if [ "Y" = "${USE_PROGRAM_SUFFIX}" ]; then
66   extra_conf="${extra_conf} --program-suffix=-${target_gcc_ver}" ; fi
67
68cd ${SRC}/${PKGDIR}
69case ${target_gcc_ver} in
70   3.4.3 )
71      # Apply linkonce patch for gcc (should be fixed come gcc 3.4.4)
72      apply_patch gcc-3.4.3-linkonce-1
73      # Remove library search paths that cause issues with libtool on
74      # multi-arch systems
75      # TODO: check to see if this applies to ealier gcc versions, and
76      #       decide if this should only be applied if doing a multi-archi
77      #       build
78      apply_patch gcc-3.4.3-remove_standard_startfile_prefix_from_startfile_prefixes-1
79
80      # Arm fixes
81      apply_patch gcc-3.4.0-arm-bigendian
82      apply_patch gcc-3.4.0-arm-nolibfloat
83      apply_patch gcc-3.4.0-arm-lib1asm
84   ;;
85   4.0.0 )
86      apply_patch gcc-4.0.0-fix_tree_optimisation_PR21173
87      apply_patch gcc-4.0.0-reload_check_uninitialized_pseudos_PR20973
88      apply_patch gcc-4.0.0-remove_standard_startfile_prefix_from_startfile_prefixes-1
89   ;;
90   4.1.0 )
91      apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1
92      apply_patch gcc-4.1.0-fix_PR20425
93   ;;
94   4.0.* | 4.1.* )
95      apply_patch gcc-4.0.0-remove_standard_startfile_prefix_from_startfile_prefixes-1
96   ;;
97esac
98
99
100# Dont run fixincludes
101# ( Following mimics the nofixincludes patch )
102# NOTE: This needs to be fixed for gcc4
103# Also avoid debug symbols in libgcc2
104cd ${SRC}/${PKGDIR}/gcc
105
106test -f Makefile.in-ORIG ||
107   cp Makefile.in Makefile.in-ORIG
108                                                                               
109#grep -Ev '(README| ./fixinc.sh )' Makefile.in-ORIG | \
110sed 's@LIBGCC2_DEBUG_CFLAGS = -g@LIBGCC2_DEBUG_CFLAGS =@g' Makefile.in-ORIG \
111   > Makefile.in
112
113# Problems arise when building 64bit libgcc_s during a multilib
114# build if the 64bit crt objects reside under */lib64 as
115# -B${HST_TOOLS}/${TARGET}/lib is passed during the build causing
116# us to link in the 32bit crt objects.,
117# This is because -B*/lib overrides the specs file so the  multilib
118# spec isnt used to determine lib dir.
119# Here we just remove -B*/lib from FLAGS_FOR_TARGET.
120#
121# NOTE: for gcc-3.3.3 all we had do edit was configure.in,
122#       FLAGS_FOR_TARGET was only specified here.
123#       As of gcc-3.4.0 we need to edit configure itself.
124#       So, we'll just attempt to edit both
125
126cd ${SRC}/${PKGDIR}
127for file in configure configure.in; do
128   grep FLAGS_FOR_TARGET ${file} > /dev/null 2>&1 &&
129   {
130      # copy instead of move, we will want to retain perms
131      test -f ${file}-ORIG ||
132         cp -p ${file} ${file}-ORIG
133
134      sed '/FLAGS_FOR_TARGET.*\/lib\//s@-B[^ ]*/lib/@@g' \
135         ${file}-ORIG > ${file}
136   }
137done
138
139test -d ${SRC}/gcc-${GCC_VER}-native &&
140   rm -rf ${SRC}/gcc-${GCC_VER}-native
141
142mkdir -p ${SRC}/gcc-${GCC_VER}-native &&
143cd ${SRC}/gcc-${GCC_VER}-native &&
144
145max_log_init Gcc ${GCC_VER} native ${CONFLOGS} ${LOG}
146CC="${CC-gcc} ${ARCH_CFLAGS}" \
147CXX="${CXX-g++} ${ARCH_CFLAGS}" \
148CFLAGS="-O2 -pipe ${TGT_CFLAGS}" \
149CXXFLAGS="-O2 -pipe ${TGT_CFLAGS}" \
150../${PKGDIR}/configure --prefix=/usr \
151   --host=${TARGET} \
152   --enable-languages=c,c++ --enable-__cxa_atexit \
153   --enable-c99 --enable-long-long --enable-threads=posix \
154   --enable-shared ${extra_conf} \
155   --mandir=/usr/share/man \
156   --infodir=/usr/share/info \
157   >> ${LOGFILE} 2>&1 &&
158echo " o Configure OK" || barf
159#   --enable-languages=c,c++,f77,objc,ada,java,pascal,treelang --enable-__cxa_atexit \
160
161min_log_init ${BUILDLOGS} &&
162if [ "Y" = "${NOBOOTSTRAP}" ]; then
163   make ${PMFLAGS} LDFLAGS="-s" \
164      >> ${LOGFILE} 2>&1
165else 
166   make ${PMFLAGS} BOOT_LDFLAGS="-s" BOOT_CFLAGS="-O2 -pipe ${TGT_CFLAGS}" \
167      STAGE1_CFLAGS="-O2 -pipe ${TGT_CFLAGS}" bootstrap \
168      >> ${LOGFILE} 2>&1
169fi && 
170echo " o Build OK" || barf
171
172min_log_init ${TESTLOGS} &&
173make -k check \
174   >> ${LOGFILE} 2>&1 &&
175echo " o Test OK" || errmsg
176
177min_log_init ${INSTLOGS} &&
178make install \
179   >> ${LOGFILE} 2>&1 &&
180echo " o Install OK" || barf
181
182#3.0 20030503
183# Create symlinks if we chose to add a version suffix
184if [ "Y" = "${USE_PROGRAM_SUFFIX}" ]; then
185   for prog in c++ c++filt cpp g++ gcc gccbug gcov ; do
186      if [ -f /usr/bin/${prog}-${target_gcc_ver} ]; then
187         echo " o Creating ${prog} -> ${prog}-${target_gcc_ver} symlink..."
188         ln -sf ${prog}-${target_gcc_ver} /usr/bin/${prog}
189      fi
190   done
191   for prog in gcc g++ c++ ; do
192      if [ -f /usr/bin/${TARGET}-${prog}-${target_gcc_ver} ]; then
193         echo " o Creating ${TARGET}-${prog} -> ${TARGET}-${prog}-${target_gcc_ver} symlink ..."
194         ln -sf ${TARGET}-${prog}-${target_gcc_ver} \
195            /usr/bin/${TARGET}-${prog}
196      fi
197   done
198fi # USE_PROGRAM_SUFFIX
199
200ln -s ../usr/bin/cpp /lib &&
201ln -sf gcc /usr/bin/cc
202rm /usr/${libdirname}/libiberty.a
203
204# Following req'd when using --enable-version-specific-runtime-libs
205if [ Y = "${USE_VER_SPEC_RT_LIBS}" ]; then
206   # TODO: BIG TODO HERE
207   #       MAKE THIS HANDLE "libdirname"
208   #       -----------------------------
209   #       look into gcc_libdir/../lib/libdirname symlinks for multiarch
210   #       This is appropriate for x86_64, bit others need to be checked...
211   #       We will also in the future want to modify these default gcc .so
212   #       install directories
213   #
214
215   gcc_libdir=`/usr/bin/gcc --print-file-name include | \
216            sed 's@include@@g'`
217
218   # Better make a symlink for the c++ includes
219   mkdir /usr/include/c++
220   ln -s ${gcc_libdir}/include/c++ /usr/include/c++/${target_gcc_ver}
221                                                                               
222   # Add the path to our new c++ libs in /etc/ld.so.conf
223   echo "${gcc_libdir}" >> /etc/ld.so.conf
224   if [ Y = "${MULTIARCH}" ]; then 
225      echo "${gcc_libdir}/32" >> /etc/ld.so.conf
226   fi
227
228   # TODO: choose whether to just delete existing libgcc_s.so links pointing to
229   # ${TOOLS} or just create the following over the top
230                                                                               
231   # Create hardlink and symlinks for libgcc_s in /usr/lib
232   case ${target_gcc_ver} in
233      3.4* | 4.* )
234         if [ Y = "${MULTIARCH}" ]; then
235            # 32bit libs
236            ln -f ${gcc_libdir}/../lib/libgcc_s.so.1 \
237               /usr/lib/libgcc_s-${target_gcc_ver}.so.1
238            ln -sf libgcc_s-${target_gcc_ver}.so.1 \
239               /usr/lib/libgcc_s.so.1
240            ln -sf libgcc_s.so.1 /usr/lib/libgcc_s_32.so
241            ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
242            # 64bit libs
243            ln -f ${gcc_libdir}/../lib64/libgcc_s.so.1 \
244               /usr/lib64/libgcc_s-${target_gcc_ver}.so.1
245            ln -sf libgcc_s-${target_gcc_ver}.so.1 \
246               /usr/lib64/libgcc_s.so.1
247            ln -sf libgcc_s.so.1 /usr/lib64/libgcc_s.so
248         else
249            ln -f ${gcc_libdir}/../lib/libgcc_s.so.1 \
250               /usr/lib/libgcc_s-${target_gcc_ver}.so.1
251            ln -sf libgcc_s-${target_gcc_ver}.so.1 /usr/lib/libgcc_s.so.1
252            ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
253         fi
254      ;;
255      * )
256         # TODO: Have to check this for gcc < 3.4   
257         ln -f ${gcc_libdir}/libgcc_s.so.1 \
258            /usr/${libdirname}/libgcc_s-${target_gcc_ver}.so.1
259         if [ Y = "${MULTIARCH}" ]; then
260            # 32bit libs
261            ln -f ${gcc_libdir}/32/libgcc_s.so.1 \
262               /usr/lib/libgcc_s-${target_gcc_ver}.so.1
263            ln -sf libgcc_s-${target_gcc_ver}.so.1 \
264               /usr/lib/libgcc_s.so.1
265            ln -sf libgcc_s.so.1 /usr/lib/libgcc_s_32.so
266            ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
267            # 64bit libs
268            ln -f ${gcc_libdir}/libgcc_s.so.1 \
269               /usr/lib64/libgcc_s-${target_gcc_ver}.so.1
270            ln -sf libgcc_s-${target_gcc_ver}.so.1 \
271               /usr/lib64/libgcc_s.so.1
272            ln -sf libgcc_s.so.1 /usr/lib64/libgcc_s.so
273         else
274            ln -f ${gcc_libdir}/libgcc_s.so.1 \
275               /usr/lib/libgcc_s-${target_gcc_ver}.so.1
276            ln -sf libgcc_s-${target_gcc_ver}.so.1 \
277               /usr/lib/libgcc_s.so.1
278            ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
279         fi
280      ;;
281   esac
282
283fi
Note: See TracBrowser for help on using the repository browser.