Skip to content

Pseudo-cross compiles on macOS fail - perhaps due to not passing the sysroot to the OpenJ9 build. #1200

@chrisdennis

Description

@chrisdennis

When attempting to build on (very) recent macOS versions you see issues related to the configured clang compiler hitting builtins introduced in the system installed Xcode:

$ bash configure --with-boot-jdk=/opt/homebrew/Cellar/openjdk/25.0.2/libexec/openjdk.jdk/Contents/Home --with-xcode-path=/Users/cdennis/xcode-15.4/Xcode.app --with-noncompressedrefs
...
====================================================
The existing configuration has been successfully updated in
/Users/cdennis/src/openj9-openjdk-jdk/build/macosx-aarch64-server-release
using configure arguments '--with-boot-jdk=/opt/homebrew/Cellar/openjdk/25.0.2/libexec/openjdk.jdk/Contents/Home --with-xcode-path=/Users/cdennis/xcode-15.4/Xcode.app --with-noncompressedrefs'.

Configuration summary:
* Name:           macosx-aarch64-server-release
* Debug level:    release
* HS debug level: product
* JVM variants:   server
* JVM features:   server: 'dtrace jfr management' 
* OpenJDK target: OS: macosx, CPU architecture: aarch64, address length: 64
* Version string: 27-internal-adhoc.cdennis.openj9-openjdk-jdk (27-internal)
* Source date:    1775073643 (2026-04-01T20:00:43Z)

Tools summary:
* Boot JDK:       openjdk version "25.0.2" 2026-01-20 OpenJDK Runtime Environment Homebrew (build 25.0.2) OpenJDK 64-Bit Server VM Homebrew (build 25.0.2, mixed mode, sharing) (at /opt/homebrew/Cellar/openjdk/25.0.2/libexec/openjdk.jdk/Contents/Home)
* Toolchain:      clang (clang/LLVM from Xcode 15.4)
* Sysroot:        /Users/cdennis/xcode-15.4/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk
* C Compiler:     Version 15.0.0 (at /Users/cdennis/xcode-15.4/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
* C++ Compiler:   Version 15.0.0 (at /Users/cdennis/xcode-15.4/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++)

Build performance summary:
* Build jobs:     12
* Memory limit:   36864 MB

WARNING: The result of this configuration has overridden an older
configuration. You *should* run 'make clean' to make sure you get a
proper build. Failure to do so might result in strange build problems.

$ make -j1 images
...
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__hash_table:166:79: note: in instantiation of function template specialization 'std::__countl_zero<unsigned long>' requested here
  return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - std::__countl_zero(__n - 1)));
                                                                              ^
In file included from /Users/cdennis/src/openj9-openjdk-jdk/omr/ddr/lib/ddr-ir/ClassUDT.cpp:22:
In file included from /Users/cdennis/src/openj9-openjdk-jdk/omr/ddr/include/ddr/ir/ClassUDT.hpp:25:
In file included from /Users/cdennis/src/openj9-openjdk-jdk/omr/ddr/include/ddr/ir/ClassType.hpp:25:
In file included from /Users/cdennis/src/openj9-openjdk-jdk/omr/ddr/include/ddr/ir/NamespaceUDT.hpp:25:
In file included from /Users/cdennis/src/openj9-openjdk-jdk/omr/ddr/include/ddr/ir/Macro.hpp:26:
In file included from /Users/cdennis/src/openj9-openjdk-jdk/omr/ddr/include/ddr/std/string.hpp:28:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:654:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:951:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/algorithm:1873:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/lexicographical_compare.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/mismatch.h:15:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/simd_utils.h:14:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__bit/countl.h:28:10: error: use of undeclared identifier '__builtin_clzg'
  return __builtin_clzg(__t, numeric_limits<_Tp>::digits);
         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/traits.h:71:27: note: in instantiation of function template specialization 'std::__countl_zero<unsigned long long>' requested here
    auto __t = (64 - std::__countl_zero(static_cast<type>(__v | 1))) * 1233 >> 12;
                          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/to_chars_integral.h:64:39: note: in instantiation of member function 'std::__itoa::__traits_base<unsigned long long>::__width' requested here
  if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
                                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/to_chars_integral.h:79:12: note: in instantiation of function template specialization 'std::__to_chars_itoa<unsigned long long>' requested here
    return __to_chars_itoa(__first, __last, static_cast<uint64_t>(__value), false_type());
           ^
5 errors generated.
make[6]: *** [runtime/omr/ddr/lib/ddr-ir/CMakeFiles/omr_ddr_ir.dir/ClassUDT.cpp.o] Error 1
make[5]: *** [runtime/omr/ddr/lib/ddr-ir/CMakeFiles/omr_ddr_ir.dir/all] Error 2
[  0%] Built target ffi
[  0%] Generating CMakeFiles/j9nls.dir/java_class_filelist
[  1%] Creating Java archive j9nls.jar
[  1%] Built target trace
[  1%] Generating CMakeFiles/j9vmcp.dir/java_class_filelist
[  1%] Creating Java archive j9vmcp.jar
[  1%] Built target j9nls
[  1%] Built target j9vmcp
[  1%] Linking CXX static library ../../../lib/libpugixml.a
[  1%] Built target pugixml
make[4]: *** [all] Error 2
make[3]: *** [build-j9] Error 2
make[2]: *** [j9vm-build] Error 2
make[2]: *** Waiting for unfinished jobs....

ERROR: Build failed for target 'images' in configuration 'macosx-aarch64-server-release' (exit code 2)

No indication of failed target found.
HELP: Try searching the build log for '] Error'.
HELP: Run 'make doctor' to diagnose build problems.

make[1]: *** [main] Error 2
make: *** [images] Error 2

You can see in the build failure that it's using my system Xcode rather than the configured 15.4: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

From what I can see it looks like the OpenJ9 portions of the build system may have always been using the system Xcode and it's only the very latest versions which are causing any issues here. I have prototyped a fix which solves this issue for me but is likely not good enough for merging, but should serve to illustrate the problem - I'll create a draft PR containing it shortly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions