Skip to content

Commit

Permalink
8296904: Improve handling of macos xcode toolchain
Browse files Browse the repository at this point in the history
Reviewed-by: mbaesken
Backport-of: 470f3424fcce0e41b75cccdd5e3a56771cd07ff5
  • Loading branch information
RealCLanger committed Dec 9, 2022
1 parent 0f43f8e commit 57e6d92
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 42 deletions.
46 changes: 25 additions & 21 deletions doc/building.html
Expand Up @@ -239,49 +239,49 @@ <h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requ
<table>
<thead>
<tr class="header">
<th style="text-align: left;">Operating system</th>
<th style="text-align: left;">Supported toolchain</th>
<th>Operating system</th>
<th>Supported toolchain</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Linux</td>
<td style="text-align: left;">gcc, clang</td>
<td>Linux</td>
<td>gcc, clang</td>
</tr>
<tr class="even">
<td style="text-align: left;">macOS</td>
<td style="text-align: left;">Apple Xcode (using clang)</td>
<td>macOS</td>
<td>Apple Xcode (using clang)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">AIX</td>
<td style="text-align: left;">IBM XL C/C++</td>
<td>AIX</td>
<td>IBM XL C/C++</td>
</tr>
<tr class="even">
<td style="text-align: left;">Windows</td>
<td style="text-align: left;">Microsoft Visual Studio</td>
<td>Windows</td>
<td>Microsoft Visual Studio</td>
</tr>
</tbody>
</table>
<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>
<table>
<thead>
<tr class="header">
<th style="text-align: left;">Operating system</th>
<th style="text-align: left;">Toolchain version</th>
<th>Operating system</th>
<th>Toolchain version</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Linux</td>
<td style="text-align: left;">gcc 10.2.0</td>
<td>Linux</td>
<td>gcc 10.2.0</td>
</tr>
<tr class="even">
<td style="text-align: left;">macOS</td>
<td style="text-align: left;">Apple Xcode 10.1 (using clang 10.0.0)</td>
<td>macOS</td>
<td>Apple Xcode 10.1 (using clang 10.0.0)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Windows</td>
<td style="text-align: left;">Microsoft Visual Studio 2022 update 17.1.0</td>
<td>Windows</td>
<td>Microsoft Visual Studio 2022 update 17.1.0</td>
</tr>
</tbody>
</table>
Expand All @@ -295,12 +295,16 @@ <h3 id="clang">clang</h3>
<p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
<h3 id="apple-xcode">Apple Xcode</h3>
<p>The oldest supported version of Xcode is 8.</p>
<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>
<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>
<pre><code>xcode-select --install</code></pre>
<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>
<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>
<ul>
<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>
<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>
</ul>
<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>
<h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
<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>
<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>
<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>
<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>
<h3 id="ibm-xl-cc">IBM XL C/C++</h3>
Expand Down
40 changes: 20 additions & 20 deletions doc/building.md
Expand Up @@ -305,12 +305,12 @@ be able to run on the target platform. In theory, toolchain and operating
system should be independent factors, but in practice there's more or less a
one-to-one correlation between target operating system and toolchain.

Operating system Supported toolchain
------------------ -------------------------
Linux gcc, clang
macOS Apple Xcode (using clang)
AIX IBM XL C/C++
Windows Microsoft Visual Studio
| Operating system | Supported toolchain |
| ------------------ | ------------------------- |
| Linux | gcc, clang |
| macOS | Apple Xcode (using clang) |
| AIX | IBM XL C/C++ |
| Windows | Microsoft Visual Studio |

Please see the individual sections on the toolchains for version
recommendations. As a reference, these versions of the toolchains are used, at
Expand All @@ -319,11 +319,11 @@ 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.

Operating system Toolchain version
------------------ -------------------------------------------------------
Linux gcc 10.2.0
macOS Apple Xcode 10.1 (using clang 10.0.0)
Windows Microsoft Visual Studio 2022 update 17.1.0
| Operating system | Toolchain version |
| ------------------ | ------------------------------------------ |
| Linux | gcc 10.2.0 |
| macOS | Apple Xcode 10.1 (using clang 10.0.0) |
| Windows | Microsoft Visual Studio 2022 update 17.1.0 |

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

The oldest supported version of Xcode is 8.

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

It is advisable to keep an older version of Xcode for building the JDK when
updating Xcode. This [blog page](
http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html) has
good suggestions on managing multiple Xcode versions. To use a specific version
of Xcode, use `xcode-select -s` before running `configure`, or use
`--with-toolchain-path` to point to the version of Xcode to use, e.g.
`configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin`
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:

* Use `xcode-select -s` before running `configure`, e.g. `xcode-select -s /Applications/Xcode13.1.app`. The drawback is that the setting
is system wide and you may have to revert it after an OpenJDK build.
* Use configure option `--with-xcode-path`, e.g. `configure --with-xcode-path=/Applications/Xcode13.1.app`
This allows using a specific Xcode version for an OpenJDK build, independently of the active Xcode version by `xcode-select`.

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 [Problems with the
Expand Down
14 changes: 13 additions & 1 deletion make/autoconf/basic.m4
Expand Up @@ -212,6 +212,18 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
[UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_toolchain_path)]
)
AC_ARG_WITH([xcode-path], [AS_HELP_STRING([--with-xcode-path],
[set up toolchain on Mac OS using a path to an Xcode installation])])
if test "x$with_xcode_path" != x; then
if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],
$with_xcode_path/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$with_xcode_path/Contents/Developer/usr/bin)
else
AC_MSG_WARN([Option --with-xcode-path is only valid on Mac OS, ignoring.])
fi
fi
AC_ARG_WITH([extra-path], [AS_HELP_STRING([--with-extra-path],
[prepend these directories to the default path])],
[UTIL_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)]
Expand All @@ -222,7 +234,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
# If not, detect if Xcode is installed by running xcodebuild -version
# if no Xcode installed, xcodebuild exits with 1
# if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
if test "x$DEVKIT_ROOT" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then
if test "x$DEVKIT_ROOT" != x || test "x$TOOLCHAIN_PATH" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then
# We need to use xcodebuild in the toolchain dir provided by the user
UTIL_LOOKUP_PROGS(XCODEBUILD, xcodebuild, $TOOLCHAIN_PATH)
if test x$XCODEBUILD = x; then
Expand Down

3 comments on commit 57e6d92

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RealCLanger
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 57e6d92 Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RealCLanger Could not automatically backport 57e6d92a to openjdk/jdk11u-dev due to conflicts in the following files:

  • doc/building.html
  • doc/building.md

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk11u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk11u-dev master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b RealCLanger-backport-57e6d92a

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev 57e6d92a6ddbfe78cbf250a4502ce0911ee6f75a

# Backport the commit
$ git cherry-pick --no-commit 57e6d92a6ddbfe78cbf250a4502ce0911ee6f75a
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 57e6d92a6ddbfe78cbf250a4502ce0911ee6f75a'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 57e6d92a6ddbfe78cbf250a4502ce0911ee6f75a.

Please sign in to comment.