Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on M3: ld: symbol(s) not found for architecture arm64 #19475

Open
theresa-m opened this issue May 9, 2024 · 4 comments
Open

Build failure on M3: ld: symbol(s) not found for architecture arm64 #19475

theresa-m opened this issue May 9, 2024 · 4 comments

Comments

@theresa-m
Copy link
Contributor

Java -version output

Attempting to build Java 21

Summary of problem

Build failure on Mac using Sonoma 14.4.1, Xcode 15.3, Apple clang version 15.0.0 (clang-1500.3.9.4) using configuration:
bash configure --with-boot-jdk=<bootjdk> --disable-ddr --disable-warnings-as-errors --with-noncompressedrefs

This failure so far has only been reproduced on an M3 chip. I compared my setup on M1 with the user and that is the only difference in setup so far that I have been able to identify.

The build failure is:

ld: load command #14 string extends beyond end of load command in '/Users/satya/openj9-openjdk-jdk21/build/macosx-aarch64-server-release/support/modules_libs/java.base/libjava.dylib'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [/Users/satya/openj9-openjdk-jdk21/build/macosx-aarch64-server-release/support/modules_libs/java.base/libzip.dylib] Error 1
make[2]: *** [java.base-libs] Error 2

The release notes for Xcode 15 show that a new linker is being used. The user tried adding --with-extra-ldflags='-ld_classic -Wl' to the configuration to use the old linker resulting in the error:

ld: warning: ignoring file /Users/satya/openj9-openjdk-jdk21/build/macosx-aarch64-server-release/support/modules_libs/java.base/libjava.dylib, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0xCE 0xFA 0xED 0xFE 0x0C 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x06 0x00 0x00 0x00 )
Undefined symbols for architecture arm64:
  "_JNU_ThrowByName", referenced from:
      _checkInflateStatus in Inflater.o
  "_JNU_ThrowIllegalArgumentException", referenced from:
      _Java_java_util_zip_Deflater_init in Deflater.o
      _Java_java_util_zip_Deflater_setDictionary in Deflater.o
      _Java_java_util_zip_Deflater_setDictionaryBuffer in Deflater.o
      _Java_java_util_zip_Inflater_setDictionary in Inflater.o
      _Java_java_util_zip_Inflater_setDictionaryBuffer in Inflater.o
  "_JNU_ThrowInternalError", referenced from:
      _Java_java_util_zip_Deflater_init in Deflater.o
      _Java_java_util_zip_Deflater_setDictionary in Deflater.o
      _Java_java_util_zip_Deflater_setDictionaryBuffer in Deflater.o
      _Java_java_util_zip_Deflater_deflateBytesBytes in Deflater.o
      _Java_java_util_zip_Deflater_deflateBytesBuffer in Deflater.o
      _Java_java_util_zip_Deflater_deflateBufferBytes in Deflater.o
      _Java_java_util_zip_Deflater_deflateBufferBuffer in Deflater.o
      ...
  "_JNU_ThrowOutOfMemoryError", referenced from:
      _Java_java_util_zip_Deflater_init in Deflater.o
      _Java_java_util_zip_Deflater_deflateBytesBytes in Deflater.o
      _Java_java_util_zip_Deflater_deflateBytesBuffer in Deflater.o
      _Java_java_util_zip_Deflater_deflateBufferBytes in Deflater.o
      _Java_java_util_zip_Inflater_init in Inflater.o
      _Java_java_util_zip_Inflater_inflateBytesBytes in Inflater.o
      _checkInflateStatus in Inflater.o
      ...
  "_getErrorString", referenced from:
      _ZIP_ReadEntry in zip_util.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [/Users/satya/openj9-openjdk-jdk21/build/macosx-aarch64-server-release/support/modules_libs/java.base/libzip.dylib] Error 1
make[2]: *** [java.base-libs] Error 2

Suggestions for what to try next are appreciated!

@theresa-m
Copy link
Contributor Author

@dylanjtuttle confirmed that he is experiencing the same failure on his m3. Thanks Dylan!

@knn-k
Copy link
Contributor

knn-k commented May 16, 2024

Could you share the binary build/macosx-aarch64-server-release/support/modules_libs/java.base/libjava.dylib, please?
I am going take a look into it.

@theresa-m
Copy link
Contributor Author

Thanks @knn-k this is the file I received from the user.
libjava.dylib.zip

@knn-k
Copy link
Contributor

knn-k commented May 17, 2024

I am not sure if this is the reason of the failure, but I see a garbage ^] in the Load command 13 of the otool output:

% otool -lv libjava.dylib | less
...
Load command 12
          cmd LC_LOAD_DYLIB
      cmdsize 52
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 09:00:02 1970
      current version 1345.100.2
compatibility version 1.0.0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libobjc.A.dylib^] (offset 24) <-- HERE
   time stamp 2 Thu Jan  1 09:00:02 1970
      current version 228.0.0
compatibility version 1.0.0
Load command 14
      cmd LC_CODE_SIGNATURE
  cmdsize 16
  dataoff 130704
 datasize 20896

I don't see the garbage in the otool output for libjava.dylib from ibm-semeru-open-jdk_aarch64_mac_21.0.2_13_openj9-0.43.0.tar.gz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants