Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit 7275da4

Browse files
committed
8296904: Improve handling of macos xcode toolchain
Reviewed-by: mbaesken Backport-of: 470f3424fcce0e41b75cccdd5e3a56771cd07ff5
1 parent d153a8c commit 7275da4

File tree

3 files changed

+69
-44
lines changed

3 files changed

+69
-44
lines changed

doc/building.html

Lines changed: 24 additions & 20 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 11.2.0</td>
275+
<td>Linux</td>
276+
<td>gcc 11.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,9 +295,13 @@ <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>
303307
<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 2022.</p>

doc/building.md

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

316-
Operating system Supported toolchain
317-
------------------ -------------------------
318-
Linux gcc, clang
319-
macOS Apple Xcode (using clang)
320-
AIX IBM XL C/C++
321-
Windows Microsoft Visual Studio
316+
| Operating system | Supported toolchain |
317+
| ------------------ | ------------------------- |
318+
| Linux | gcc, clang |
319+
| macOS | Apple Xcode (using clang) |
320+
| AIX | IBM XL C/C++ |
321+
| Windows | Microsoft Visual Studio |
322322

323323
Please see the individual sections on the toolchains for version
324324
recommendations. As a reference, these versions of the toolchains are used, at
@@ -327,11 +327,11 @@ possible to compile the JDK with both older and newer versions, but the closer
327327
you stay to this list, the more likely you are to compile successfully without
328328
issues.
329329

330-
Operating system Toolchain version
331-
------------------ -------------------------------------------------------
332-
Linux gcc 11.2.0
333-
macOS Apple Xcode 10.1 (using clang 10.0.0)
334-
Windows Microsoft Visual Studio 2022 update 17.1.0
330+
| Operating system | Toolchain version |
331+
| ------------------ | ------------------------------------------ |
332+
| Linux | gcc 11.2.0 |
333+
| macOS | Apple Xcode 10.1 (using clang 10.0.0) |
334+
| Windows | Microsoft Visual Studio 2022 update 17.1.0 |
335335

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

360360
The oldest supported version of Xcode is 8.
361361

362-
You will need the Xcode command lines developers tools to be able to build
363-
the JDK. (Actually, *only* the command lines tools are needed, not the IDE.)
362+
You will need the Xcode command line developer tools to be able to build
363+
the JDK. (Actually, *only* the command line tools are needed, not the IDE.)
364364
The simplest way to install these is to run:
365365
```
366366
xcode-select --install
367367
```
368368

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

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

make/autoconf/basic.m4

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ AC_DEFUN([BASIC_SETUP_XCODE_SYSROOT],
139139
if test $? -ne 0; then
140140
AC_MSG_ERROR([The xcodebuild tool in the devkit reports an error: $XCODEBUILD_OUTPUT])
141141
fi
142+
elif test "x$TOOLCHAIN_PATH" != x; then
143+
UTIL_LOOKUP_PROGS(XCODEBUILD, xcodebuild, $TOOLCHAIN_PATH)
144+
if test "x$XCODEBUILD" != x; then
145+
XCODEBUILD_OUTPUT=`"$XCODEBUILD" -version 2>&1`
146+
if test $? -ne 0; then
147+
AC_MSG_WARN([Ignoring the located xcodebuild tool $XCODEBUILD due to an error: $XCODEBUILD_OUTPUT])
148+
XCODEBUILD=
149+
fi
150+
fi
142151
else
143152
UTIL_LOOKUP_PROGS(XCODEBUILD, xcodebuild)
144153
if test "x$XCODEBUILD" != x; then
@@ -288,6 +297,22 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
288297
[UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_toolchain_path)]
289298
)
290299
300+
AC_ARG_WITH([xcode-path], [AS_HELP_STRING([--with-xcode-path],
301+
[set up toolchain on Mac OS using a path to an Xcode installation])])
302+
303+
if test "x$with_xcode_path" != x; then
304+
if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
305+
UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],
306+
$with_xcode_path/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$with_xcode_path/Contents/Developer/usr/bin)
307+
else
308+
AC_MSG_WARN([Option --with-xcode-path is only valid on Mac OS, ignoring.])
309+
fi
310+
fi
311+
312+
AC_MSG_CHECKING([for toolchain path])
313+
AC_MSG_RESULT([$TOOLCHAIN_PATH])
314+
AC_SUBST(TOOLCHAIN_PATH)
315+
291316
AC_ARG_WITH([extra-path], [AS_HELP_STRING([--with-extra-path],
292317
[prepend these directories to the default path])],
293318
[UTIL_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)]
@@ -304,10 +329,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
304329
AC_MSG_RESULT([$SYSROOT])
305330
AC_SUBST(SYSROOT)
306331
307-
AC_MSG_CHECKING([for toolchain path])
308-
AC_MSG_RESULT([$TOOLCHAIN_PATH])
309-
AC_SUBST(TOOLCHAIN_PATH)
310-
311332
AC_MSG_CHECKING([for extra path])
312333
AC_MSG_RESULT([$EXTRA_PATH])
313334
])

0 commit comments

Comments
 (0)