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

Library Forwarding: Make building on weak cross-compiling setups easier #3597

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

neobrain
Copy link
Member

ARM64 Ubuntu provides both an x86 cross-compiler and corresponding glibc/stdlibc++ libraries, which makes cross-compiling FEX's guest library wrappers very easy. Sadly most other distributions only ship the compiler without any libraries/headers at all. In such environments, it can be easier to compile only the host-side libraries while offloading builds of the guest libraries to another machine / VM.

This PR adds two main features to make such fallback setups possible:

  • Guest wrappers may now be built separately from the main project by running cmake ../ThunkLibs/CMakeLists.txt -DX86_32_TOOLCHAIN_FILE=`realpath ../toolchain_x86_32.cmake` -DX86_64_TOOLCHAIN_FILE=`realpath ../toolchain_x86_64.cmake` -DX86_DEV_ROOTFS=/ from a dedicated build folder.
  • The new X86_DEV_ROOTFS CMake setting can be used to provide a development x86 rootfs, from which standard headers will be read. (Specifically, Ubuntu requires these packages: libstdc++-12-dev-amd64-cross libstdc++-12-dev-i386-cross libstdc++-12-dev libc6-dev-amd64-cross libc6-dev-i386-cross linux-libc-dev-amd64-cross linux-libc-dev-i386-cross)

@alyssarosenzweig
Copy link
Collaborator

In the case where we have a working x86 cross compiler when building on arm64, and can procure a x86 rootfs but without the proper multilib integration, does X86_DEV_ROOTFS provide the necessary glue to build thunks without needing a separate machine/VM? If so, I think that sounds like a decent approach for Fedora. It would be great to get some documentation (either in-tree or contributed to wiki) about how to use these new options to build fex on such weak setups.

@neobrain
Copy link
Member Author

In the case where we have a working x86 cross compiler when building on arm64, and can procure a x86 rootfs but without the proper multilib integration, does X86_DEV_ROOTFS provide the necessary glue to build thunks without needing a separate machine/VM? If so, I think that sounds like a decent approach for Fedora. It would be great to get some documentation (either in-tree or contributed to wiki) about how to use these new options to build fex on such weak setups.

It might work without a VM, but I haven't tested it. You'd have to add the dev rootfs paths to the CMake toolchain files in our project root so that the CMake targets in GuestLibs/CMakeLists.txt can also find the headers/libraries. Definitely interested to see someone try that out!

ThunkLibs/CMakeLists.txt Outdated Show resolved Hide resolved
@neobrain neobrain force-pushed the feature_libfwd_build branch 2 times, most recently from afb9526 to ba6c175 Compare April 25, 2024 13:28
@neobrain neobrain force-pushed the feature_libfwd_build branch 2 times, most recently from 749cc9c to 98d3de8 Compare April 25, 2024 13:38
@neobrain
Copy link
Member Author

Realized we can achieve the same effect by using --sysroot and re-adding the global /usr/include directory for library headers, which is much cleaner than adding hardcoded include directories manually.

@neobrain neobrain marked this pull request as draft April 25, 2024 14:32
ExternalProject_Add(guest-libs
PREFIX Guest/guest-libs
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/GuestLibs"
BINARY_DIR "../Guest"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something's off about this. I'm getting weird RPATH errors without ../, but with ../ it's clearly putting the data in the wrong folder.

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 this pull request may close these issues.

2 participants