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

Enable cross-compilation of native libraries #1446

Open
loicottet opened this issue Jun 27, 2019 · 8 comments
Open

Enable cross-compilation of native libraries #1446

loicottet opened this issue Jun 27, 2019 · 8 comments

Comments

@loicottet
Copy link
Member

loicottet commented Jun 27, 2019

I'm working on making the LLVM backend of Graal output ARM programs and a big blocker is that the native C libraries (libjvm, liblibchelper, libstrictmath notably) are compiled by default for the host platform only.

It would be nice to be able to select the target architecture when running mx build and have the binaries output to the <os>-aarch64 folder instead of the current <os>-amd64.

@vjovanov
Copy link
Member

Once cross-compilation is fully supported we will also have to ship those with the distribution.

@johanvos
Copy link
Contributor

johanvos commented Jun 27, 2019

+1 on this.
The current property in suite.py for doing this is called os_arch but it only checks the (build) os. It would be helpful to have both a targetOs and targetArch entity and have the output indeed in <targetOs>-<targetArch>.
If nothing is specified, the native libs should be built for targetOs = currentOs and targetArch = currentArch.

@vjovanov
Copy link
Member

vjovanov commented Jul 2, 2019

@gilles-duboscq this is a proposal:
As the first step, we need:

  1. To introduce --target-arch in mx build. For example, we would have mx build --target-arch=aarch64. Here it is important to do this right: the tripled used by ninja is complicated so we need to design this in a way that it is extensible in the future (e.g., what if ARM needs a different ABI or a different floating point strategy than the host).
  2. This flag would be used in the mx.get_arch instead of the host (when set). Here, we need to find all usages of mx.get_arch and
  3. The ninja build would use a specific GCC to build for the target architecture.

In the second step, we would introduce components for native-image native libraries for supported architectures. On amd64 hosts, people would need to install the component for aarch64 if they need to develop for aarch64 and on aarch64 hosts they would need a component for amd64.

This feature would be used as follows:

  1. In development, users would do mx build; mx build --target-arch=aarch64.
  2. In production, users would do gu install native-image-aarch64, or something similar. That is, in GraalVM this would be just another component related to the native image.

@araspitzu
Copy link

Any news on this?

@pejovica
Copy link
Member

The first set of changes that add support for multiarch native projects to mx is being reviewed. Once that's merged, I'll convert the projects used by the native-image and add support for the aarch64 cross-toolchain.

@plebcity
Copy link

plebcity commented Feb 27, 2023

We would love to be able to cross compile to aarch64 using the native-image tool. Is this supported now?

@mageddo
Copy link

mageddo commented Mar 3, 2023

Still a unreleased feature, tried this on graalvm 23.3.1 JDK 19

$ native-image --no-server --no-fallback --target=linux-aarch64 -jar build/libs/graalvm-vanilla-all.jar ./build/graalvm-vanilla
Warning: Ignoring server-mode native-image argument --no-server.
Error: Invalid Path entry /home/typer/.sdkman/candidates/java/22.3.1.r19-grl/lib/svm/clibraries/linux-aarch64
Caused by: java.nio.file.NoSuchFileException: /home/typer/.sdkman/candidates/java/22.3.1.r19-grl/lib/svm/clibraries/linux-aarch64

But if a try to install the native image module for a cross OS, I will the another error

$ gu -u install "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/llvm-installable-svm-java19-linux-aarch64-22.3.1.jar"
Processing Component: https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/llvm-installable-svm-java19-linux-aarch64-22.3.1.jar
Downloading: Component https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/llvm-installable-svm-java19-linux-aarch64-22.3.1.jar: https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/llvm-installable-svm-java19-linux-aarch64-22.3.1.jar from github.com
Installation of https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/llvm-installable-svm-java19-linux-aarch64-22.3.1.jar failed: Component LLVM Runtime Core could not be installed. It requires Architecture aarch64, but the GraalVM provides amd64
Error: Component LLVM Runtime Core could not be installed. It requires Architecture aarch64, but the GraalVM provides amd64

@mageddo
Copy link

mageddo commented Mar 3, 2023

Related issue #407

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

8 participants