Skip to content

Java: Support Apple Silicon/M1 machines #7720

Closed

Description

@jurmous

When I run an application on an Apple Silicon based JVM depending on the RocksDB JVM library it fails with UnsatisfiedLinkError.

Expected behavior

Maven dependency includes Mac Arm64 compilation

Actual behavior

Maven dependency does not include Mac Arm64 compilation

Steps to reproduce the behavior

Run RocksDB inside a Apple Silicon JVM application. UnsatisfiedLinkError is thrown.

Depends on #7710

Note: RocksDB for Java works normally running in Rosetta mode, but as soon as environment is started in non Rosetta mode the program fails.

Activity

  1. self-assigned this
    on Nov 28, 2020
  2. adamretter commented on Nov 28, 2020

    @adamretter
    Collaborator

    @jurmous I am waiting for #7714 to get merged before I add the update for RocksJava. If you want to test #7714 and give us some feedback that would be great...

  3. jurmous commented on Nov 29, 2020

    @jurmous
    ContributorAuthor

    I posted my feedback in #7714.

  4. jurmous commented on Dec 10, 2020

    @jurmous
    ContributorAuthor

    @adamretter Thanks for all the work on the Apple Silicon compilation issues! Do you have any update on the RocksJava Apple Silicon support? Or do you need help?

  5. adamretter commented on Dec 10, 2020

    @adamretter
    Collaborator

    @jurmous I can likely send a PR tomorrow if that works for you?

  6. adamretter commented on Dec 11, 2020

    @adamretter
    Collaborator

    @jurmous okay so there is no problem with building RocksDB and RocksJava from source and running it on Apple Silicon now.

    I will shortly send a PR to differentiate between Mac binaries for x64 and aarch64. We can then package both into the next release of RocksJava that is published on Maven central.

    As well as separate libraries for each architecture (x64 and aarch64) it seems we could combine them into a single "Universal Binary" (see: https://developer.apple.com/documentation/xcode/building_a_universal_macos_binary), I will give some thought as to the best approach.

  7. jurmous commented on Dec 11, 2020

    @jurmous
    ContributorAuthor

    @adamretter Thanks for checking it out!

    Cool that there is no problem building the libraries!

    Yes both directions would be valid. Universal makes some things easier I guess and the Mac binary is not that large compared to linux64.

  8. jurmous commented on Jan 13, 2021

    @jurmous
    ContributorAuthor

    @adamretter Were you already able to give some thought on the best approach? And were you able to create a PR? Thanks! 😊

  9. adamretter commented on Jan 13, 2021

    @adamretter
    Collaborator

    @jurmous Sorry for the delay, I do have some preliminary work here for building Universal Binaries. I had to pause whilst other priorities took over, but I hope to get back to it ASAP.

  10. jurmous commented on Jan 14, 2021

    @jurmous
    ContributorAuthor

    Ok, I understand. Good luck with the other priorities! Let me know if I can help when you are able to get back to it!

  11. Yrp commented on Jan 29, 2021

    @Yrp

    Hi, guys. Any progress?

  12. adamretter commented on Jan 29, 2021

    @adamretter
    Collaborator

    @jurmous @Yrp you can find the start of my work on Universal Binaries for RocksDB here -
    https://github.com/adamretter/rocksdb/tree/macos-multi-arch

    Running make static_lib_ub will give you a Universal Binary for both
    x86_64 arm64.

    Building the universal binaries can be done in macOS on either Intel
    or Apple Silicon as long as you have macOS bigSur and the latest
    XCode.

  13. jurmous commented on Jan 30, 2021

    @jurmous
    ContributorAuthor

    @adamretter Thanks for all the work already! ❤️

    I have checked out your branch and tried to run make static_lib_ub on root.
    I get however an error about an unknown CPU target:
    (Big Sur 11.1 & Xcode 12.4 on an M1 machine)

    $DEBUG_LEVEL is 1
    Makefile:203: Warning: Compiling in debug mode. Don't use the resulting binary in production
      GEN      util/build_version.cc
    $DEBUG_LEVEL is 1
    Makefile:203: Warning: Compiling in debug mode. Don't use the resulting binary in production
      GEN      util/build_version.cc
    TARGET_ARCHITECTURE=x86_64 STATIC_LIBRARY=librocksdb_debug-x86_64.a /Applications/Xcode.app/Contents/Developer/usr/bin/make static_lib
    $DEBUG_LEVEL is 0
      GEN      util/build_version.cc
      CC       db/column_family.o
    error: unknown target CPU 'armv8-a+crc+crypto'
    note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere,
          sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake,
          icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
          btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
    make[1]: *** [db/column_family.o] Error 1
    make: *** [static_lib_ub] Error 2
    

    make static_lib runs fine btw.

    This work is for the generic static library if I am correct? If this works correctly further work has to be done to build a universal librocksdbjni-osx.jnilib?

  14. tobiade commented on Apr 4, 2021

    @tobiade

    Hey folks - thanks for the work here. I just ran into this issue when trying to run a Kafka Streams app on my M1 machine. The Kafka Stream library is using RocksDB v5.18.4 under the hood.

    @jurmous you mentioned you were able to run RocksDB when running in Rosetta mode? Could you please let me know how you did that? I'm just (very) simply trying to run my app from IntelliJ, so curious as to how to modify it to run in Rosetta mode.

  15. 38 remaining items

  16. jurmous commented on Mar 26, 2022

    @jurmous
    ContributorAuthor

    RocksDB 6.29.4.1 has been released to Maven Central which should now work on M1 macs.

  17. adamretter commented on Mar 26, 2022

    @adamretter
    Collaborator

    Additionally now so has version 7.0.3

  18. added 2 commits that reference this issue on Jun 7, 2022
  19. added 3 commits that reference this issue on Jul 18, 2022
    bff8989
    ca05d23
    dac2c60
  20. added a commit that references this issue on Nov 21, 2022
    76c7404
  21. added a commit that references this issue on Feb 20, 2026
    5602b1d
  22. added a commit that references this issue on Oct 1, 2026
    caed479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions