r1231 - in trunk: . scripts/scripts/target-scripts

ryan at linuxfromscratch.org ryan at linuxfromscratch.org
Mon Mar 6 23:56:36 PST 2006


Author: ryan
Date: 2006-03-07 00:56:36 -0700 (Tue, 07 Mar 2006)
New Revision: 1231

Modified:
   trunk/
   trunk/scripts/scripts/target-scripts/target-gcc.sh
Log:
 r1233 at rei:  lfs | 2006-03-07 18:48:37 +1100
 Update for gcc-4.1.0 release



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 27a90bee-6a05-0410-9baa-d6d48c78a963:/local:705
27a90bee-6a05-0410-9baa-d6d48c78a963:/trunk:1232
c4644617-e5f8-0310-a1f2-9ce34ac0f9cb:/cross-lfs:564
   + 27a90bee-6a05-0410-9baa-d6d48c78a963:/local:705
27a90bee-6a05-0410-9baa-d6d48c78a963:/trunk:1233
c4644617-e5f8-0310-a1f2-9ce34ac0f9cb:/cross-lfs:564

Modified: trunk/scripts/scripts/target-scripts/target-gcc.sh
===================================================================
--- trunk/scripts/scripts/target-scripts/target-gcc.sh	2006-03-07 07:56:13 UTC (rev 1230)
+++ trunk/scripts/scripts/target-scripts/target-gcc.sh	2006-03-07 07:56:36 UTC (rev 1231)
@@ -100,6 +100,8 @@
            apply_patch gcc-4.0.0-reload_check_uninitialized_pseudos_PR20973
            apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1
    ;;
+   4.0.* ) apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1 ;;
+   4.1.* ) apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1 ;;
 esac
 
 # if we are using gcc-3.4x, set libexecdir to */${libdirname}
@@ -147,20 +149,32 @@
 # cross building a native compiler so we cannot actually run xgcc.
 # We get around this by substituting our cross-compiler here for xgcc,
 # by rights it should have the same specs and produce the expected results
-cd ${SRC}/${PKGDIR}/gcc
-test -f mklibgcc.in-ORIG ||
-   mv mklibgcc.in mklibgcc.in-ORIG
+#
+# NOTE: with gcc-4.1 onwards we can just set GCC_FOR_TARGET to our cross-compiler
+#       and be done with the shenannigans
 
-sed "s@\./xgcc@${HST_TOOLS}/bin/${TARGET}-gcc at g" \
-   mklibgcc.in-ORIG > mklibgcc.in
+extra_makeopts=""
+case ${target_gcc_ver} in
+   4.[1-9].* )
+      extra_makeopts="${extra_makeopts} GCC_FOR_TARGET=${HST_TOOLS}/bin/${TARGET}-gcc"
+   ;;
+   * )
+      cd ${SRC}/${PKGDIR}/gcc
+      test -f mklibgcc.in-ORIG ||
+         mv mklibgcc.in mklibgcc.in-ORIG
 
-# A similar problem exists when setting MULTILIBS on the environment
-# for the mklibgcc script for generation of libgcc.mk .
-# Here we will force it to use our cross-compiler to produce the results
-# of gcc --print-multi-lib
-sed -i "/MULTILIBS/s@\$(GCC_FOR_TARGET)@${HST_TOOLS}/bin/${TARGET}-gcc at g" \
-   Makefile.in
+      sed "s@\./xgcc@${HST_TOOLS}/bin/${TARGET}-gcc at g" \
+         mklibgcc.in-ORIG > mklibgcc.in
 
+      # A similar problem exists when setting MULTILIBS on the environment
+      # for the mklibgcc script for generation of libgcc.mk .
+      # Here we will force it to use our cross-compiler to produce the results
+      # of gcc --print-multi-lib
+      sed -i "/MULTILIBS/s@\$(GCC_FOR_TARGET)@${HST_TOOLS}/bin/${TARGET}-gcc at g" \
+         Makefile.in
+   ;;
+esac
+
 # When cross-building a target native compiler we run into big issues
 # when determining assembler and linker features required for tls support,
 # ( not to mention which nm, objdump et al to use ) during the configures
@@ -197,7 +211,7 @@
    4.* )
       # Testing only... set AS_FOR_TARGET and LD_FOR_TARGET so these are used
       # for feature checks... will have to check for unintended side effects
