gluonhq / gluonfx-maven-plugin

Plugin that simplifies creating native images for Java/JavaFX maven projects
BSD 3-Clause "New" or "Revised" License
186 stars 38 forks source link

JavaFX static SDK 21 linker command failed on macOS 13.6 (22G120) Apple Silicon #491

Open cavoirom opened 9 months ago

cavoirom commented 9 months ago

I'm facing this error when building native image on macOS 13.6 (Apple Silicon)

[Thu Oct 05 23:35:25 ICT 2023][FINE] Start process link...
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] ld: warning: no platform load command found in '<redacted>/target/gluonfx/aarch64-darwin/gvm/tmp/SVM-1696523641365/com.cavoirom.quick_api.quickapi.o', assuming: macOS
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] ld: warning: object file (<redacted>/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/svm/clibraries/darwin-aarch64/libjvm.a[2](JvmFuncs.o)) was built for newer 'macOS' version (12.0) than being linked (11.0)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] ld: warning: object file (<redacted>/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/svm/clibraries/darwin-aarch64/libjvm.a[3](JvmFuncsFallbacks.o)) was built for newer 'macOS' version (12.0) than being linked (11.0)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] ld: warning: object file (<redacted>/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/svm/clibraries/darwin-aarch64/liblibchelper.a[4](cpuid.o)) was built for newer 'macOS' version (12.0) than being linked (11.0)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] ld: warning: object file (<redacted>/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/svm/clibraries/darwin-aarch64/liblibchelper.a[5](timeZone.o)) was built for newer 'macOS' version (12.0) than being linked (11.0)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] ld: warning: object file (<redacted>/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/svm/clibraries/darwin-aarch64/libdarwin.a[2](foundation.o)) was built for newer 'macOS' version (12.0) than being linked (11.0)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] ld: Undefined symbols:
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]   _LMGetKbdType, referenced from:
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]       _getJavaCodeForMacKeyAndModifiers in libglass.a[14](GlassKey.obj)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]   _TISCopyCurrentKeyboardLayoutInputSource, referenced from:
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]       _getJavaCodeForMacKey in libglass.a[14](GlassKey.obj)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]   _TISGetInputSourceProperty, referenced from:
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]       _getJavaCodeForMacKeyAndModifiers in libglass.a[14](GlassKey.obj)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]   _kTISPropertyUnicodeKeyLayoutData, referenced from:
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB]       _getJavaCodeForMacKeyAndModifiers in libglass.a[14](GlassKey.obj)
[Thu Oct 05 23:35:25 ICT 2023][INFO] [SUB] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Thu Oct 05 23:35:25 ICT 2023][FINE] Result for link: 1
[Thu Oct 05 23:35:25 ICT 2023][SEVERE] Process link failed with result: 1

My settings

Build with GraalVM on: https://github.com/gluonhq/graal/releases

If I change the javafxStaticSdkVersion to 21-ea+9.1, the build will success.

Expected behavior: native image will be build successfully.

jperedadnr commented 9 months ago

Those symbols come from the PR that added this commit, that was merged right before JavaFX 21 GA.

I'm running on macOS 13.4.1, and I can link just fine. I wonder what could have changed in 13.6.

Can you run and post the result of

nm target/gluonfx/aarch64-darwin/gvm/tmp/SVM-***/com.gluonhq.hello.hellogluon.o | grep _LMGetKbdType
cavoirom commented 9 months ago

Instead of running against hellogluon I ran the above command on my binary:

nm target/gluonfx/aarch64-darwin/gvm/tmp/SVM-1696523641365/***ickapi.o | grep _LMGetKbdType

No output.

There are nothing special in the dependencies:

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>${javafx.version}</version>
    </dependency>
    <dependency>
      <groupId>io.reactivex.rxjava3</groupId>
      <artifactId>rxjava</artifactId>
      <version>${rxjava.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents.core5</groupId>
      <artifactId>httpcore5</artifactId>
      <version>${httpcore5.version}</version>
    </dependency>
cavoirom commented 6 months ago

For those who is facing the same issue. Here is what I found on StackOverflow: https://stackoverflow.com/q/77512693

Summary: We need to link Carbon.

Here is my configuration in the gluonfx-maven-plugin.

<configuration>
  ...
  <linkerArgs>
    <!-- Workaround linker command failed on macOS Sonoma, details: https://stackoverflow.com/q/77512693 -->
    <linkerArg>-Wl</linkerArg>
    <linkerArg>-framework</linkerArg>
    <linkerArg>Carbon</linkerArg>
  </linkerArgs>
  ...
</configuration>