Ryan Oliver wrote:

One final thing.

Back in the day we used to supply the following patches to gcc for the cross-toolchain builds

Starting with 3.4.3
http://svn.cross-lfs.org/svn/repos/cross-lfs-scripts/trunk/ryan/patches/gcc-3.4.3-clean_exec_and_lib_search_paths_when_cross-1.patch

Submitted by: Ryan Oliver <ryan.oli...@pha.com.au>
Date: 2005-05-02
Initial Package Version: 3.4.3
Origin: Ryan Oliver (issue reported by Erik-Jan Post)
Upstream Status: N/A
Description: Removes standard_exec_prefix_2 from library search path when cross-compiling.
  Removes both standard_exec_prefix_1 and standard_exec_prefix_2 from the gcc
  executable search path when cross-compiling.

  ie: if cross_compile = 1 in the specs file, do not
      - do not add /usr/lib/gcc/${TARGET}/${GCC_VER} to the library search path
      - do not add /usr/lib/gcc/${TARGET}/${GCC_VER} or
                   /usr/libexec/gcc/${TARGET}/${GCC_VER}
        to the executable search path

  This avoids the possibility of linking in libraries from the host if they
  exist under those directories.


Thankfully this is no longer an issue anymore for cross-compilers (not too sure when the fix went in to mainline, we still needed a version of this patch for
gcc-4.2.2)
http://svn.cross-lfs.org/svn/repos/cross-lfs-scripts/trunk/ryan/patches/gcc-4.2.2-cross_search_paths-1.patch

Due to the way cross-lfs works, where we dont use the cross-compiled native compiler until we chroot/reboot, nullifying those particular prefixes was not an issue for us.

However, introducing a native compiler to build chapter 5 does expose the issue.

These are hard coded in gcc.c itself and aren't wrapped with #ifdef like everything else so there is no sane way to override it.

Find attached a patch which adds #ifdef around them.

Patch not upstreamed (yet)

Apply patch during the native gcc build and specify the following
(the undef'ing below is superfluous, at the moment, but once the patch has been applied we have to cater for the fact someone MAY define those prefixes somewhere else)

echo "
#undef STANDARD_EXEC_PREFIX_1
#undef STANDARD_EXEC_PREFIX_2
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_EXEC_PREFIX_1 \"\"
#define STANDARD_EXEC_PREFIX_2 \"\"
#define STANDARD_STARTFILE_PREFIX_1 \"/tools/lib/\"
#define STANDARD_STARTFILE_PREFIX_2 \"\"" >> gcc/config/linux.h


Not tested, but it is pretty obvious what will happen

Best Regards
[R]
( cc'd to clfs-dev for reference only, we dont need this patch)

Submitted by: Ryan Oliver <ryan.oli...@performiq.com.au>
Date: 2008-12-22
Origin: Ryan Oliver
Upstream Status: Not sent yet
Description:
   When installing a native gcc into a non-standard prefix we may want to
   restrict the possibility of executables or libraries being found
   outside of our installation, which could occur if a same version
   gcc installation exists under /usr.

   Patch simply allows us to override STANDARD_EXEC_PREFIX_{1,2} the same
   as all the other defined prefixes.

--- gcc-4.3.2/gcc/gcc.c-orig    2008-12-22 16:03:24.000000000 +1100
+++ gcc-4.3.2/gcc/gcc.c 2008-12-22 16:07:07.000000000 +1100
@@ -1484,6 +1484,13 @@
 #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
 #endif
 
+#ifndef STANDARD_EXEC_PREFIX_1
+#define STANDARD_EXEC_PREFIX_1 "/usr/libexec/gcc/"
+#endif
+#ifndef STANDARD_EXEC_PREFIX_2
+#define STANDARD_EXEC_PREFIX_1 "/usr/lib/gcc/
+#endif
+
 #ifdef CROSS_DIRECTORY_STRUCTURE  /* Don't use these prefixes for a cross 
compiler.  */
 #undef MD_EXEC_PREFIX
 #undef MD_STARTFILE_PREFIX
@@ -1515,8 +1522,8 @@
 /* For native compilers, these are well-known paths containing
    components that may be provided by the system.  For cross
    compilers, these paths are not used.  */
-static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/";
-static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/";
+static const char *const standard_exec_prefix_1 = STANDARD_EXEC_PREFIX_1;
+static const char *const standard_exec_prefix_2 = STANDARD_EXEC_PREFIX_2;
 static const char *md_exec_prefix = MD_EXEC_PREFIX;
 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to