Skip to content

Commit 57e6d92

Browse files
committed
8296904: Improve handling of macos xcode toolchain
Reviewed-by: mbaesken Backport-of: 470f3424fcce0e41b75cccdd5e3a56771cd07ff5
1 parent 0f43f8e commit 57e6d92

File tree

3 files changed

+58
-42
lines changed

3 files changed

+58
-42
lines changed

doc/building.html

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -239,49 +239,49 @@ <h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requ
239239
<table>
240240
<thead>
241241
<tr class="header">
242-
<th style="text-align: left;">Operating system</th>
243-
<th style="text-align: left;">Supported toolchain</th>
242+
<th>Operating system</th>
243+
<th>Supported toolchain</th>
244244
</tr>
245245
</thead>
246246
<tbody>
247247
<tr class="odd">
248-
<td style="text-align: left;">Linux</td>
249-
<td style="text-align: left;">gcc, clang</td>
248+
<td>Linux</td>
249+
<td>gcc, clang</td>
250250
</tr>
251251
<tr class="even">
252-
<td style="text-align: left;">macOS</td>
253-
<td style="text-align: left;">Apple Xcode (using clang)</td>
252+
<td>macOS</td>
253+
<td>Apple Xcode (using clang)</td>
254254
</tr>
255255
<tr class="odd">
256-
<td style="text-align: left;">AIX</td>
257-
<td style="text-align: left;">IBM XL C/C++</td>
256+
<td>AIX</td>
257+
<td>IBM XL C/C++</td>
258258
</tr>
259259
<tr class="even">
260-
<td style="text-align: left;">Windows</td>
261-
<td style="text-align: left;">Microsoft Visual Studio</td>
260+
<td>Windows</td>
261+
<td>Microsoft Visual Studio</td>
262262
</tr>
263263
</tbody>
264264
</table>
265265
<p>Please see the individual sections on the toolchains for version recommendations. As a reference, these versions of the toolchains are used, at the time of writing, by Oracle for the daily builds of the JDK. It should be possible to compile the JDK with both older and newer versions, but the closer you stay to this list, the more likely you are to compile successfully without issues.</p>
266266
<table>
267267
<thead>
268268
<tr class="header">
269-
<th style="text-align: left;">Operating system</th>
270-
<th style="text-align: left;">Toolchain version</th>
269+
<th>Operating system</th>
270+
<th>Toolchain version</th>
271271
</tr>
272272
</thead>
273273
<tbody>
274274
<tr class="odd">
275-
<td style="text-align: left;">Linux</td>
276-
<td style="text-align: left;">gcc 10.2.0</td>
275+
<td>Linux</td>
276+
<td>gcc 10.2.0</td>
277277
</tr>
278278
<tr class="even">
279-
<td style="text-align: left;">macOS</td>
280-
<td style="text-align: left;">Apple Xcode 10.1 (using clang 10.0.0)</td>
279+
<td>macOS</td>
280+
<td>Apple Xcode 10.1 (using clang 10.0.0)</td>
281281
</tr>
282282
<tr class="odd">
283-
<td style="text-align: left;">Windows</td>
284-
<td style="text-align: left;">Microsoft Visual Studio 2022 update 17.1.0</td>
283+
<td>Windows</td>
284+
<td>Microsoft Visual Studio 2022 update 17.1.0</td>
285285
</tr>
286286
</tbody>
287287
</table>
@@ -295,12 +295,16 @@ <h3 id="clang">clang</h3>
295295
<p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
296296
<h3 id="apple-xcode">Apple Xcode</h3>
297297
<p>The oldest supported version of Xcode is 8.</p>
298-
<p>You will need the Xcode command lines developers tools to be able to build the JDK. (Actually, <em>only</em> the command lines tools are needed, not the IDE.) The simplest way to install these is to run:</p>
298+
<p>You will need the Xcode command line developer tools to be able to build the JDK. (Actually, <em>only</em> the command line tools are needed, not the IDE.) The simplest way to install these is to run:</p>
299299
<pre><code>xcode-select --install</code></pre>
300-
<p>It is advisable to keep an older version of Xcode for building the JDK when updating Xcode. This <a href="http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html">blog page</a> has good suggestions on managing multiple Xcode versions. To use a specific version of Xcode, use <code>xcode-select -s</code> before running <code>configure</code>, or use <code>--with-toolchain-path</code> to point to the version of Xcode to use, e.g. <code>configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin</code></p>
300+
<p>When updating Xcode, it is advisable to keep an older version for building the JDK. To use a specific version of Xcode you have multiple options:</p>
301+
<ul>
302+
<li>Use <code>xcode-select -s</code> before running <code>configure</code>, e.g. <code>xcode-select -s /Applications/Xcode13.1.app</code>. The drawback is that the setting is system wide and you may have to revert it after an OpenJDK build.</li>
303+
<li>Use configure option <code>--with-xcode-path</code>, e.g. <code>configure --with-xcode-path=/Applications/Xcode13.1.app</code> This allows using a specific Xcode version for an OpenJDK build, independently of the active Xcode version by <code>xcode-select</code>.</li>
304+
</ul>
301305
<p>If you have recently (inadvertently) updated your OS and/or Xcode version, and the JDK can no longer be built, please see the section on <a href="#problems-with-the-build-environment">Problems with the Build Environment</a>, and <a href="#getting-help">Getting Help</a> to find out if there are any recent, non-merged patches available for this update.</p>
302306
<h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
303-
<p>For aarch64 machines running Windows the minimum accepted version is Visual Studio 2019 (16.8 or higher). For all other platforms the minimum accepted version of Visual Studio is 2017. Older versions will not be accepted by <code>configure</code> and will not work. For all platforms the maximum accepted version of Visual Studio is 2019.</p>
307+
<p>The minimum accepted version of Visual Studio is 2017. Older versions will not be accepted by <code>configure</code> and will not work. The maximum accepted version of Visual Studio is 2019.</p>
304308
<p>If you have multiple versions of Visual Studio installed, <code>configure</code> will by default pick the latest. You can request a specific version to be used by setting <code>--with-toolchain-version</code>, e.g. <code>--with-toolchain-version=2017</code>.</p>
305309
<p>If you have Visual Studio installed but <code>configure</code> fails to detect it, it may be because of <a href="#spaces-in-path">spaces in path</a>.</p>
306310
<h3 id="ibm-xl-cc">IBM XL C/C++</h3>

doc/building.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,12 @@ be able to run on the target platform. In theory, toolchain and operating
305305
system should be independent factors, but in practice there's more or less a
306306
one-to-one correlation between target operating system and toolchain.
307307

308-
Operating system Supported toolchain
309-
------------------ -------------------------
310-
Linux gcc, clang
311-
macOS Apple Xcode (using clang)
312-
AIX IBM XL C/C++
313-
Windows Microsoft Visual Studio
308+
| Operating system | Supported toolchain |
309+
| ------------------ | ------------------------- |
310+
| Linux | gcc, clang |
311+
| macOS | Apple Xcode (using clang) |
312+
| AIX | IBM XL C/C++ |
313+
| Windows | Microsoft Visual Studio |
314314

315315
Please see the individual sections on the toolchains for version
316316
recommendations. As a reference, these versions of the toolchains are used, at
@@ -319,11 +319,11 @@ possible to compile the JDK with both older and newer versions, but the closer
319319
you stay to this list, the more likely you are to compile successfully without
320320
issues.
321321

322-
Operating system Toolchain version
323-
------------------ -------------------------------------------------------
324-
Linux gcc 10.2.0
325-
macOS Apple Xcode 10.1 (using clang 10.0.0)
326-
Windows Microsoft Visual Studio 2022 update 17.1.0
322+
| Operating system | Toolchain version |
323+
| ------------------ | ------------------------------------------ |
324+
| Linux | gcc 10.2.0 |
325+
| macOS | Apple Xcode 10.1 (using clang 10.0.0) |
326+
| Windows | Microsoft Visual Studio 2022 update 17.1.0 |
327327

328328
All compilers are expected to be able to compile to the C99 language standard,
329329
as some C99 features are used in the source code. Microsoft Visual Studio
@@ -351,20 +351,20 @@ To use clang instead of gcc on Linux, use `--with-toolchain-type=clang`.
351351

352352
The oldest supported version of Xcode is 8.
353353

354-
You will need the Xcode command lines developers tools to be able to build
355-
the JDK. (Actually, *only* the command lines tools are needed, not the IDE.)
354+
You will need the Xcode command line developer tools to be able to build
355+
the JDK. (Actually, *only* the command line tools are needed, not the IDE.)
356356
The simplest way to install these is to run:
357357
```
358358
xcode-select --install
359359
```
360360

361-
It is advisable to keep an older version of Xcode for building the JDK when
362-
updating Xcode. This [blog page](
363-
http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html) has
364-
good suggestions on managing multiple Xcode versions. To use a specific version
365-
of Xcode, use `xcode-select -s` before running `configure`, or use
366-
`--with-toolchain-path` to point to the version of Xcode to use, e.g.
367-
`configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin`
361+
When updating Xcode, it is advisable to keep an older version for building the JDK.
362+
To use a specific version of Xcode you have multiple options:
363+
364+
* Use `xcode-select -s` before running `configure`, e.g. `xcode-select -s /Applications/Xcode13.1.app`. The drawback is that the setting
365+
is system wide and you may have to revert it after an OpenJDK build.
366+
* Use configure option `--with-xcode-path`, e.g. `configure --with-xcode-path=/Applications/Xcode13.1.app`
367+
This allows using a specific Xcode version for an OpenJDK build, independently of the active Xcode version by `xcode-select`.
368368

369369
If you have recently (inadvertently) updated your OS and/or Xcode version, and
370370
the JDK can no longer be built, please see the section on [Problems with the

make/autoconf/basic.m4

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,18 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
212212
[UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_toolchain_path)]
213213
)
214214
215+
AC_ARG_WITH([xcode-path], [AS_HELP_STRING([--with-xcode-path],
216+
[set up toolchain on Mac OS using a path to an Xcode installation])])
217+
218+
if test "x$with_xcode_path" != x; then
219+
if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
220+
UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],
221+
$with_xcode_path/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$with_xcode_path/Contents/Developer/usr/bin)
222+
else
223+
AC_MSG_WARN([Option --with-xcode-path is only valid on Mac OS, ignoring.])
224+
fi
225+
fi
226+
215227
AC_ARG_WITH([extra-path], [AS_HELP_STRING([--with-extra-path],
216228
[prepend these directories to the default path])],
217229
[UTIL_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)]
@@ -222,7 +234,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
222234
# If not, detect if Xcode is installed by running xcodebuild -version
223235
# if no Xcode installed, xcodebuild exits with 1
224236
# if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
225-
if test "x$DEVKIT_ROOT" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then
237+
if test "x$DEVKIT_ROOT" != x || test "x$TOOLCHAIN_PATH" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then
226238
# We need to use xcodebuild in the toolchain dir provided by the user
227239
UTIL_LOOKUP_PROGS(XCODEBUILD, xcodebuild, $TOOLCHAIN_PATH)
228240
if test x$XCODEBUILD = x; then

0 commit comments

Comments
 (0)