re PR libobjc/11572 (GNU libobjc no longer compiled on Darwin)

2004-09-15  Andrew Pinski  <pinskia@physics.uc.edu>

        PR target/11572
        * c-incpath.h (target_c_incpath_s): Add extra_pre_includes.
        Add two parameters to extra_includes.
        (C_INCPATH_INIT): Remove.
        * c-incpath.c (register_include_chains): Call extra_pre_includes
        before adding the standard include directory.
        Update call to extra_includes.
        (!defined TARGET_EXTRA_INCLUDES): Update
        hook_void_charptr_charptr_int and add !define
        TARGET_EXTRA_PRE_INCLUDES.
        (!define TARGET_EXTRA_INCLUDES): Define as
        hook_void_charptr_charptr_int.
        (!define TARGET_EXTRA_PRE_INCLUDES): Likewise.
        (target_c_incpath): Always declare.
        * fixinclude.c (defined TARGET_EXTRA_INCLUDES): Declare a
        empty function.
        (define TARGET_EXTRA_PRE_INCLUDES): Likewise.
        * config/darwin.h: (darwin_register_frameworks): Update for
        the two new parameters.
        (darwin_register_objc_includes): Add prototype.
        (TARGET_EXTRA_PRE_INCLUDES): Define.
        * config/darwin-c.c (darwin_register_objc_includes): New function.
        (darwin_register_frameworks): Update for the two new parameters.
        (target_c_incpath): Remove.
        * config/t-darwin (darwin-c.o): Add $(PREPROCESSOR_DEFINES) to
        the compile line.
        * doc/tm.texi (TARGET_EXTRA_INCLUDES): Document the two new
        parameters.
        (TARGET_EXTRA_PRE_INCLUDES): Document.

        * gcc.c (spec_function): Add replace-outfile.
        (replace_outfile_spec_function): New function.
        * config/darwin.h (LINK_SPEC): Add replace
        -lobjc with -lobjc-gnu if -fgnu-runtime is
        supplied.
        * invoke.texi (replace-outfile): Document.

From-SVN: r87588
This commit is contained in:
Andrew Pinski 2004-09-16 06:49:59 +00:00 committed by Andrew Pinski
parent 511bbc8f91
commit 3dd53121bd
10 changed files with 164 additions and 16 deletions

View File

@ -1,3 +1,42 @@
2004-09-15 Andrew Pinski <pinskia@physics.uc.edu>
PR target/11572
* c-incpath.h (target_c_incpath_s): Add extra_pre_includes.
Add two parameters to extra_includes.
(C_INCPATH_INIT): Remove.
* c-incpath.c (register_include_chains): Call extra_pre_includes
before adding the standard include directory.
Update call to extra_includes.
(!defined TARGET_EXTRA_INCLUDES): Update
hook_void_charptr_charptr_int and add !define
TARGET_EXTRA_PRE_INCLUDES.
(!define TARGET_EXTRA_INCLUDES): Define as
hook_void_charptr_charptr_int.
(!define TARGET_EXTRA_PRE_INCLUDES): Likewise.
(target_c_incpath): Always declare.
* fixinclude.c (defined TARGET_EXTRA_INCLUDES): Declare a
empty function.
(define TARGET_EXTRA_PRE_INCLUDES): Likewise.
* config/darwin.h: (darwin_register_frameworks): Update for
the two new parameters.
(darwin_register_objc_includes): Add prototype.
(TARGET_EXTRA_PRE_INCLUDES): Define.
* config/darwin-c.c (darwin_register_objc_includes): New function.
(darwin_register_frameworks): Update for the two new parameters.
(target_c_incpath): Remove.
* config/t-darwin (darwin-c.o): Add $(PREPROCESSOR_DEFINES) to
the compile line.
* doc/tm.texi (TARGET_EXTRA_INCLUDES): Document the two new
parameters.
(TARGET_EXTRA_PRE_INCLUDES): Document.
* gcc.c (spec_function): Add replace-outfile.
(replace_outfile_spec_function): New function.
* config/darwin.h (LINK_SPEC): Add replace
-lobjc with -lobjc-gnu if -fgnu-runtime is
supplied.
* invoke.texi (replace-outfile): Document.
2004-09-13 Jan Hubicka <jh@suse.cz>
* predict.c (expr_expected_value, strip_builtin_expect): New function.

