【问题标题】:How to compile OpenJDK 11 on macOS?如何在 macOS 上编译 OpenJDK 11?
【发布时间】:2022-09-24 06:43:37
【问题描述】:

当我制作时,使用:

配置总结:

  • 调试级别:fastdebug
  • HS 调试级别:fastdebug
  • JVM 变体:服务器
  • JVM 特性:服务器:\'aot cds cmsgc compiler1 compiler2 dtrace epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services vm-structs\'
  • OpenJDK 目标:操作系统:macosx,CPU 架构:x86,地址长度:64
  • 版本字符串:11.0.16-internal+0-adhoc.sadman.jdk11u-dev-master (11.0.16-internal)

工具总结:

  • 启动JDK:openjdk版本\"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,混合模式) (在 /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home)
  • 工具链:clang(来自 Xcode 13.4 的 clang/LLVM)
  • C 编译器:版本 13.1.6(位于 /usr/bin/clang)
  • C++ 编译器:版本 13.1.6(位于 /usr/bin/clang++)

构建性能总结:

  • 要使用的核心数:12
  • 内存限制:16384 MB

它提醒我

jdk11u-dev-master/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp:59:30:错误:提供给类函数宏调用的参数过多 断言(接口!= NULL,\“不变\”);

/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) \\

这意味着jdk的源代码使用两个参数断言,但我的Mac只支持一个参数断言。

    标签: java c++ compiler-errors java-11


    【解决方案1】:

    在 jdk11u 源代码的 ./test/hotspot/gtest/unittest.hpp 中有这样的注释和对 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
    

    不知何故,test/hotspot/gtest/jfr/test_networkUtilization.cpp 已被打破...看来assert 在其中一个包含中被重新定义unittest.hpp

    您可以通过将unittest.hpp#include 向下移动一点来修复编译,请参阅以下差异:

    --- 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 {
    

    【讨论】:

      【解决方案2】:

      在 macos monterey 上编译 openjdk 11 是成功的

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
      • 你能给我一些关于我的问题的建议吗
      猜你喜欢
      • 2021-09-22
      • 1970-01-01
      • 1970-01-01
      • 2019-06-06
      • 2019-03-01
      • 2020-01-20
      • 1970-01-01
      • 2019-05-11
      • 2019-06-21
      相关资源
      最近更新 更多