This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Darwin] Patch: new compiler option, -mmacosx-<version>
On Feb 20, 2004, at 5:30 PM, Stan Shebs wrote:
I take you didn't like my suggestion to compute a number instead of
using table lookup, or Zem's idea of using -mmacosx=xxx ? Using the '='
form would be more consistent with recent multi-value options like
-mcpu and -mtune, although I don't know if there's an objective reason
to choose = over -.
I don't have any strong preference between - and =. But
since you say that = is the preferred style nowadays, I
made that change.
+ if (v->vers_str)
+ macosx_version_min_required = v->vers_num;
This will be silent if the version number is not recognized, right?
I think if you're going to restrict values to the fixed table, there
ought to be at least be a warning that the specified number (or other
string) is perhaps mistaken. (Hey, maybe you could add "jaguar",
"panther", etc too.)
Good suggestion! I added "jaguar" and "panther" (no "etc",
since I think those are the only kitty-cat names that have
been used officially), and I added a warning if the version
is unrecognized. I also fixed the missing spaces.
New patch appended. OK to commit to mainline?
--Matt
Index: config/darwin-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin-protos.h,v
retrieving revision 1.29
diff -p -r1.29 darwin-protos.h
*** config/darwin-protos.h 10 Nov 2003 23:07:09 -0000 1.29
--- config/darwin-protos.h 21 Feb 2004 06:46:02 -0000
*************** along with GCC; see the file COPYING. I
*** 18,23 ****
--- 18,25 ----
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+ extern void darwin_parse_macosx_version_name (void);
+
extern int name_needs_quotes (const char *);
extern void machopic_validate_stub_or_non_lazy_ptr (const char *,
int);
Index: config/darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.57
diff -p -r1.57 darwin.c
*** config/darwin.c 7 Feb 2004 14:14:52 -0000 1.57
--- config/darwin.c 21 Feb 2004 06:46:03 -0000
*************** static void update_non_lazy_ptrs (const
*** 48,53 ****
--- 48,95 ----
static void update_stubs (const char *);
static const char *machopic_non_lazy_ptr_name (const char*);
+ /* Earliest operating system for which generated code is targeted, as
string
+ and as integer. The string form is "10.0", "10.1", etc. The
corresponding
+ numeric versions are 1000, 1010, etc. This number is used for
feature
+ tests of the form "enable_this_feature =
macosx_version_min_required >= n",
+ so 0 is a conservative default. */
+
+ const char *darwin_macosx_version_name;
+ unsigned int macosx_version_min_required = 0;
+
+ /* Parse -mdeployment-target- option. */
+
+ static struct darwin_macosx_vers {
+ const char *vers_str;
+ unsigned int vers_num;
+ } darwin_macosx_vers_tbl[] = {
+ { "10.0", 1000 },
+ { "10.1", 1010 },
+ { "10.2", 1020 },
+ { "jaguar", 1020 },
+ { "10.3", 1030 },
+ { "panther", 1030 },
+ { "10.4", 1040 },
+ { "10.5", 1050 },
+ { NULL, 0 }
+ };
+
+ void darwin_parse_macosx_version_name (void)
+ {
+ if (darwin_macosx_version_name)
+ {
+ struct darwin_macosx_vers *v = darwin_macosx_vers_tbl;
+ while (v->vers_str
+ && strcmp (darwin_macosx_version_name, v->vers_str) != 0)
+ v++;
+
+ if (v->vers_str)
+ macosx_version_min_required = v->vers_num;
+ else
+ warning ("-macosx=%s: unrecognized version",
darwin_macosx_version_name);
+ }
+ }
+
int
name_needs_quotes (const char *name)
{
Index: config/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.h,v
retrieving revision 1.68
diff -p -r1.68 darwin.h
*** config/darwin.h 13 Feb 2004 01:58:37 -0000 1.68
--- config/darwin.h 21 Feb 2004 06:46:03 -0000
*************** Boston, MA 02111-1307, USA. */
*** 82,87 ****
--- 82,100 ----
#undef DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 0
+ /* Strings provided by SUBTARGET_OPTIONS */
+ extern const char *darwin_macosx_version_name;
+
+ /* Override rs6000.h/i386.h definition */
+ #undef SUBTARGET_OPTIONS
+ #define SUBTARGET_OPTIONS \
+ { "macosx=", &darwin_macosx_version_name, \
+ N_("Earliest operating system for which code should be
generated"), 0 }
+
+ /* Earliest operating system for which generated code is targeted.
1000 for 10.0,
+ 1010 for 10.1, etc. */
+ extern unsigned int macosx_version_min_required;
+
/* This table intercepts weirdo options whose names would interfere
with normal driver conventions, and either translates them into
standardly-named options, or adds a 'Z' so that they can get to
Index: config/i386/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/darwin.h,v
retrieving revision 1.9
diff -p -r1.9 darwin.h
*** config/i386/darwin.h 27 Sep 2003 04:48:18 -0000 1.9
--- config/i386/darwin.h 21 Feb 2004 06:46:03 -0000
*************** Boston, MA 02111-1307, USA. */
*** 51,56 ****
--- 51,61 ----
#define SUBTARGET_EXTRA_SPECS \
{ "darwin_arch", "i386" },
+ #define SUBTARGET_OVERRIDE_OPTIONS \
+ do { \
+ darwin_parse_macosx_version_name ();
\
+ } while (0)
+
/* The Darwin assembler mostly follows AT&T syntax. */
#undef ASSEMBLER_DIALECT
#define ASSEMBLER_DIALECT ASM_ATT
Index: config/rs6000/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/darwin.h,v
retrieving revision 1.48
diff -p -r1.48 darwin.h
*** config/rs6000/darwin.h 7 Feb 2004 17:06:22 -0000 1.48
--- config/rs6000/darwin.h 21 Feb 2004 06:46:03 -0000
*************** do { \
*** 87,93 ****
flag_pic = 2; \
} \
} \
! }while(0)
/* We want -fPIC by default, unless we're using -static to compile for
the kernel or some such. */
--- 87,94 ----
flag_pic = 2; \
} \
} \
! darwin_parse_macosx_version_name ();
\
! } while (0)
/* We want -fPIC by default, unless we're using -static to compile for
the kernel or some such. */
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.410
diff -p -r1.410 invoke.texi
*** doc/invoke.texi 20 Feb 2004 18:42:51 -0000 1.410
--- doc/invoke.texi 21 Feb 2004 06:46:04 -0000
*************** in the following sections.
*** 462,468 ****
-single_module -static -sub_library -sub_umbrella @gol
-twolevel_namespace -umbrella -undefined @gol
-unexported_symbols_list -weak_reference_mismatches @gol
! -whatsloaded}
@emph{MIPS Options}
@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
--- 462,468 ----
-single_module -static -sub_library -sub_umbrella @gol
-twolevel_namespace -umbrella -undefined @gol
-unexported_symbols_list -weak_reference_mismatches @gol
! -whatsloaded -mmacosx=@var{ver}}
@emph{MIPS Options}
@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
*************** See man ld(1) for more information.
*** 7589,7594 ****
--- 7589,7601 ----
@opindex bundle_loader
This specifies the @var{executable} that will be loading the build
output file being linked. See man ld(1) for more information.
+
+ @item -mmacosx=@var{ver}
+ @opindex mmacosx
+ This specifies the earliest version of Mac OS for which code should
+ be generated. Specifying @code{-mmacosx=10.2}, for example, allows
+ the compiler to use features that were first made available in that
+ version of the operating system.
@item -allowable_client @var{client_name}
@itemx -arch_only