简体   繁体   中英

How to compile OpenJDK 11 on macOS?

When I make, with:

Configuration summary:

  • Debug level: fastdebug
  • HS debug level: fastdebug
  • JVM variants: server
  • JVM features: server: 'aot cds cmsgc compiler1 compiler2 dtrace epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services vm-structs'
  • OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64
  • Version string: 11.0.16-internal+0-adhoc.sadman.jdk11u-dev-master (11.0.16-internal)

Tools summary:

  • Boot JDK: openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode) (at /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home)
  • Toolchain: clang (clang/LLVM from Xcode 13.4)
  • C Compiler: Version 13.1.6 (at /usr/bin/clang)
  • C++ Compiler: Version 13.1.6 (at /usr/bin/clang++)

Build performance summary:

  • Cores to use: 12
  • Memory limit: 16384 MB

And it remind me that

jdk11u-dev-master/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp:59:30: error: too many arguments provided to function-like macro invocation assert(interfaces,= NULL; "invariant");

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/assert.h:98:9: note: macro 'assert' defined here #define assert(e) \

Which means the source codes of jdk use two arguments assert, but my Mac just support one argument assert.

在 macos monterey 上编译 openjdk11 是成功的

In ./test/hotspot/gtest/unittest.hpp in the jdk11u source there is this comment and redefinition of assert :

// gtest/gtest.h includes assert.h which will define the assert macro, but hotspot has its
// own standards incompatible assert macro that takes two parameters.
// The workaround is to undef assert and then re-define it. The re-definition
// must unfortunately be copied since debug.hpp might already have been
// included and a second include wouldn't work due to the header guards in debug.hpp.
#ifdef assert
  #undef assert
  #ifdef vmassert
    #define assert(p, ...) vmassert(p, __VA_ARGS__)
  #endif
#endif

Somehow this has been broken for test/hotspot/gtest/jfr/test_networkUtilization.cpp ... it appears to be that assert is getting redefined in one of the includes after unittest.hpp .

You can fix the compile by moving the #include of unittest.hpp down a bit, see this diff:

--- a/test/hotspot/gtest/jfr/test_networkUtilization.cpp
+++ b/test/hotspot/gtest/jfr/test_networkUtilization.cpp
@@ -42,12 +42,12 @@
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/growableArray.hpp"
 
-#include "unittest.hpp"
-
 #include <vector>
 #include <list>
 #include <map>
 
+#include "unittest.hpp"
+
 namespace {
 
   class MockFastUnorderedElapsedCounterSource : public ::FastUnorderedElapsedCounterSource {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM