source: scripts/scripts/cross-scripts/cross-gcc-shared.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: 5.4 KB
Line 
1#!/bin/bash
2
3# cross-lfs cross-gcc w shared libgcc build
4# -----------------------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9#
10
11cd ${SRC}
12
13LOG="gcc-cross-shared.log"
14
15if [ "Y" = "${MULTIARCH}" ]; then
16
17   vendor_os=`echo ${TARGET} | sed 's@\([^-]*\)-\(.*\)@\2@'`
18
19   case ${TGT_ARCH} in
20      x86_64 )
21      ;;
22      sparc* )
23         TARGET=sparc64-${vendor_os}
24      ;;
25      powerpc* | ppc* )
26         TARGET=powerpc64-${vendor_os}
27      ;;
28      s390* )
29         TARGET=s390x-${vendor_os}
30      ;;
31      mips*el* )
32         TARGET=mips64el-${vendor_os}
33      ;;
34      * )
35         # TODO: add some error messages etc
36         barf
37      ;;
38   esac
39
40else
41   # If we are not bi-arch, disable multilib
42   extra_conf="--enable-multilib=no"
43
44   # HACK: this sets abi to n32 with mips... this should be handled
45   # by the multiarch funcs somehow... and set according to DEFAULTENV
46   case ${TGT_ARCH} in
47      mips* )
48         extra_conf="${extra_conf} --with-abi=${DEFAULTENV}"
49      ;;
50   esac
51fi
52
53# if target is same as build host, adjust host slightly to
54# trick configure so we do not produce native tools
55if [ "${TARGET}" = "${BUILD}" ]; then
56#   extra_conf="--host=${BUILD}x"
57   althost=`echo ${BUILD} | sed 's@\([_a-zA-Z0-9]*\)\(-[_a-zA-Z0-9]*\)\(.*\)@\1\2x\3@'`
58   extra_conf="--host=${althost} ${extra_conf}"
59fi
60
61# if target has no floating point unit, use soft float
62if [ "${WITHOUT_FPU}" = "Y" ]; then
63   extra_conf="${extra_conf} --with-float=soft"
64fi
65
66unpack_tarball gcc-${GCC_VER}
67
68#3.0 20030427
69# Cannot trust ${GCC_VER} to supply us with the correct
70# gcc version (especially if cvs).
71# Grab it straight from version.c
72cd ${SRC}/${PKGDIR}
73target_gcc_ver=`grep version_string gcc/version.c | \
74                sed 's@.* = \(\|"\)\([0-9.]*\).*@\2@g'`
75# As of gcc4, the above doesn't cut it... check gcc/BASE-VER
76if [ -z "${target_gcc_ver}" -a -f gcc/BASE-VER ]; then
77   target_gcc_ver=`cat gcc/BASE-VER`
78fi
79
80# Apply linkonce patch for gcc (should be fixed come gcc 3.4.4)
81cd ${SRC}/${PKGDIR}
82case ${target_gcc_ver} in
83   3.4.3 )
84      apply_patch gcc-3.4.3-linkonce-1
85      apply_patch gcc-3.4.0-arm-bigendian
86      apply_patch gcc-3.4.0-arm-nolibfloat
87      apply_patch gcc-3.4.0-arm-lib1asm
88      apply_patch gcc-3.4.3-clean_exec_and_lib_search_paths_when_cross-1
89   ;;
90   4.0.0 )
91      apply_patch gcc-4.0.0-fix_tree_optimisation_PR21173
92      apply_patch gcc-4.0.0-reload_check_uninitialized_pseudos_PR20973
93      apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1
94   ;;
95   4.1.0 )
96      apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1
97      apply_patch gcc-4.1.0-fix_PR20425
98   ;;
99   4.0.* | 4.1.* )
100      apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1
101   ;;
102esac
103
104# if we are using gcc-3.4x, set libexecdir to */${libdirname}
105case ${target_gcc_ver} in
106   3.4* | 4.* )
107      extra_conf="${extra_conf} --libexecdir=${HST_TOOLS}/${libdirname}"
108   ;;
109esac
110
111if [ "${USE_SYSROOT}" = "Y" ]; then
112   extra_conf="${extra_conf} --with-sysroot=${LFS}"
113else
114   # LFS style build
115   #----------------
116
117   # source functions for required gcc modifications
118   . ${SCRIPTS}/funcs/cross_gcc-funcs.sh
119
120   # Alter the generated specs file to
121   #  o set dynamic linker to be under ${TGT_TOOLS}/lib{,32,64}
122   #  o set startfile_prefix_spec so we search for startfiles
123   #    under ${TGT_TOOLS}/lib/lib{,32,64}
124   gcc_specs_mod
125
126   # Set cpp's default include search path, and the header search path
127   # used by fixincludes to be ${TGT_TOOLS}/include
128   cpp_set_cross_system_header_dir
129
130   # fix configure so that shared libgcc gets built against the correct
131   # startfiles if the user sets ${TGT_TOOLS} = ${HOST_TOOLS}/${TARGET}
132   configure_fix_flags_for_target
133fi
134
135
136# The following needs to be done if we are configuring gcc without
137#   --disable-shared
138# We need to Strip "-lc" from the shared libs list. We don't have libc yet...
139# Altered files are
140#    gcc/config/t-slibgcc-elf-ver and
141#    gcc/config/t-libunwind (for ia64)
142#
143cd ${SRC}/${PKGDIR}/gcc
144for file in config/t-slibgcc-elf-ver config/t-libunwind; do
145   test -f ${file}-ORIG ||
146      mv ${file} ${file}-ORIG
147   sed '/^SHLIB_LC = /s@-lc@@' ${file}-ORIG > ${file}
148done
149
150test -d ${SRC}/gcc-${GCC_VER}-cross-shared &&
151   rm -rf ${SRC}/gcc-${GCC_VER}-cross-shared
152
153mkdir -p ${SRC}/gcc-${GCC_VER}-cross-shared &&
154cd ${SRC}/gcc-${GCC_VER}-cross-shared &&
155
156# NOTE:
157# Some errors occur on solaris where bash syntax is used with a
158# standard /bin/sh ( ie: expecting $(command) to be evaluated )
159# To avoid this issue we override make's default shell with
160# /bin/bash
161# This is done via passing CONFIG_SHELL=/bin/bash to
162# configure, which uses this when it specifies SHELL in
163# the Makefiles.
164
165max_log_init Gcc ${GCC_VER} cross-pt2 ${CONFLOGS} ${LOG}
166#CONFIG_SHELL=/bin/bash \
167CFLAGS="-O2 ${HOST_CFLAGS} -pipe" \
168../${PKGDIR}/configure --prefix=${HST_TOOLS} \
169   --target=${TARGET} ${extra_conf} \
170   --with-local-prefix=${TGT_TOOLS} --enable-languages=c \
171   --disable-nls --enable-shared \
172   >> ${LOGFILE} 2>&1 &&
173echo " o Configure OK" || barf
174
175min_log_init ${BUILDLOGS} &&
176#make ${PMFLAGS} BOOT_CFLAGS="-O2 ${HOST_CFLAGS} -pipe" \
177#   STAGE1_CFLAGS="-O ${HOST_CFLAGS} -pipe" all-gcc \
178make ${PMFLAGS} CFLAGS_FOR_TARGET="-O2 -pipe ${TGT_CFLAGS}" all-gcc \
179   >> ${LOGFILE} 2>&1 &&
180echo " o Build OK" || barf
181
182min_log_init ${INSTLOGS} &&
183make install-gcc \
184   >> ${LOGFILE} 2>&1 &&
185echo " o Install OK" || barf
186
Note: See TracBrowser for help on using the repository browser.