annotate gcc/config/darwin-driver.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Additional functions for the GCC driver on Darwin native.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2006-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Apple Computer Inc.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 any later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "config.h"
111
kono
parents: 67
diff changeset
22 #include "libiberty.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "coretypes.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "tm.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
26 #include "opts.h"
111
kono
parents: 67
diff changeset
27 #include "diagnostic-core.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
28
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
29 /* Validate a version string (either given on the command line or, perhaps
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
30 as MACOSX_DEPLOYMENT_TARGET).
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
31
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
32 The specs %version-compare() function doesn't accept leading '0' on
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
33 numbers so strip them out. Do sanity checking here too.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
34
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
35 Return:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
36 * original string means it was OK and we didn't want to change it.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
37 * new string means it was OK but we rewrote it to avoid possible format
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
38 problems.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
39 * NULL means we didn't like what we saw.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
40 */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
41
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
42 static const char *
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
43 validate_macosx_version_min (const char *version_str)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
44 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
45 size_t version_len;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
46 unsigned long major, minor, tiny = 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
47 char *end;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
48 const char *old_version = version_str;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
49 bool need_rewrite = false;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
50
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
51 version_len = strlen (version_str);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
52 if (version_len < 4) /* The minimum would be 10.x */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
53 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
54
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
55 /* Version string must consist of digits and periods only. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
56 if (strspn (version_str, "0123456789.") != version_len)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
57 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
58
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
59 if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
60 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
61
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
62 if (version_str[0] == '0')
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
63 need_rewrite = true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
64
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
65 major = strtoul (version_str, &end, 10);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
66 version_str = end + ((*end == '.') ? 1 : 0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
67
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
68 if (major != 10) /* So far .. all MacOS 10 ... */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
69 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
70
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
71 /* Version string components must be present and numeric. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
72 if (!ISDIGIT (version_str[0]))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
73 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
74
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
75 /* If we have one or more leading zeros on a component, then rewrite the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
76 version string. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
77 if (version_str[0] == '0' && version_str[1] != '\0'
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
78 && version_str[1] != '.')
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
79 need_rewrite = true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
80
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
81 minor = strtoul (version_str, &end, 10);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
82 version_str = end + ((*end == '.') ? 1 : 0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
83 if (minor > 99)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
84 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
85
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
86 /* If 'tiny' is present it must be numeric. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
87 if (*end != '\0' && !ISDIGIT (version_str[0]))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
88 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
89
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
90 /* If we have one or more leading zeros on a component, then rewrite the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
91 version string. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
92 if (*end != '\0' && version_str[0] == '0'
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
93 && version_str[1] != '\0')
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
94 need_rewrite = true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
95
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
96 tiny = strtoul (version_str, &end, 10);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
97 if (tiny > 99)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
98 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
99
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
100 /* Version string must contain no more than three tokens. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
101 if (*end != '\0')
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
102 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
103
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
104 if (need_rewrite)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
105 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
106 char *new_version;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
107 asprintf (&new_version, "10.%lu.%lu", minor, tiny);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
108 return new_version;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
109 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
110
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
111 return old_version;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
112 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
113
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
114 #ifndef CROSS_DIRECTORY_STRUCTURE
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 #include <sys/sysctl.h>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 #include "xregex.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
111
kono
parents: 67
diff changeset
118 static char *
kono
parents: 67
diff changeset
119 darwin_find_version_from_kernel (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 char osversion[32];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 size_t osversion_len = sizeof (osversion) - 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 static int osversion_name[2] = { CTL_KERN, KERN_OSRELEASE };
111
kono
parents: 67
diff changeset
124 int major_vers;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 char * version_p;
111
kono
parents: 67
diff changeset
126 char * new_flag;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 /* Determine the version of the running OS. If we can't, warn user,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 and do nothing. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 if (sysctl (osversion_name, ARRAY_SIZE (osversion_name), osversion,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 &osversion_len, NULL, 0) == -1)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
133 warning (0, "sysctl for kern.osversion failed: %m");
111
kono
parents: 67
diff changeset
134 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 /* Try to parse the first two parts of the OS version number. Warn
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 user and return if it doesn't make sense. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 if (! ISDIGIT (osversion[0]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 goto parse_failed;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 major_vers = osversion[0] - '0';
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 version_p = osversion + 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 if (ISDIGIT (*version_p))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 major_vers = major_vers * 10 + (*version_p++ - '0');
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 if (*version_p++ != '.')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 goto parse_failed;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 /* The major kernel version number is 4 plus the second OS version
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 component. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 if (major_vers - 4 <= 4)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 /* On 10.4 and earlier, the old linker is used which does not
111
kono
parents: 67
diff changeset
152 support three-component system versions.
kono
parents: 67
diff changeset
153 FIXME: we should not assume this - a newer linker could be used. */
kono
parents: 67
diff changeset
154 asprintf (&new_flag, "10.%d", major_vers - 4);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 else
111
kono
parents: 67
diff changeset
156 /* Although the newer linker supports three-component system
kono
parents: 67
diff changeset
157 versions, there's no guarantee that the minor version component
kono
parents: 67
diff changeset
158 of the kernel and the system are the same. Apple's clang always
kono
parents: 67
diff changeset
159 uses 0 as the minor version: do the same. */
kono
parents: 67
diff changeset
160 asprintf (&new_flag, "10.%d.0", major_vers - 4);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
111
kono
parents: 67
diff changeset
162 return new_flag;
kono
parents: 67
diff changeset
163
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 parse_failed:
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
165 warning (0, "couldn%'t understand kern.osversion %q.*s",
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 (int) osversion_len, osversion);
111
kono
parents: 67
diff changeset
167 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 }
111
kono
parents: 67
diff changeset
169 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
111
kono
parents: 67
diff changeset
171 /* When running on a Darwin system and using that system's headers and
kono
parents: 67
diff changeset
172 libraries, default the -mmacosx-version-min flag to be the version
kono
parents: 67
diff changeset
173 of the system on which the compiler is running.
kono
parents: 67
diff changeset
174
kono
parents: 67
diff changeset
175 When building cross or native cross compilers, default to the OSX
kono
parents: 67
diff changeset
176 version of the target (as provided by the most specific target header
kono
parents: 67
diff changeset
177 included in tm.h). This may be overidden by setting the flag explicitly
kono
parents: 67
diff changeset
178 (or by the MACOSX_DEPLOYMENT_TARGET environment). */
kono
parents: 67
diff changeset
179
kono
parents: 67
diff changeset
180 static const char *
kono
parents: 67
diff changeset
181 darwin_default_min_version (void)
kono
parents: 67
diff changeset
182 {
kono
parents: 67
diff changeset
183 /* Try to retrieve the deployment target from the environment. */
kono
parents: 67
diff changeset
184 const char *new_flag = getenv ("MACOSX_DEPLOYMENT_TARGET");
kono
parents: 67
diff changeset
185
kono
parents: 67
diff changeset
186 /* Apparently, an empty string for MACOSX_DEPLOYMENT_TARGET means
kono
parents: 67
diff changeset
187 "use the default". Or, possibly "use 10.1". We choose
kono
parents: 67
diff changeset
188 to ignore the environment variable, as if it was never set. */
kono
parents: 67
diff changeset
189 if (new_flag == NULL || new_flag[0] == 0)
kono
parents: 67
diff changeset
190 #ifndef CROSS_DIRECTORY_STRUCTURE
kono
parents: 67
diff changeset
191 /* Try to find the version from the kernel, if we fail - we print a
kono
parents: 67
diff changeset
192 message and give up. */
kono
parents: 67
diff changeset
193 new_flag = darwin_find_version_from_kernel ();
kono
parents: 67
diff changeset
194 #else
kono
parents: 67
diff changeset
195 /* For cross-compilers, default to a minimum version determined by
kono
parents: 67
diff changeset
196 the configuration. */
kono
parents: 67
diff changeset
197 new_flag = DEF_MIN_OSX_VERSION;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 #endif /* CROSS_DIRECTORY_STRUCTURE */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
199
111
kono
parents: 67
diff changeset
200 if (new_flag != NULL)
kono
parents: 67
diff changeset
201 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
202 const char *checked = validate_macosx_version_min (new_flag);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
203 if (checked == NULL)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
204 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
205 warning (0, "couldn%'t understand version %s", new_flag);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
206 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
207 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
208 new_flag = xstrndup (checked, strlen (checked));
111
kono
parents: 67
diff changeset
209 }
kono
parents: 67
diff changeset
210 return new_flag;
kono
parents: 67
diff changeset
211 }
kono
parents: 67
diff changeset
212
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
213 /* See if we can find the sysroot from the SDKROOT environment variable. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
214
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
215 static const char *
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
216 maybe_get_sysroot_from_sdkroot ()
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
217 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
218 const char *maybe_sysroot = getenv ("SDKROOT");
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
219
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
220 /* We'll use the same rules as the clang driver, for compatibility.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
221 1) The path must be absolute
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
222 2) Ignore "/", that is the default anyway and we do not want the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
223 sysroot semantics to be applied to it.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
224 3) It must exist (actually, we'll check it's readable too). */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
225
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
226 if (maybe_sysroot == NULL
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 || *maybe_sysroot != '/'
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228 || strlen (maybe_sysroot) == 1
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
229 || access (maybe_sysroot, R_OK) == -1)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
230 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
231
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
232 return xstrndup (maybe_sysroot, strlen (maybe_sysroot));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
233 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
234
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
235 /* Translate -filelist and -framework options in *DECODED_OPTIONS
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
236 (size *DECODED_OPTIONS_COUNT) to use -Xlinker so that they are
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
237 considered to be linker inputs in the case that no other inputs are
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
238 specified. Handling these options in DRIVER_SELF_SPECS does not
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
239 suffice because specs are too late to add linker inputs, and
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
240 handling them in LINK_SPEC does not suffice because the linker will
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
241 not be called if there are no other inputs. When native, also
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
242 default the -mmacosx-version-min flag. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
243
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
244 void
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
245 darwin_driver_init (unsigned int *decoded_options_count,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
246 struct cl_decoded_option **decoded_options)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
247 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
248 unsigned int i;
111
kono
parents: 67
diff changeset
249 bool seenX86 = false;
kono
parents: 67
diff changeset
250 bool seenX86_64 = false;
kono
parents: 67
diff changeset
251 bool seenPPC = false;
kono
parents: 67
diff changeset
252 bool seenPPC64 = false;
kono
parents: 67
diff changeset
253 bool seenM32 = false;
kono
parents: 67
diff changeset
254 bool seenM64 = false;
kono
parents: 67
diff changeset
255 bool appendM32 = false;
kono
parents: 67
diff changeset
256 bool appendM64 = false;
kono
parents: 67
diff changeset
257 const char *vers_string = NULL;
kono
parents: 67
diff changeset
258 bool seen_version_min = false;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
259 bool seen_sysroot_p = false;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
260
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
261 for (i = 1; i < *decoded_options_count; i++)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
262 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
263 if ((*decoded_options)[i].errors & CL_ERR_MISSING_ARG)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
264 continue;
111
kono
parents: 67
diff changeset
265
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
266 switch ((*decoded_options)[i].opt_index)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
267 {
111
kono
parents: 67
diff changeset
268 case OPT_arch:
kono
parents: 67
diff changeset
269 /* Support provision of a single -arch xxxx flag as a means of
kono
parents: 67
diff changeset
270 specifying the sub-target/multi-lib. Translate this into -m32/64
kono
parents: 67
diff changeset
271 as appropriate. */
kono
parents: 67
diff changeset
272 if (!strcmp ((*decoded_options)[i].arg, "i386"))
kono
parents: 67
diff changeset
273 seenX86 = true;
kono
parents: 67
diff changeset
274 else if (!strcmp ((*decoded_options)[i].arg, "x86_64"))
kono
parents: 67
diff changeset
275 seenX86_64 = true;
kono
parents: 67
diff changeset
276 else if (!strcmp ((*decoded_options)[i].arg, "ppc"))
kono
parents: 67
diff changeset
277 seenPPC = true;
kono
parents: 67
diff changeset
278 else if (!strcmp ((*decoded_options)[i].arg, "ppc64"))
kono
parents: 67
diff changeset
279 seenPPC64 = true;
kono
parents: 67
diff changeset
280 else
kono
parents: 67
diff changeset
281 error ("this compiler does not support %s",
kono
parents: 67
diff changeset
282 (*decoded_options)[i].arg);
kono
parents: 67
diff changeset
283 /* Now we've examined it, drop the -arch arg. */
kono
parents: 67
diff changeset
284 if (*decoded_options_count > i) {
kono
parents: 67
diff changeset
285 memmove (*decoded_options + i,
kono
parents: 67
diff changeset
286 *decoded_options + i + 1,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
287 ((*decoded_options_count - i - 1)
111
kono
parents: 67
diff changeset
288 * sizeof (struct cl_decoded_option)));
kono
parents: 67
diff changeset
289 }
kono
parents: 67
diff changeset
290 --i;
kono
parents: 67
diff changeset
291 --*decoded_options_count;
kono
parents: 67
diff changeset
292 break;
kono
parents: 67
diff changeset
293
kono
parents: 67
diff changeset
294 case OPT_m32:
kono
parents: 67
diff changeset
295 seenM32 = true;
kono
parents: 67
diff changeset
296 break;
kono
parents: 67
diff changeset
297
kono
parents: 67
diff changeset
298 case OPT_m64:
kono
parents: 67
diff changeset
299 seenM64 = true;
kono
parents: 67
diff changeset
300 break;
kono
parents: 67
diff changeset
301
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
302 case OPT_filelist:
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
303 case OPT_framework:
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
304 ++*decoded_options_count;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
305 *decoded_options = XRESIZEVEC (struct cl_decoded_option,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
306 *decoded_options,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
307 *decoded_options_count);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
308 memmove (*decoded_options + i + 2,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
309 *decoded_options + i + 1,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
310 ((*decoded_options_count - i - 2)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
311 * sizeof (struct cl_decoded_option)));
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
312 generate_option (OPT_Xlinker, (*decoded_options)[i].arg, 1,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
313 CL_DRIVER, &(*decoded_options)[i + 1]);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
314 generate_option (OPT_Xlinker,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
315 (*decoded_options)[i].canonical_option[0], 1,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
316 CL_DRIVER, &(*decoded_options)[i]);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
317 break;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
318
111
kono
parents: 67
diff changeset
319 case OPT_mmacosx_version_min_:
kono
parents: 67
diff changeset
320 seen_version_min = true;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
321 vers_string =
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
322 validate_macosx_version_min ((*decoded_options)[i].arg);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
323 if (vers_string == NULL)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
324 warning (0, "%qs is not valid for %<mmacosx-version-min%>",
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
325 (*decoded_options)[i].arg);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
326 else if (vers_string == (*decoded_options)[i].arg)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
327 vers_string = xstrndup ((*decoded_options)[i].arg, 32);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
328 /* Now we've examined it, and verified/re-written, put it to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
329 one side and append later. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
330 if (*decoded_options_count > i) {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
331 memmove (*decoded_options + i,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
332 *decoded_options + i + 1,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
333 ((*decoded_options_count - i - 1)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
334 * sizeof (struct cl_decoded_option)));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 --i;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
337 --*decoded_options_count;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
338 break;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
339
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
340 case OPT__sysroot_:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
341 case OPT_isysroot:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
342 seen_sysroot_p = true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
343 break;
111
kono
parents: 67
diff changeset
344
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
345 default:
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
346 break;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
347 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
348 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
349
111
kono
parents: 67
diff changeset
350 /* Turn -arch xxxx into the appropriate -m32/-m64 flag.
kono
parents: 67
diff changeset
351 If the User tried to specify multiple arch flags (which is possible with
kono
parents: 67
diff changeset
352 some Darwin compilers) warn that this mode is not supported by this
kono
parents: 67
diff changeset
353 compiler (and ignore the arch flags, which means that the default multi-
kono
parents: 67
diff changeset
354 lib will be generated). */
kono
parents: 67
diff changeset
355 /* TODO: determine if these warnings would better be errors. */
kono
parents: 67
diff changeset
356 #if DARWIN_X86
kono
parents: 67
diff changeset
357 if (seenPPC || seenPPC64)
kono
parents: 67
diff changeset
358 warning (0, "this compiler does not support PowerPC (arch flags ignored)");
kono
parents: 67
diff changeset
359 if (seenX86)
kono
parents: 67
diff changeset
360 {
kono
parents: 67
diff changeset
361 if (seenX86_64 || seenM64)
kono
parents: 67
diff changeset
362 warning (0, "%s conflicts with i386 (arch flags ignored)",
kono
parents: 67
diff changeset
363 (seenX86_64? "x86_64": "m64"));
kono
parents: 67
diff changeset
364 else if (! seenM32) /* Add -m32 if the User didn't. */
kono
parents: 67
diff changeset
365 appendM32 = true;
kono
parents: 67
diff changeset
366 }
kono
parents: 67
diff changeset
367 else if (seenX86_64)
kono
parents: 67
diff changeset
368 {
kono
parents: 67
diff changeset
369 if (seenX86 || seenM32)
kono
parents: 67
diff changeset
370 warning (0, "%s conflicts with x86_64 (arch flags ignored)",
kono
parents: 67
diff changeset
371 (seenX86? "i386": "m32"));
kono
parents: 67
diff changeset
372 else if (! seenM64) /* Add -m64 if the User didn't. */
kono
parents: 67
diff changeset
373 appendM64 = true;
kono
parents: 67
diff changeset
374 }
kono
parents: 67
diff changeset
375 #elif DARWIN_PPC
kono
parents: 67
diff changeset
376 if (seenX86 || seenX86_64)
kono
parents: 67
diff changeset
377 warning (0, "this compiler does not support X86 (arch flags ignored)");
kono
parents: 67
diff changeset
378 if (seenPPC)
kono
parents: 67
diff changeset
379 {
kono
parents: 67
diff changeset
380 if (seenPPC64 || seenM64)
kono
parents: 67
diff changeset
381 warning (0, "%s conflicts with ppc (arch flags ignored)",
kono
parents: 67
diff changeset
382 (seenPPC64? "ppc64": "m64"));
kono
parents: 67
diff changeset
383 else if (! seenM32) /* Add -m32 if the User didn't. */
kono
parents: 67
diff changeset
384 appendM32 = true;
kono
parents: 67
diff changeset
385 }
kono
parents: 67
diff changeset
386 else if (seenPPC64)
kono
parents: 67
diff changeset
387 {
kono
parents: 67
diff changeset
388 if (seenPPC || seenM32)
kono
parents: 67
diff changeset
389 warning (0, "%s conflicts with ppc64 (arch flags ignored)",
kono
parents: 67
diff changeset
390 (seenPPC? "ppc": "m32"));
kono
parents: 67
diff changeset
391 else if (! seenM64) /* Add -m64 if the User didn't. */
kono
parents: 67
diff changeset
392 appendM64 = true;
kono
parents: 67
diff changeset
393 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
394 #endif
111
kono
parents: 67
diff changeset
395
kono
parents: 67
diff changeset
396 if (appendM32 || appendM64)
kono
parents: 67
diff changeset
397 {
kono
parents: 67
diff changeset
398 ++*decoded_options_count;
kono
parents: 67
diff changeset
399 *decoded_options = XRESIZEVEC (struct cl_decoded_option,
kono
parents: 67
diff changeset
400 *decoded_options,
kono
parents: 67
diff changeset
401 *decoded_options_count);
kono
parents: 67
diff changeset
402 generate_option (appendM32 ? OPT_m32 : OPT_m64, NULL, 1, CL_DRIVER,
kono
parents: 67
diff changeset
403 &(*decoded_options)[*decoded_options_count - 1]);
kono
parents: 67
diff changeset
404 }
kono
parents: 67
diff changeset
405
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
406 if (! seen_sysroot_p)
111
kono
parents: 67
diff changeset
407 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
408 /* We will pick up an SDKROOT if we didn't specify a sysroot and treat
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
409 it as overriding any configure-time --with-sysroot. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
410 const char *sdkroot = maybe_get_sysroot_from_sdkroot ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
411 if (sdkroot)
111
kono
parents: 67
diff changeset
412 {
kono
parents: 67
diff changeset
413 ++*decoded_options_count;
kono
parents: 67
diff changeset
414 *decoded_options = XRESIZEVEC (struct cl_decoded_option,
kono
parents: 67
diff changeset
415 *decoded_options,
kono
parents: 67
diff changeset
416 *decoded_options_count);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
417 generate_option (OPT__sysroot_, sdkroot, 1, CL_DRIVER,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
418 &(*decoded_options)[*decoded_options_count - 1]);
111
kono
parents: 67
diff changeset
419 }
kono
parents: 67
diff changeset
420 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
421
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
422 /* We will need to know the OS X version we're trying to build for here
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
423 so that we can figure out the mechanism and source for the sysroot to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
424 be used. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
425 if (! seen_version_min && *decoded_options_count > 1)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
426 /* Not set by the User, try to figure it out. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
427 vers_string = darwin_default_min_version ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
428
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
429 /* Create and push a cleaned up version, plus the major version for
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
430 assemblers and other cases that need it. */
111
kono
parents: 67
diff changeset
431 if (vers_string != NULL)
kono
parents: 67
diff changeset
432 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
433 ++*decoded_options_count;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
434 *decoded_options = XRESIZEVEC (struct cl_decoded_option,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
435 *decoded_options,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
436 *decoded_options_count);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
437 generate_option (OPT_mmacosx_version_min_, vers_string, 1, CL_DRIVER,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
438 &(*decoded_options)[*decoded_options_count - 1]);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
439
111
kono
parents: 67
diff changeset
440 char *asm_major = NULL;
kono
parents: 67
diff changeset
441 const char *first_period = strchr(vers_string, '.');
kono
parents: 67
diff changeset
442 if (first_period != NULL)
kono
parents: 67
diff changeset
443 {
kono
parents: 67
diff changeset
444 const char *second_period = strchr(first_period+1, '.');
kono
parents: 67
diff changeset
445 if (second_period != NULL)
kono
parents: 67
diff changeset
446 asm_major = xstrndup (vers_string, second_period-vers_string);
kono
parents: 67
diff changeset
447 else
kono
parents: 67
diff changeset
448 asm_major = xstrdup (vers_string);
kono
parents: 67
diff changeset
449 }
kono
parents: 67
diff changeset
450 /* Else we appear to have a weird macosx version with no major number.
kono
parents: 67
diff changeset
451 Punt on this for now. */
kono
parents: 67
diff changeset
452 if (asm_major != NULL)
kono
parents: 67
diff changeset
453 {
kono
parents: 67
diff changeset
454 ++*decoded_options_count;
kono
parents: 67
diff changeset
455 *decoded_options = XRESIZEVEC (struct cl_decoded_option,
kono
parents: 67
diff changeset
456 *decoded_options,
kono
parents: 67
diff changeset
457 *decoded_options_count);
kono
parents: 67
diff changeset
458 generate_option (OPT_asm_macosx_version_min_, asm_major, 1, CL_DRIVER,
kono
parents: 67
diff changeset
459 &(*decoded_options)[*decoded_options_count - 1]);
kono
parents: 67
diff changeset
460 }
kono
parents: 67
diff changeset
461 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
462 }