This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add -iframework
- From: Mike Stump <mrs at apple dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: "gcc-patches at gcc dot gnu dot org Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 5 Mar 2007 17:50:08 -0800
- Subject: Re: Add -iframework
- References: <A6510708-D7DF-493A-878D-63C0C607EB41@apple.com> <451D5F91.3020608@codesourcery.com> <01708ED7-4ACE-4C7D-B279-F5F2EA24A345@apple.com> <451D7366.1060907@codesourcery.com> <49183844-F192-4AF8-8591-0EBA5D9772E8@apple.com> <4529D35F.60209@codesourcery.com> <5FC2D911-C6D9-4CAE-8513-B014AB64B72F@apple.com> <45E7B0B5.6050304@codesourcery.com>
On Mar 1, 2007, at 9:05 PM, Mark Mitchell wrote:
"The main difference between this @option{-iframework} and @option{-F}
is that with @option{-iframework} the compiler does not ..."
Sounds good, fixed.
Why is that the default? Shouldn't the default be to return false, as
the Darwin hook does for all options except -iframework? In fact, the
default *does* return false.
Yup, just a typo. Fixed the documentation.
+This option is useful when option processing calls routines only
+available for the C language family.
+See @code{TARGET_HANDLE_OPTION} above for more information.
+@end deftypefn
"In general, you should use @some-kind-of-xref{TARGET_HANDLE_OPTION}
to
handle options. However, if processing an option requires routines
that
are only available in the C (and related language) front ends, then
you
should use @code{TARGET_HANDLE_C_OPTION} instead."
Sounds good, fixed, save the @xref/@pxref bit. I tried to use @anchor
with both @xref and @pxref to do the cross reference, neither seemed
to work for me (tested by make html), so I left it as @code to better
match the rest of the *.texi files. If someone can confirm that
@pxref works for them, I'd be happy to update it, though, I still
think it would be better for a maintainer to update all
@code{TARGET.*} at once. Let me know.
OK with those changes, assuming no objections from C maintainers in 48
hours.
Thanks.
Below is the final version I checked in. I corrected the ChangeLog
slightly and linux building.
mrs2 $ cat ~/diffs/framework-1e.diffs.txt
2007-03-05 Mike Stump <mrs@apple.com>
* c-common.c (targetcm): Add.
* c-opts.c (c_common_handle_option): Handle language specific
target options.
* opts.c (handle_option): Verify language for target options, if
any are given.
* opth-gen.awk: Add CL_LANG_ALL.
* target-def.h (TARGET_HANDLE_C_OPTION): Add.
(TARGETCM_INITIALIZER): Add.
* target.h (struct gcc_targetcm): Add.
(targetcm): Add.
* targhooks.c (default_handle_c_option): Add.
* targhooks.h (default_handle_c_option): Add.
* doc/tm.texi (TARGET_HANDLE_C_OPTION): Add.
* config/darwin.opt (iframework): Add.
* config/darwin.h (TARGET_HAS_TARGETCM): Add.
* config/darwin-c.c (handle_c_option): Add.
(TARGET_HANDLE_C_OPTION): Add.
(targetcm): Add.
* doc/invoke.texi (Darwin Options): Add -iframework.
Doing diffs in .:
--- ./c-common.c.~1~ 2007-03-05 16:00:47.000000000 -0800
+++ ./c-common.c 2007-03-05 16:02:48.000000000 -0800
@@ -48,6 +48,7 @@ Software Foundation, 51 Franklin Street,
#include "opts.h"
#include "real.h"
#include "cgraph.h"
+#include "target-def.h"
cpp_reader *parse_in; /* Declared in c-pragma.h. */
@@ -6926,4 +6927,8 @@ c_build_cdtor_fns (void)
}
}
+#ifndef TARGET_HAS_TARGETCM
+struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
+#endif
+
#include "gt-c-common.h"
--- ./c-opts.c.~1~ 2007-03-05 16:00:47.000000000 -0800
+++ ./c-opts.c 2007-03-05 16:02:48.000000000 -0800
@@ -39,6 +39,7 @@ Software Foundation, 51 Franklin Street,
#include "opts.h"
#include "options.h"
#include "mkdeps.h"
+#include "target.h"
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
@@ -278,7 +279,12 @@ c_common_handle_option (size_t scode, co
{
default:
if (cl_options[code].flags & (CL_C | CL_CXX | CL_ObjC |
CL_ObjCXX))
- break;
+ {
+ if ((option->flags & CL_TARGET)
+ && ! targetcm.handle_c_option (scode, arg, value))
+ result = 0;
+ break;
+ }
#ifdef CL_Fortran
if (lang_fortran && (cl_options[code].flags & (CL_Fortran)))
break;
--- ./config/darwin-c.c.~1~ 2007-03-05 15:59:30.000000000 -0800
+++ ./config/darwin-c.c 2007-03-05 16:02:48.000000000 -0800
@@ -34,6 +34,8 @@ Boston, MA 02110-1301, USA. */
#include "tm_p.h"
#include "cppdefault.h"
#include "prefix.h"
+#include "target.h"
+#include "target-def.h"
/* Pragmas. */
@@ -42,13 +44,6 @@ Boston, MA 02110-1301, USA. */
static bool using_frameworks = false;
-/* Maintain a small stack of alignments. This is similar to pragma
- pack's stack, but simpler. */
-
-static void push_field_alignment (int);
-static void pop_field_alignment (void);
-static const char *find_subframework_file (const char *, const char *);
-static void add_system_framework_path (char *);
static const char *find_subframework_header (cpp_reader *pfile,
const char *header,
cpp_dir **dirp);
@@ -60,6 +55,9 @@ typedef struct align_stack
static struct align_stack * field_align_stack = NULL;
+/* Maintain a small stack of alignments. This is similar to pragma
+ pack's stack, but simpler. */
+
static void
push_field_alignment (int bit_alignment)
{
@@ -619,3 +617,31 @@ darwin_cpp_builtins (cpp_reader *pfile)
builtin_define_with_value
("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__",
version_as_macro(), false);
}
+
+/* Handle C family front-end options. */
+
+static bool
+handle_c_option (size_t code,
+ const char *arg,
+ int value ATTRIBUTE_UNUSED)
+{
+ switch (code)
+ {
+ default:
+ /* Unrecognized options that we said we'd handle turn into
+ errors if not listed here. */
+ return false;
+
+ case OPT_iframework:
+ add_system_framework_path (xstrdup (arg));
+ break;
+ }
+
+ /* We recognized the option. */
+ return true;
+}
+
+#undef TARGET_HANDLE_C_OPTION
+#define TARGET_HANDLE_C_OPTION handle_c_option
+
+struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
--- ./config/darwin.h.~1~ 2007-03-05 15:59:30.000000000 -0800
+++ ./config/darwin.h 2007-03-05 16:02:48.000000000 -0800
@@ -980,4 +980,6 @@ extern int flag_mkernel;
extern int flag_apple_kext;
#define TARGET_KEXTABI flag_apple_kext
+#define TARGET_HAS_TARGETCM 1
+
#endif /* CONFIG_DARWIN_H */
--- ./config/darwin.opt.~1~ 2007-03-05 15:59:30.000000000 -0800
+++ ./config/darwin.opt 2007-03-05 16:02:48.000000000 -0800
@@ -42,3 +42,7 @@ Generate code for darwin loadable kernel
mkernel
Target Report Var(flag_mkernel)
Generate code for the kernel or loadable kernel extensions
+
+iframework
+Target RejectNegative C ObjC C++ ObjC++ Joined Separate
+-iframework <dir> Add <dir> to the end of the system framework
include path
--- ./doc/invoke.texi.~1~ 2007-03-05 16:00:37.000000000 -0800
+++ ./doc/invoke.texi 2007-03-05 16:02:48.000000000 -0800
@@ -462,6 +462,7 @@ Objective-C and Objective-C++ Dialects}.
-dynamic -dynamiclib -exported_symbols_list @gol
-filelist -flat_namespace -force_cpusubtype_ALL @gol
-force_flat_namespace -headerpad_max_install_names @gol
+-iframework @gol
-image_base -init -install_name -keep_private_externs @gol
-multi_module -multiply_defined -multiply_defined_unused @gol
-noall_load -no_dead_strip_inits_and_terms @gol
@@ -8463,6 +8464,14 @@ in @samp{"/System/Library/Frameworks"} a
the name of the framework and header.h is found in the
@samp{"PrivateHeaders"} or @samp{"Headers"} directory.
+@item -iframework@var{dir}
+@opindex iframework
+Like @option{-F} except the directory is a treated as a system
+directory. The main difference between this @option{-iframework} and
+@option{-F} is that with @option{-iframework} the compiler does not
+warn about constructs contained within header files found via
+@var{dir}. This option is valid only for the C family of languages.
+
@item -gused
@opindex -gused
Emit debugging information for symbols that are used. For STABS
--- ./doc/tm.texi.~1~ 2007-03-05 16:00:37.000000000 -0800
+++ ./doc/tm.texi 2007-03-05 16:02:48.000000000 -0800
@@ -773,6 +773,19 @@ argument. Otherwise @var{value} is 1 if
option was used and 0 if the ``no-'' form was.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_HANDLE_C_OPTION (size_t
@var{code}, const char *@var{arg}, int @var{value})
+This target hook is called whenever the user specifies one of the
+target-specific C language family options described by the @file{.opt}
+definition files(@pxref{Options}). It has the opportunity to do some
+option-specific processing and should return true if the option is
+valid. The default definition does nothing but return false.
+
+In general, you should use @code{TARGET_HANDLE_OPTION} to handle
+options. However, if processing an option requires routines that are
+only available in the C (and related language) front ends, then you
+should use @code{TARGET_HANDLE_C_OPTION} instead.
+@end deftypefn
+
@defmac TARGET_VERSION
This macro is a C statement to print on @code{stderr} a string
describing the particular machine description choice. Every machine
--- ./opth-gen.awk.~1~ 2007-03-05 15:59:30.000000000 -0800
+++ ./opth-gen.awk 2007-03-05 16:02:48.000000000 -0800
@@ -139,6 +139,7 @@ for (i = 0; i < n_langs; i++) {
s = substr(" ", length (macros[i]))
print "#define " macros[i] s " (1 << " i ")"
}
+print "#define CL_LANG_ALL ((1 << " n_langs ") - 1)"
print ""
print "enum opt_code"
--- ./opts.c.~1~ 2007-03-05 15:59:30.000000000 -0800
+++ ./opts.c 2007-03-05 16:02:48.000000000 -0800
@@ -268,6 +268,15 @@ handle_option (const char **argv, unsign
complain_wrong_lang (argv[0], option, lang_mask);
goto done;
}
+ else if ((option->flags & CL_TARGET)
+ && (option->flags & CL_LANG_ALL)
+ && !(option->flags & lang_mask))
+ {
+ /* Complain for target flag language mismatches if any languages
+ are specified. */
+ complain_wrong_lang (argv[0], option, lang_mask);
+ goto done;
+ }
if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
{
--- ./target-def.h.~1~ 2007-03-05 16:00:47.000000000 -0800
+++ ./target-def.h 2007-03-05 16:02:48.000000000 -0800
@@ -730,5 +730,8 @@ Foundation, 51 Franklin Street, Fifth Fl
TARGET_ARM_EABI_UNWINDER \
}
+#define TARGET_HANDLE_C_OPTION default_handle_c_option
+#define TARGETCM_INITIALIZER { TARGET_HANDLE_C_OPTION }
+
#include "hooks.h"
#include "targhooks.h"
--- ./target.h.~1~ 2007-03-05 16:00:47.000000000 -0800
+++ ./target.h 2007-03-05 16:02:48.000000000 -0800
@@ -892,4 +892,16 @@ struct gcc_target
extern struct gcc_target targetm;
+struct gcc_targetcm {
+ /* Handle target switch CODE (an OPT_* value). ARG is the argument
+ passed to the switch; it is NULL if no argument was. VALUE is the
+ value of ARG if CODE specifies a UInteger option, otherwise it is
+ 1 if the positive form of the switch was used and 0 if the
negative
+ form was. Return true if the switch was valid. */
+ bool (*handle_c_option) (size_t code, const char *arg, int value);
+};
+
+/* Each target can provide their own. */
+extern struct gcc_targetcm targetcm;
+
#endif /* GCC_TARGET_H */
--- ./targhooks.c.~1~ 2007-03-05 15:59:30.000000000 -0800
+++ ./targhooks.c 2007-03-05 16:02:48.000000000 -0800
@@ -614,4 +614,12 @@ default_narrow_bitfield (void)
return !STRICT_ALIGNMENT;
}
+bool
+default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
+ const char *arg ATTRIBUTE_UNUSED,
+ int value ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+
#include "gt-targhooks.h"
--- ./targhooks.h.~1~ 2007-03-05 15:59:30.000000000 -0800
+++ ./targhooks.h 2007-03-05 16:02:48.000000000 -0800
@@ -82,3 +82,4 @@ extern enum reg_class default_secondary_
enum machine_mode,
secondary_reload_info *);
extern void hook_void_bitmap (bitmap);
+extern bool default_handle_c_option (size_t, const char *, int);
--------------