This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
32/64 startfile path handling
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 21 May 2002 15:34:44 +0930
- Subject: 32/64 startfile path handling
- References: <OF811DA05C.CAFD7EAB-ONC1256BA7.006253B6@de.ibm.com> <20020427001207.GP31160@bubble.sa.bigpond.net.au> <20020501044425.B23056@devserv.devel.redhat.com>
This thread started from
http://gcc.gnu.org/ml/gcc-patches/2002-04/msg01661.html
On Wed, May 01, 2002 at 04:44:25AM -0400, Jakub Jelinek wrote:
> On Sat, Apr 27, 2002 at 09:42:07AM +0930, Alan Modra wrote:
> > Since this has come up, I'll present my solution, a new spec to
> > tweak default compiler search paths. Developed for powerpc64,
> > but with x86_64, s390 etc. people in mind. x86_64 will be able
> > to do something like:
> >
> > #define STARTFILE_PREFIX_SPEC "\
> > %{m32: /usr/local/lib/ /lib/ /usr/lib/} \
> > %{!m32: /usr/local/lib64/ /lib64/ /usr/lib64/}"
> >
> > and then get rid of those ugly absolute paths in STARTFILE_SPEC
> > and ENDFILE_SPEC.
>
> I like this, though I guess STARTFILE_PREFIX_SPEC should be used even
> if native BI-ARCH compiler (e.g. sparc64-linux -> sparc64-linux which
> supports both -m64 and -m32, similarly sparc-linux -> sparc-linux which
> supports both -m32 and -m64).
Agreed. Here we go. OK to apply? Tested building powerpc64-linux
cross on powerpc-linux host.
gcc/ChangeLog
* configure.in (CROSS): Define NATIVE_CROSS.
* configure: Regenerate.
* gcc.c (STARTFILE_PREFIX_SPEC): Define.
(startfile_prefix_spec): New var.
(static_specs): Add startfile_prefix_spec.
(do_spec_2): Split out from..
(do_spec): ..here.
(main): Process startfile_prefix_spec.
* config/rs6000/linux64.h (LINK_OS_LINUX_SPEC) Add -Y, change name
of dynamic linker.
(STARTFILE_PREFIX_SPEC): Define.
(STARTFILE_LINUX_SPEC, ENDFILE_LINUX_SPEC): Rewrite without
absolute paths.
diff -urpN -xCVS -x'*~' -xTAGS gcc-ppc64-32.orig/gcc/gcc.c gcc-ppc64-32/gcc/gcc.c
--- gcc-ppc64-32.orig/gcc/gcc.c 2002-05-20 19:05:39.000000000 +0930
+++ gcc-ppc64-32/gcc/gcc.c 2002-05-21 12:48:47.000000000 +0930
@@ -299,6 +299,7 @@ static const char *handle_braces PARAMS
static char *save_string PARAMS ((const char *, int));
static void set_collect_gcc_options PARAMS ((void));
static int do_spec_1 PARAMS ((const char *, int, const char *));
+static int do_spec_2 PARAMS ((const char *));
static const char *find_file PARAMS ((const char *));
static int is_directory PARAMS ((const char *, const char *, int));
static void validate_switches PARAMS ((const char *));
@@ -641,6 +642,10 @@ proper position among the other output f
# endif
#endif
+#ifndef STARTFILE_PREFIX_SPEC
+# define STARTFILE_PREFIX_SPEC ""
+#endif
+
static const char *asm_debug = ASM_DEBUG_SPEC;
static const char *cpp_spec = CPP_SPEC;
static const char *cpp_predefines = CPP_PREDEFINES;
@@ -658,6 +663,7 @@ static const char *switches_need_spaces
static const char *linker_name_spec = LINKER_NAME;
static const char *link_command_spec = LINK_COMMAND_SPEC;
static const char *link_libgcc_spec = LINK_LIBGCC_SPEC;
+static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC;
/* Standard options to cpp, cc1, and as, to reduce duplication in specs.
There should be no need to override these in target dependent files,
@@ -1388,6 +1394,7 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix),
INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix),
INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1),
+ INIT_STATIC_SPEC ("startfile_prefix_spec", &startfile_prefix_spec),
};
#ifdef EXTRA_SPECS /* additional specs needed */
@@ -4133,15 +4140,7 @@ do_spec (spec)
{
int value;
- clear_args ();
- arg_going = 0;
- delete_this_arg = 0;
- this_is_output_file = 0;
- this_is_library_file = 0;
- input_from_pipe = 0;
- suffix_subst = NULL;
-
- value = do_spec_1 (spec, 0, NULL);
+ value = do_spec_2 (spec);
/* Force out any unfinished command.
If -pipe, this forces out the last command if it ended in `|'. */
@@ -4159,6 +4158,21 @@ do_spec (spec)
return value;
}
+static int
+do_spec_2 (spec)
+ const char *spec;
+{
+ clear_args ();
+ arg_going = 0;
+ delete_this_arg = 0;
+ this_is_output_file = 0;
+ this_is_library_file = 0;
+ input_from_pipe = 0;
+ suffix_subst = NULL;
+
+ return do_spec_1 (spec, 0, NULL);
+}
+
/* Process the sub-spec SPEC as a portion of a larger spec.
This is like processing a whole spec except that we do
not initialize at the beginning and we do not supply a
@@ -5838,8 +5852,10 @@ main (argc, argv)
if (access (specs_file, R_OK) == 0)
read_specs (specs_file, TRUE);
- /* If not cross-compiling, look for startfiles in the standard places. */
- if (*cross_compile == '0')
+ /* If not cross-compiling, look for startfiles in the standard places.
+ Similarly, don't add the standard prefixes if startfile handling
+ will be under control of startfile_prefix_spec. */
+ if (*cross_compile == '0' || *startfile_prefix_spec == 0)
{
if (*md_exec_prefix)
{
@@ -5897,6 +5913,16 @@ main (argc, argv)
"BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL);
}
+ if (*startfile_prefix_spec != 0
+ && do_spec_2 (startfile_prefix_spec) == 0
+ && do_spec_1 (" ", 0, NULL) == 0)
+ {
+ int ndx;
+ for (ndx = 0; ndx < argbuf_index; ndx++)
+ add_prefix (&startfile_prefixes, argbuf[ndx], "BINUTILS",
+ PREFIX_PRIORITY_LAST, 0, NULL);
+ }
+
/* Process any user specified specs in the order given on the command
line. */
for (uptr = user_specs_head; uptr; uptr = uptr->next)
diff -urpN -xCVS -x'*~' -xTAGS gcc-ppc64-32.orig/gcc/configure.in gcc-ppc64-32/gcc/configure.in
--- gcc-ppc64-32.orig/gcc/configure.in 2002-05-20 19:05:15.000000000 +0930
+++ gcc-ppc64-32/gcc/configure.in 2002-05-21 12:48:47.000000000 +0930
@@ -1115,6 +1115,11 @@ then
CROSS="-DCROSS_COMPILE"
ALL=all.cross
SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)'
+ case "$host","$target" in
+ i?86-*-*,x86_64-*-* \
+ | powerpc*-*-*,powerpc64*-*-*)
+ CROSS="$CROSS -DNATIVE_CROSS" ;;
+ esac
fi
# If this is a cross-compiler that does not
diff -urpN -xCVS -x'*~' -xTAGS gcc-ppc64-32.orig/gcc/config/rs6000/linux64.h gcc-ppc64-32/gcc/config/rs6000/linux64.h
--- gcc-ppc64-32.orig/gcc/config/rs6000/linux64.h 2002-05-20 19:08:16.000000000 +0930
+++ gcc-ppc64-32/gcc/config/rs6000/linux64.h 2002-05-21 12:48:47.000000000 +0930
@@ -100,6 +100,7 @@ Boston, MA 02111-1307, USA. */
/* Don't assume anything about the header files. */
#define NO_IMPLICIT_EXTERN_C
+/* Override svr4.h */
#undef MD_EXEC_PREFIX
#undef MD_STARTFILE_PREFIX
@@ -138,29 +139,24 @@ Boston, MA 02111-1307, USA. */
#define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
#undef LINK_OS_LINUX_SPEC
-#ifndef CROSS_COMPILE
-#define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
+#define LINK_OS_LINUX_SPEC "-m elf64ppc -Y /usr/local/lib64:/lib64:/usr/lib64 \
+%{!shared: %{!static: \
%{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib64/ld.so.1}}}"
-#else
-#define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker ld.so.1}}}"
+ %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}"
+
+#ifdef NATIVE_CROSS
+#define STARTFILE_PREFIX_SPEC "/usr/local/lib64/ /lib64/ /usr/lib64/"
#endif
-#ifndef CROSS_COMPILE
#undef STARTFILE_LINUX_SPEC
#define STARTFILE_LINUX_SPEC "\
-%{!shared: %{pg:/usr/lib64/gcrt1.o%s} %{!pg:%{p:/usr/lib64/gcrt1.o%s} \
- %{!p:/usr/lib64/crt1.o%s}}} /usr/lib64/crti.o%s \
-%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
-#endif
+%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \
+%{static:crtbeginT.o%s} \
+%{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
-#ifndef CROSS_COMPILE
#undef ENDFILE_LINUX_SPEC
#define ENDFILE_LINUX_SPEC "\
-%{!shared:crtend.o%s} %{shared:crtendS.o%s} /usr/lib64/crtn.o%s"
-#endif
+%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
#undef TOC_SECTION_ASM_OP
#define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\""
--
Alan Modra
IBM OzLabs - Linux Technology Centre