Skip to content

jbpf does not build out of the box for ARM machines (Mac M1/M2 chips) #58

Closed

Description

Describe the bug
jbpf does not compile out-of-the-box on ARM machines.

When following the README and examples, an ARM user will come across a couple build issues. First, the provided Dockerfiles installs gcc-multilib which does not exist on ARM. There are two workarounds for this:

  1. ARM users can build for AMD by specifying a platform flag for docker build: docker build --platform linux/amd64 -f <Dockerfile> .
  2. ARM users can build natively for ARM by excluding gcc-multilib from the Dockerfile

If an ARM user tries to build natively for ARM (option #2 above), they will come across a couple other issues when building jbpf and running the provided examples:

  • jbpf_start_time and jbpf_end_time functions have inline x86 assembly. These function calls get called (and error) when running on ARM. There are several possible ways to fix this. You could also gate these functions on x86 and replace the calls to jbpf_start_time and jbpf_end_time with jbpf_measure_start_time and jbpf_measure_end_time respectively, which are wrappers that can call clock_gettime depending on the platform to avoid calling the asm. Or you could get rid of the asm and decide clock_gettime is good enough on any platform. There are probably several more ways to fix this issue.
  • To get the examples working when building natively for ARM, I also had to apt install libc6-dev in the Dockerfile and modify some Include flags in the example Makefiles. Finally, I added ld-linux-aarch64.so to the approved libraries list in helper_build_files/approved_libraries.txt.

To Reproduce
Steps to reproduce the behavior:

  1. On an ARM machine (like Mac M1/M2) follow the build instructions in the README and install dependencies page.
  2. Get Docker errors when building Dockerfile:
Package gcc-multilib has no installation candidate
  1. When building jbpf on ARM, see the following error regarding x86 asm in source code:
error: unknown register name 'rdx' in 'asm'
lto-wrapper: fatal error: /usr/bin/cc returned 1 exit status
compilation terminated.

Expected behavior
README instructions for building jbpf and running examples to work out of the box on ARM machines.

Desktop (please complete the following information):

  • OS: Mac M1 Pro running macOS Sequoia
  • Docker: version 27.5.1

Activity

  1. xfoukas commented on Mar 21, 2025

    @xfoukas
    Collaborator

    Anita Tenjarla (@anita-tenjarla) thanks for raising this very detailed issue!

    Indeed, we do not currently provide support for ARM, as our initial focus has been on x86.
    However, we welcome any contributions that could help us get ARM working as well.

    From your description I understand that you have already gotten jbpf working on ARM? If so, would you be open to create a PR with your suggested fixes? We are happy to work with you and discuss in more depth the sub-issues that you described and the right ways to address them.

  2. anita-tenjarla commented on Mar 21, 2025

    @anita-tenjarla
    ContributorAuthor

    Thanks for the quick response! I put up a PR with the changes I have working locally. With these changes, I'm able to build jbpf and run the standalone example for both ARM and AMD (depending on the --platform flag I give Docker). I'm not sure if this breaks anything for AMD users- open to all feedback.

  3. xfoukas commented on Mar 21, 2025

    @xfoukas
    Collaborator

    Thanks a lot for creating the PR!

    We will go over it and will try to run tests locally and I will then get back to you with feedback.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions