Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355682

Compiler warnings in PLATFORM_API_MacOSX_Ports.cpp causing build failure on macos with XCode 16.3

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 17, 21, 24, 25
    • client-libs

      A couple of users have reported that when building the JDK on macos with XCode 16.3, the build generates compiler warnings which causes the JDK build to fail. The warnings are listed at the end of this issue.

      Workarounds exist to get past these warnings and build the JDK successfully. Using a lower versioned XCode (for example 15.4) details here https://github.com/openjdk/jdk/blob/master/doc/building.md#apple-xcode or configuring the JDK build to use "--disable-warnings-as-errors" option (details here https://github.com/openjdk/jdk/blob/master/doc/building.md#problems-with-the-build-environment) are known to help get past this issue.

      Warnings generated during the build are as follows:

      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:127:39: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
      127 | AudioDeviceID devices[count];
      | ^~~~~
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:127:39: note: read of non-const variable 'count' is not allowed in a constant expression
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:126:21: note: declared here
      126 | int count = size/sizeof(AudioDeviceID);
      | ^
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:151:42: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
      151 | AudioObjectID controlIDs[count];
      | ^~~~~
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:151:42: note: read of non-const variable 'count' is not allowed in a constant expression
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:150:21: note: declared here
      150 | int count = size / sizeof(AudioObjectID);
      | ^
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:483:38: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
      483 | AudioObjectID controlIDs[mixer->deviceControlCount];
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:483:38: note: read of non-constexpr variable 'mixer' is not allowed in a constant expression
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:458:16: note: declared here
      458 | PortMixer *mixer = (PortMixer *)id;
      | ^
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:527:34: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
      527 | AudioControl* volumeControls[totalChannels+1]; // 0 - for master channel
      | ^~~~~~~~~~~~~~~
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:527:34: note: read of non-const variable 'totalChannels' is not allowed in a constant expression
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:524:9: note: declared here
      524 | int totalChannels = GetChannelCount(mixer->deviceID, port->scope == kAudioDevicePropertyScopeOutput ? 1 : 0);
      | ^
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:529:32: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
      529 | AudioControl* muteControls[totalChannels+1]; // 0 - for master channel
      | ^~~~~~~~~~~~~~~
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:529:32: note: read of non-const variable 'totalChannels' is not allowed in a constant expression
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:524:9: note: declared here
      524 | int totalChannels = GetChannelCount(mixer->deviceID, port->scope == kAudioDevicePropertyScopeOutput ? 1 : 0);
      | ^
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:775:24: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
      775 | Float32 subVolumes[control->controlCount];
      | ^~~~~~~~~~~~~~~~~~~~~
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:775:24: note: read of non-constexpr variable 'control' is not allowed in a constant expression
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:772:18: note: declared here
      772 | PortControl *control = (PortControl *)controlIDV;
      | ^
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:824:24: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
      824 | Float32 subVolumes[control->controlCount];
      | ^~~~~~~~~~~~~~~~~~~~~
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:824:24: note: read of non-constexpr variable 'control' is not allowed in a constant expression
      src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_Ports.cpp:818:18: note: declared here
      818 | PortControl *control = (PortControl *)controlIDV;
      | ^
      7 errors generated.
      make[3]: *** [build/macosx-aarch64-server-release/support/native/java.desktop/libjsound/PLATFORM_API_MacOSX_Ports.o] Error 1


            kizune Alexander Zuev
            jpai Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: