Opened 10 hours ago

Last modified 4 hours ago

#71049 assigned defect

openjdk21 @21.0.4+7: error: use of undeclared identifier 'NSBundleExecutableArchitectureARM64' on 10.14 and 10.15 — at Version 2

Reported by: sambthompson (Sam Thompson) Owned by: breun (Nils Breunese)
Priority: Normal Milestone:
Component: ports Version: 2.10.2
Keywords: catalina mojave Cc:
Port: openjdk21

Description (last modified by sambthompson (Sam Thompson))

See: https://build.macports.org/builders/ports-10.15_x86_64-builder/builds/196610/steps/install-port/logs/stdio

:info:build src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m:69:29: error: use of undeclared identifier 'NSBundleExecutableArchitectureARM64'; did you mean 'NSBundleExecutableArchitecturePPC64'?
:info:build         if (architecture == NSBundleExecutableArchitectureARM64) {
:info:build                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:info:build                             NSBundleExecutableArchitecturePPC64
:info:build /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:123:5: note: 'NSBundleExecutableArchitecturePPC64' declared here
:info:build     NSBundleExecutableArchitecturePPC64     = 0x01000012
:info:build     ^
:info:build 1 error generated.

It's unclear whether this is an upstream issue; the failing code in question is not tagged upstream for openjdk21, but is delivered in the tarball anyway. Upstream still claims to support from 10.12 for openjdk21. EDIT: Was backported.

However, I don't think it should not fail in any case (and clearly other builds of openjdk21 e.g. from IBM, Azul, etc. are successful/usable on 10.15 and 10.14), because the fragment in question is guarded with Objective C pragma @available, viz. EDIT: Wrong again, doesn't work like #ifdef.

static BOOL isValidDisplayMode(CGDisplayModeRef mode) {
    // Workaround for apple bug FB13261205, since it only affects arm based macs
    // and arm support started with macOS 11 ignore the workaround for previous versions
    if (@available(macOS 11, *)) {
        if (architecture == -1) {
            architecture = [[NSRunningApplication currentApplication] executableArchitecture];
        }
        if (architecture == NSBundleExecutableArchitectureARM64) {
            return (CGDisplayModeGetPixelWidth(mode) >= 800);
        }
    }
    return (1 < CGDisplayModeGetWidth(mode) && 1 < CGDisplayModeGetHeight(mode));
}

However, it's not clear why this is not being honoured on builds on 10.14 and 10.15. I have to assume there is compiler support for this @available syntax (apparently since Xcode 9 / LLVM 5), since that does not generate an error.

Change History (2)

comment:1 Changed 9 hours ago by sambthompson (Sam Thompson)

This fix was backported to openjdk21 on March 11, so earlier comment about shipping in error was in error.

According to this thread, @available still needs the symbols defined in the SDK. Sigh.

The orginal upstream report that resulted in this change is: JDK-8266242. The back-porting process apparently didn't pick up the issue with building using older Xcodes on 10.12 - 10.15, without later SDKs defining this enum. I also note that this code appears to be only use of @availability in the whole source.

comment:2 Changed 9 hours ago by sambthompson (Sam Thompson)

Description: modified (diff)
Note: See TracTickets for help on using tickets.