View File

@ -372,21 +372,34 @@ register_include_chains (cpp_reader *pfile, const char *sysroot,
include chain. */
add_env_var_paths ("CPATH", BRACKET);
add_env_var_paths (lang_env_vars[idx], SYSTEM);
target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
/* Finally chain on the standard directories. */
if (stdinc)
add_standard_paths (sysroot, iprefix, cxx_stdinc);
target_c_incpath.extra_includes (stdinc);
target_c_incpath.extra_includes (sysroot, iprefix, stdinc);
merge_include_chains (pfile, verbose);
cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
quote_ignores_source_dir);
}
#if !(defined TARGET_EXTRA_INCLUDES) || !(defined TARGET_EXTRA_PRE_INCLUDES)
static void hook_void_charptr_charptr_int (const char *sysroot ATTRIBUTE_UNUSED,
const char *iprefix ATTRIBUTE_UNUSED,
int stdinc ATTRIBUTE_UNUSED)
{
}
#endif
#ifndef TARGET_EXTRA_INCLUDES
static void hook_void_int(int u ATTRIBUTE_UNUSED) { }
struct target_c_incpath_s target_c_incpath = { hook_void_int };
#define TARGET_EXTRA_INCLUDES hook_void_charptr_charptr_int
#endif
#ifndef TARGET_EXTRA_PRE_INCLUDES
#define TARGET_EXTRA_PRE_INCLUDES hook_void_charptr_charptr_int
#endif
struct target_c_incpath_s target_c_incpath = { TARGET_EXTRA_PRE_INCLUDES, TARGET_EXTRA_INCLUDES };

View File

@ -23,11 +23,10 @@ extern void add_cpp_dir_path (struct cpp_dir *, int);
struct target_c_incpath_s {
/* Do extra includes processing. STDINC is false iff -nostdinc was given. */
void (*extra_includes) (int);
void (*extra_pre_includes) (const char *, const char *, int);
void (*extra_includes) (const char *, const char *, int);
};
extern struct target_c_incpath_s target_c_incpath;
#define C_INCPATH_INIT { TARGET_EXTRA_INCLUDES }
enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };

View File

@ -30,6 +30,8 @@ Boston, MA 02111-1307, USA. */
#include "c-incpath.h"
#include "toplev.h"
#include "tm_p.h"
#include "cppdefault.h"
#include "prefix.h"
/* Pragmas. */
@ -419,13 +421,55 @@ static const char *framework_defaults [] =
"/Library/Frameworks",
};
/* Register the GNU objective-C runtime include path if STDINC. */
void
darwin_register_objc_includes (const char *sysroot, const char *iprefix,
int stdinc)
{
const char *fname;
size_t len;
/* We do not do anything if we do not want the standard includes. */
if (!stdinc)
return;
fname = GCC_INCLUDE_DIR "-gnu-runtime";
/* Register the GNU OBJC runtime include path if we are compiling OBJC
with GNU-runtime. */
if (c_dialect_objc () && !flag_next_runtime)
{
char *str;
/* See if our directory starts with the standard prefix.
"Translate" them, ie. replace /usr/local/lib/gcc... with
IPREFIX and search them first. */
if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0 && !sysroot
&& !strncmp (fname, cpp_GCC_INCLUDE_DIR, len))
{
str = concat (iprefix, fname + len, NULL);
/* FIXME: wrap the headers for C++awareness. */
add_path (str, SYSTEM, /*c++aware=*/false, false);
}
/* Should this directory start with the sysroot? */
if (sysroot)
str = concat (sysroot, fname, NULL);
else
str = update_path (fname, "");
add_path (str, SYSTEM, /*c++aware=*/false, false);
}
}
/* Register all the system framework paths if STDINC is true and setup
the missing_header callback for subframework searching if any
frameworks had been registered. */
void
darwin_register_frameworks (int stdinc)
darwin_register_frameworks (const char *sysroot ATTRIBUTE_UNUSED,
const char *iprefix ATTRIBUTE_UNUSED, int stdinc)
{
if (stdinc)
{
@ -476,5 +520,3 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
return 0;
}
struct target_c_incpath_s target_c_incpath = C_INCPATH_INIT;

View File

@ -238,6 +238,7 @@ extern const char *darwin_fix_and_continue_switch;
their names so all of them get passed. */
#define LINK_SPEC \
"%{static}%{!static:-dynamic} \
%{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)}\
%{!Zdynamiclib: \
%{Zbundle:-bundle} \
%{Zbundle_loader*:-bundle_loader %*} \
@ -962,7 +963,9 @@ enum machopic_addr_class {
#undef ASM_APP_OFF
#define ASM_APP_OFF ""
void darwin_register_frameworks (int);
void darwin_register_frameworks (const char *, const char *, int);
void darwin_register_objc_includes (const char *, const char *, int);
#define TARGET_EXTRA_PRE_INCLUDES darwin_register_objc_includes
#define TARGET_EXTRA_INCLUDES darwin_register_frameworks
void add_framework_path (char *);

View File

@ -7,7 +7,7 @@ darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(CPPLIB_H) tree.h c-pragma.h $(C_TREE_H) toplev.h $(TM_P_H) \
c-incpath.h
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/darwin-c.c
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/darwin-c.c $(PREPROCESSOR_DEFINES)
gt-darwin.h : s-gtype ; @true

View File

@ -6361,6 +6361,16 @@ based on the existence of the first. Here is a small example of its usage:
crt0%O%s %:if-exists(crti%O%s) \
%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
@end smallexample
@item @code{replace-outfile}
The @code{replace-outfile} spec function takes two arguments. It looks for the
first argument in the outfiles array and replaces it with the second argument. Here
is a small example of its usage:
@smallexample
%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
@end smallexample
@end table
@item %@{@code{S}@}

View File

@ -9370,10 +9370,19 @@ system library's @code{pow}, @code{powf} or @code{powl} routines.
The default value places no upper bound on the multiplication count.
@end defmac
@deftypefn Macro void TARGET_EXTRA_INCLUDES (int @var{stdinc})
@deftypefn Macro void TARGET_EXTRA_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
This target hook should register any extra include files for the
target. The parameter @var{stdinc} indicates if normal include files
are present.
are present. The parameter @var{sysroot} is the system root directory.
The parameter @var{iprefix} is the prefix for the gcc directory.
@end deftypefn
@deftypefn Macro void TARGET_EXTRA_PRE_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
This target hook should register any extra include files for the
target before any standard headers. The parameter @var{stdinc}
indicates if normal include files are present. The parameter
@var{sysroot} is the system root directory. The parameter
@var{iprefix} is the prefix for the gcc directory.
@end deftypefn
@deftypefn Macro void TARGET_OPTF (char *@var{path})

View File

@ -82,9 +82,19 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "errors.h"
#ifdef TARGET_EXTRA_INCLUDES
static void hook_void_int(int u ATTRIBUTE_UNUSED) { }
void TARGET_EXTRA_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
const char *iprefix ATTRIBUTE_UNUSED,
int stdinc ATTRIBUTE_UNUSED)
{
}
#endif
struct target_c_incpath_s target_c_incpath = { hook_void_int };
#ifdef TARGET_EXTRA_PRE_INCLUDES
void TARGET_EXTRA_PRE_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
const char *iprefix ATTRIBUTE_UNUSED,
int stdinc ATTRIBUTE_UNUSED)
{
}
#endif
struct line_maps line_table;

View File

@ -361,6 +361,7 @@ static const char *convert_filename (const char *, int, int);
static const char *if_exists_spec_function (int, const char **);
static const char *if_exists_else_spec_function (int, const char **);
static const char *replace_outfile_spec_function (int, const char **);
/* The Specs Language
@ -1572,6 +1573,7 @@ static const struct spec_function static_spec_functions[] =
{
{ "if-exists", if_exists_spec_function },
{ "if-exists-else", if_exists_else_spec_function },
{ "replace-outfile", replace_outfile_spec_function },
{ 0, 0 }
};
@ -7582,3 +7584,24 @@ if_exists_else_spec_function (int argc, const char **argv)
return argv[1];
}
/* replace-outfile built-in spec function.
This looks for the first argument in the outfiles array's name and replaces it
with the second argument. */
static const char *
replace_outfile_spec_function (int argc, const char **argv)
{
int i;
/* Must have exactly two arguments. */
if (argc != 2)
abort ();
for (i = 0; i < n_infiles; i++)
{
if (outfiles[i] && !strcmp (outfiles[i], argv[0]))
outfiles[i] = xstrdup (argv[1]);
}
return NULL;
}