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 system support for .so on GNU Linux for both x86_64 and aarch64 #303

Closed
webmaster128 opened this issue Mar 21, 2022 · 7 comments · Fixed by #330
Closed

Build system support for .so on GNU Linux for both x86_64 and aarch64 #303

webmaster128 opened this issue Mar 21, 2022 · 7 comments · Fixed by #330
Milestone

Comments

@webmaster128
Copy link
Member

webmaster128 commented Mar 21, 2022

In https://github.com/CosmWasm/wasmvm#builds-of-libwasmvm you see that ​libwasmvm.so (x64_64) and libwasmvm.aarch64.so are supposed to be built. But we do not yet have the build system for it. One builder image (the CentOS one) can build both of them. This makes it easy to integrate both builds in the CI.

What needs to be done is

  1. Modify https://github.com/CosmWasm/wasmvm/blob/main/builders/Dockerfile.centos7 to install the Rust targets x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu (as we did for Mac)
  2. Create two cargo builds with explicit --target to build_linux.sh (as we did for Mac here and here)
  3. Copy the build results from target/{x86_64,aarch64}-unknown-linux-gnu/release/… and write them in the artifacts folder
  4. Adapt the Makefile to copy two .so files instead of one to the api/ folder
  5. Create a version of api/link_std.go that links the libwasmvm.aarch64.so which has a different name than the x86_64 library.
  6. (optional) Once 1-5 works nicely, the builder image can be built for ARM64 as well in order to get better build performance on M1 machines. It seems like Cent OS 7 is available on x86 and x86_64 only. So we need Intel builders to create those libraries.
@webmaster128
Copy link
Member Author

In #305 the same is done for the musl librarues. Maybe this helps for orientation as well. Point 5. is not implemented though. However, the .a file needs to be copied separately anyways.

@Taztingo
Copy link
Contributor

Taztingo commented Mar 22, 2022

I was able to find an official release of a gcc cross compiler, but I was unable to find any official glibc rpms for cross compiling. I am attempting to build gcc and glibc for cross compiling from source, but if someone has a better idea please let me know.

@maurolacy
Copy link
Contributor

Switch compiler? Clang should be around and work well.

@webmaster128
Copy link
Member Author

Could you post your error message? I guess this is about the C build of handlers.c via build.rs when wasmer-vm is compiled. This part requires a C cross compiler.

@Taztingo
Copy link
Contributor

Taztingo commented Mar 23, 2022

I've been spinning in circles quite a bit, but that is exactly where it is failing now. I currently have clang set as my compiler, and I'm getting the following error.

  cargo:warning=# include <gnu/stubs-32.h>
  cargo:warning=          ^
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=aarch64-unknown-linux-gnu" "-Wall" "-Wextra" "-DCFG_TARGET_OS_LINUX" "-o" "/code/target/aarch64-unknown-linux-gnu/release/build/wasmer-vm-db468701db9730b4/out/src/trap/handlers.o" "-c" "src/trap/handlers.c" with args "clang" did not execute successfully (status code exit status: 1).

I can install glibc-devel.i686, but I don't think that's correct. I tried installing the only glibc-aarch64 rpms I could find which are:
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm
http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/glibc-aarch64-linux-gnu-devel-2.24-2.sdl7.2.noarch.rpm
Still encountered the same issue.

@Taztingo
Copy link
Contributor

I was able to resolve most of the issues by setting the linker in cargo-config and installing the following dependencies...

yum -y install gcc-aarch64-linux-gnu gcc-c++-aarch64-linux-gnu
yum install -y http://springdale.princeton.edu/data/springdale/7/x86_64/os/Computational/glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm

However, I am missing libgcc_s.so. I'm not sure why these packages don't have it, but the linker needs it. The last thing I can really think of is building gcc from source.

/usr/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

@faddat

This comment was marked as off-topic.

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

Successfully merging a pull request may close this issue.

4 participants