-      extra_makeopts="AS_FOR_TARGET=${HST_TOOLS}/bin/${TARGET}-as"
+      extra_makeopts="${extra_makeopts} AS_FOR_TARGET=${HST_TOOLS}/bin/${TARGET}-as"
       extra_makeopts="${extra_makeopts} LD_FOR_TARGET=${HST_TOOLS}/bin/${TARGET}-ld"
    ;;
 esac
@@ -257,3 +271,171 @@
 
 test -L ${INSTALL_PREFIX}/bin/cc || ln -s gcc ${INSTALL_PREFIX}/bin/cc
 
+esac
+
+# if we are using gcc-3.4x, set libexecdir to */${libdirname}
+case ${target_gcc_ver} in
+   3.4* | 4.* )
+      extra_conf="${extra_conf} --libexecdir=${BUILD_PREFIX}/${libdirname}"
+   ;;
+esac
+
+# HACK: should at least check if any of these are set first 
+ARCH_CFLAGS="${TGT_CFLAGS} ${ARCH_CFLAGS}"
+
+# if target is same as build host, adjust build slightly to avoid running
+# configure checks which we cannot run
+if [ "${TARGET}" = "${BUILD}" ]; then
+   BUILD=`echo ${BUILD} | sed 's@\([_a-zA-Z0-9]*\)\(-[_a-zA-Z0-9]*\)\(.*\)@\1\2x\3@'`
+fi
+
+if [ ! "${USE_SYSROOT}" = "Y" ]; then
+   # LFS style build
+   #----------------
+
+   # source functions for required gcc modifications
+   . ${SCRIPTS}/funcs/cross_gcc-funcs.sh
+
+   # Alter the generated specs file to 
+   #  o set dynamic linker to be under ${TGT_TOOLS}/lib{,32,64}
+   #  o set startfile_prefix_spec so we search for startfiles
+   #    under ${TGT_TOOLS}/lib/lib{,32,64}
+   gcc_specs_mod
+
+   # We need to stop cpp using /usr/include as the standard include directory.
+   # This is defined in gcc/cppdefault.c using STANDARD_INCLUDE_DIR
+   cpp_undef_standard_include_dir
+
+   # We need to override SYSTEM_HEADER_DIR so fixincludes only fixes
+   # headers under ${TGT_TOOLS}
+   fixincludes_set_native_system_header_dir
+fi
+
+# HACKS
+#-------
+
+# This here is a hack. mklibgcc runs the created xgcc for determining
+# the multilib dirs and multilib os dirs. Only problem here is we are
+# cross building a native compiler so we cannot actually run xgcc.
+# We get around this by substituting our cross-compiler here for xgcc,
+# by rights it should have the same specs and produce the expected results
+#
+# NOTE: with gcc-4.1 onwards we can just set GCC_FOR_TARGET to our cross-compiler
+#       and be done with the shenannigans
+
+extra_makeopts=""
+case ${target_gcc_ver} in
+   4.[1-9].* )
+      extra_makeopts="${extra_makeopts} GCC_FOR_TARGET=${HST_TOOLS}/bin/${TARGET}-gcc"
+   ;;
+   * )
+      cd ${SRC}/${PKGDIR}/gcc
+      test -f mklibgcc.in-ORIG ||
+         mv mklibgcc.in mklibgcc.in-ORIG
+
+      sed "s@\./xgcc@${HST_TOOLS}/bin/${TARGET}-gcc at g" \
+         mklibgcc.in-ORIG > mklibgcc.in
+
+      # A similar problem exists when setting MULTILIBS on the environment
+      # for the mklibgcc script for generation of libgcc.mk .
+      # Here we will force it to use our cross-compiler to produce the results
+      # of gcc --print-multi-lib
+      sed -i "/MULTILIBS/s@\$(GCC_FOR_TARGET)@${HST_TOOLS}/bin/${TARGET}-gcc at g" \
+         Makefile.in
+   ;;
+esac
+
+# When cross-building a target native compiler we run into big issues
+# when determining assembler and linker features required for tls support,
+# ( not to mention which nm, objdump et al to use ) during the configures
+# triggered by make.
+#
+# Gcc's configury does not take into account the fact that when cross
+# building the target native compiler we are _still_ actually cross-compiling.
+# As far as it is concerned during the final configure fragment host = target,
+# it doesn't check whether host = build. 
+#
+# It then performs its checks for binutils components as if this was a standard 
+# host native build.
+#
+# If a target native binutils was installed before attempting to build gcc
+# it will try to use the created ld, as etc under ${TGT_TOOLS}
+# This obviously will not work, they will not run on the host.
+#
+# If the target native binutils hasn't been built yet it will use the
+# as ld et al from the _build_ host.
+# This quite frankly sucks rocks.
+#
+# The following patch fixes this behaviour, enforcing usage of our
+# cross-tools for configure checks if host = target and host != build
+#
+# NOTE: 20050507 This doesn't appear to be necessary for gcc 4.x :-)
+#       This of course will have to be checked thoroughly...
+
+# TODO: Add patches for gcc-3.3 series as well
+cd ${SRC}/${PKGDIR}
+case ${target_gcc_ver} in
+   3.4* )
+      apply_patch gcc-3.4.1-fix_configure_for_target_native
+   ;;
+   4.* )
+      # set AS_FOR_TARGET and LD_FOR_TARGET so these are used for feature checks... 
+      extra_makeopts="${extra_makeopts} AS_FOR_TARGET=${HST_TOOLS}/bin/${TARGET}-as"
+      extra_makeopts="${extra_makeopts} LD_FOR_TARGET=${HST_TOOLS}/bin/${TARGET}-ld"
+   ;;
+esac
+# End HACKS
+
+test -d ${SRC}/gcc-${GCC_VER}-target &&
+   rm -rf ${SRC}/gcc-${GCC_VER}-target
+
+mkdir -p ${SRC}/gcc-${GCC_VER}-target &&
+cd ${SRC}/gcc-${GCC_VER}-target &&
+
+max_log_init Gcc ${GCC_VER} cross-pt2 ${CONFLOGS} ${LOG}
+#CONFIG_SHELL=/bin/bash \
+CFLAGS="-O2 -pipe" \
+CXXFLAGS="-O2 -pipe" \
+CC="${TARGET}-gcc ${ARCH_CFLAGS}" \
+../${PKGDIR}/configure --prefix=${BUILD_PREFIX} \
+   --build=${BUILD} --host=${TARGET} --target=${TARGET} \
+   --enable-languages=c,c++ --enable-__cxa_atexit \
+   --enable-c99 --enable-long-long --enable-threads=posix \
+   --disable-nls --enable-shared ${extra_conf} \
+   >> ${LOGFILE} 2>&1 &&
+echo " o Configure OK" || barf
+#   --enable-languages=c,c++,f77,objc,ada,java,pascal,treelang --enable-__cxa_atexit \
+#   --enable-version-specific-runtime-libs \
+
+min_log_init ${BUILDLOGS} &&
+make ${PMFLAGS} BOOT_LDFLAGS="-s" BOOT_CFLAGS="-O2 ${HOST_CFLAGS} -pipe" \
+   STAGE1_CFLAGS="-O2 ${HOST_CFLAGS} -pipe" ${extra_makeopts} all \
+   >> ${LOGFILE} 2>&1 &&
+echo " o Build OK" || barf
+
+min_log_init ${INSTLOGS} &&
+make ${INSTALL_OPTIONS} install \
+   >> ${LOGFILE} 2>&1 &&
+echo " o Install OK" || barf
+
+if [ ! "${USE_SYSROOT}" = "Y" ]; then
+   # Prep new root for target native glibc build
+   libdirs="${libdirname}"
+   if [ "Y" = "${MULTIARCH}" ]; then libdirs="lib lib32 lib64" ; fi
+   for dir in ${libdirs} ; do
+      if [ -d ${TGT_TOOLS}/${dir} ]; then
+         test -d ${LFS}/usr/${dir} || mkdir -p ${LFS}/usr/${dir}
+         ln -sf ../..${TGT_TOOLS}/${dir}/libgcc_s.so.1 \
+            ${LFS}/usr/${dir}/libgcc_s.so.1
+         test -f ${TGT_TOOLS}/${dir}/libgcc_s.so &&
+            ln -sf libgcc_s.so.1 ${LFS}/usr/${dir}/libgcc_s.so
+         test -f ${TGT_TOOLS}/${dir}/libgcc_s_32.so &&
+            ln -sf libgcc_s.so.1 ${LFS}/usr/${dir}/libgcc_s_32.so
+         test -f ${TGT_TOOLS}/${dir}/libgcc_s_64.so &&
+            ln -sf libgcc_s.so.1 ${LFS}/usr/${dir}/libgcc_s_64.so
+      fi
+   done
+fi
+
+test -L ${INSTALL_PREFIX}/bin/cc || ln -s gcc ${INSTALL_PREFIX}/bin/cc
+




More information about the cross-lfs mailing list