This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Handle TARGET_SYSTEM_ROOT properly on Darwin


If you write, on a Tiger (that is, a powerpc system running
darwin8.*.0) system,

.../configure --target=i386-apple-darwin \
--with-sysroot=/Developer/SDKs/MacOSX10.4u.sdk --with-as=/usr/bin/as \
--with-ld=/usr/bin/ld

to create a cross-compiler to i386-apple-darwin, it'll fail, because
the linker won't know to use the stub libraries out of
/Developer/SDKs, and instead tries to use the ones in /usr/lib, which
don't have support for i386 on this system; and so the link fails.

Building like this is not a common scenario at Apple, we usually just
install an OS which does have i386 support in /, but nonetheless it
ought to work, and this seems to be all that's necessary to make it go.

Tested by building with the above command.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-darwin-withsysroot.patch==============
2006-09-22  Geoffrey Keating  <geoffk@apple.com>

	* config/darwin.h (LINK_SYSROOT_SPEC): New.
	(LINK_SPEC): If TARGET_SYSTEM_ROOT is defined, pass it to
	the linker by default.

Index: config/darwin.h
===================================================================
--- config/darwin.h	(revision 117150)
+++ config/darwin.h	(working copy)
@@ -214,6 +214,13 @@
     %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %G %L}} \
     %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} }}}}}}}}"
 
+#ifdef TARGET_SYSTEM_ROOT
+#define LINK_SYSROOT_SPEC \
+  "%{isysroot*:-syslibroot %*;:-syslibroot " TARGET_SYSTEM_ROOT "}"
+#else
+#define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*}"
+#endif
+
 /* Please keep the random linker options in alphabetical order (modulo
    'Z' and 'no' prefixes).  Options that can only go to one of libtool
    or ld must be listed twice, under both !Zdynamiclib and
@@ -282,7 +289,7 @@
    %{Zseg_addr_table*: -seg_addr_table %*} \
    %{Zfn_seg_addr_table_filename*:-seg_addr_table_filename %*} \
    %{sub_library*} %{sub_umbrella*} \
-   %{isysroot*:-syslibroot %*} \
+   " LINK_SYSROOT_SPEC " \
    %{twolevel_namespace} %{twolevel_namespace_hints} \
    %{umbrella*} \
    %{undefined*} \
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]