This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH mingw32 STANDARD_STARTFILE_PREFIX_[12] (Re: PATCH mingw32 MD_STARTFILE_PREFIXwas a bad idea.)
This patch allows standard_startfile_prefix_1 and
standard_startfile_prefix_2 to be overriden with macros from their
traditional hard-coded defaults in gcc.c. This is necessary on Windows
(and probably some other non-Unix platforms) where the system has its
own conventions as to where system libraries are kept.
It also uses the new macros to fix MinGW's search paths.
With this patch, the search order on a normal MinGW installation is as
follows, which is what I needed.
PREFIX/lib/gcc/i686-pc-mingw32/3.5.0
PREFIX/lib/gcc
PREFIX/lib/gcc/i686-pc-mingw32/3.5.0
PREFIX/i686-pc-mingw32/lib
PREFIX/lib
/mingw/lib
Bootstrapped on i686-pc-mingw32.
2004-06-17 Aaron W. LaFramboise <aaronraolete36@aaronwl.com>
* gcc.c (STANDARD_STARTFILE_PREFIX_1): Define.
(STANDARD_STARTFILE_PREFIX_2): Define.
(standard_startfile_prefix_1): Initialize to
STANDARD_STARTFILE_PREFIX_1.
(standard_startfile_prefix_2): Initialize to
STANDARD_STARTFILE_PREFIX_2.
* config/i386/mingw32.h (MD_STARTFILE_PREFIX): Remove.
(STANDARD_STARTFILE_PREFIX_1): Define.
(STANDARD_STARTFILE_PREFIX_2): Define.
* doc/tm.texi (STANDARD_STARTFILE_PREFIX_1): Document.
(STANDARD_STARTFILE_PREFIX_2): Document.
Index: gcc/gcc/gcc.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.424
diff -c -3 -p -r1.424 gcc.c
*** gcc/gcc/gcc.c 4 Jun 2004 20:13:14 -0000 1.424
--- gcc/gcc/gcc.c 17 Jun 2004 06:32:45 -0000
*************** static const char *gcc_libexec_prefix;
*** 1428,1433 ****
--- 1428,1440 ----
/* Default prefixes to attach to command names. */
+ #ifndef STANDARD_STARTFILE_PREFIX_1
+ #define STANDARD_STARTFILE_PREFIX_1 "/lib/"
+ #endif
+ #ifndef STANDARD_STARTFILE_PREFIX_2
+ #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
+ #endif
+
#ifdef CROSS_COMPILE /* Don't use these prefixes for a cross
compiler. */
#undef MD_EXEC_PREFIX
#undef MD_STARTFILE_PREFIX
*************** static const char *md_exec_prefix = MD_E
*** 1453,1460 ****
static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
static const char *const standard_startfile_prefix =
STANDARD_STARTFILE_PREFIX;
! static const char *const standard_startfile_prefix_1 = "/lib/";
! static const char *const standard_startfile_prefix_2 = "/usr/lib/";
static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
static const char *tooldir_prefix;
--- 1460,1469 ----
static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
static const char *const standard_startfile_prefix =
STANDARD_STARTFILE_PREFIX;
! static const char *const standard_startfile_prefix_1
! = STANDARD_STARTFILE_PREFIX_1;
! static const char *const standard_startfile_prefix_2
! = STANDARD_STARTFILE_PREFIX_2;
static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
static const char *tooldir_prefix;
*************** main (int argc, const char **argv)
*** 6230,6239 ****
NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
! add_sysrooted_prefix (&startfile_prefixes,
standard_startfile_prefix_1,
! "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
! add_sysrooted_prefix (&startfile_prefixes,
standard_startfile_prefix_2,
! "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
#if 0 /* Can cause surprises, and one can use -B./ instead. */
add_prefix (&startfile_prefixes, "./", NULL,
PREFIX_PRIORITY_LAST, 1, NULL, 0);
--- 6239,6253 ----
NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
! if (*standard_startfile_prefix_1)
! add_sysrooted_prefix (&startfile_prefixes,
! standard_startfile_prefix_1, "BINUTILS",
! PREFIX_PRIORITY_LAST, 0, NULL, 1);
! if (*standard_startfile_prefix_2)
! add_sysrooted_prefix (&startfile_prefixes,
! standard_startfile_prefix_2, "BINUTILS",
! PREFIX_PRIORITY_LAST, 0, NULL, 1);
!
#if 0 /* Can cause surprises, and one can use -B./ instead. */
add_prefix (&startfile_prefixes, "./", NULL,
PREFIX_PRIORITY_LAST, 1, NULL, 0);
Index: gcc/gcc/config/i386/mingw32.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/i386/mingw32.h,v
retrieving revision 1.35
diff -c -3 -p -r1.35 mingw32.h
*** gcc/gcc/config/i386/mingw32.h 26 Sep 2003 03:46:06 -0000 1.35
--- gcc/gcc/config/i386/mingw32.h 17 Jun 2004 06:32:46 -0000
*************** Boston, MA 02111-1307, USA. */
*** 69,77 ****
#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
%{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s}"
! /* An additional prefix to try after the standard prefixes. */
! #undef MD_STARTFILE_PREFIX
! #define MD_STARTFILE_PREFIX "/mingw/lib/"
/* Output STRING, a string representing a filename, to FILE.
We canonicalize it to be in Unix format (backslashes are replaced
--- 69,81 ----
#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
%{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s}"
! /* Override startfile prefix defaults. */
! #ifndef STANDARD_STARTFILE_PREFIX_1
! #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
! #endif
! #ifndef STANDARD_STARTFILE_PREFIX_2
! #define STANDARD_STARTFILE_PREFIX_2 ""
! #endif
/* Output STRING, a string representing a filename, to FILE.
We canonicalize it to be in Unix format (backslashes are replaced
Index: gcc/gcc/doc/tm.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.329
diff -c -3 -p -r1.329 tm.texi
*** gcc/gcc/doc/tm.texi 11 Jun 2004 18:41:47 -0000 1.329
--- gcc/gcc/doc/tm.texi 17 Jun 2004 06:33:21 -0000
*************** try when searching for startup files suc
*** 468,473 ****
--- 468,489 ----
is built as a cross compiler.
@end defmac
+ @defmac STANDARD_STARTFILE_PREFIX_1
+ Define this macro as a C string constant if you wish to override the
+ standard choice of @code{/lib} as a prefix to try after the default prefix
+ when searching for startup files such as @file{crt0.o}.
+ @code{STANDARD_STARTFILE_PREFIX_1} is not searched when the compiler
+ is built as a cross compiler.
+ @end defmac
+
+ @defmac STANDARD_STARTFILE_PREFIX_2
+ Define this macro as a C string constant if you wish to override the
+ standard choice of @code{/lib} as yet another prefix to try after the
+ default prefix when searching for startup files such as @file{crt0.o}.
+ @code{STANDARD_STARTFILE_PREFIX_2} is not searched when the compiler
+ is built as a cross compiler.
+ @end defmac
+
@defmac MD_STARTFILE_PREFIX
If defined, this macro supplies an additional prefix to try after the
standard prefixes. @code{MD_EXEC_PREFIX} is not searched when the