-
Notifications
You must be signed in to change notification settings - Fork 123
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 thunks GuestLibs on other arm64 distros (say, Arch Linux) #1996
Comments
Is the issue on Arch that there is no x86 glibc/libstdc++ package available, or not even the x86 cross-compiler itself? I'm guessing chances are slim someone else already wrote an AUR for this? Some other things worth considering alongside this issue:
Idea three is a nonsolution for (1). Git submodules also are a bad fit for it, since we'd have to start including the same repository from multiple submodules. I'd also like to avoid ending up with a megarepo with hundreds of libraries that must be updated individually without proper tooling. Depending on how complex this gets, we may be better off resorting to a containerized Ubuntu install. Maybe the cross-compiler could be provided in a Ubuntu podman instance that is integrated using toolbox on non-Ubuntu systems? That way, whatever library structure we end up using would be versionable in a Dockerfile as well. That is not something we need to tackle in its entirety immediately, but the approach we choose to support cross-compilation on non-Ubuntu distros shouldn't require us to throw everything over again once we start worrying about points (1)-(3). Can we get away with just requiring an x86 toolchain with standard libraries to be provided by the user for now, and provide a minimal toolbox environment to satisfy this requirement on Arch? Some other random thoughts:
Guest
Just to add one data point, I think openSUSE can almost build thunks out-of-the-box (there's merely two minor issues unrelated to the toolchain). This may change once support for 32-bit thunks is added, though.
I'm not sure this can easily be done without chrooting into the rootfs, or without invasively copying files from the rootfs into the global system directories. |
Not even a cross-compiler.
This is actually a very good point; And it might be worth designing a system explictly to handle this case.
Yeah, lets stay away from submodules. I think we want to go with something deterministic.
Eh.... I think containers will be a mistake for this. If we use clang as the cross-compiler, then the only extra files we need are headers. What I'm considering right now is a deterministic system that downloads and extracts just the header files (from Debian or Ubuntu packages?) into per-library folders at configure time. I think I have experimental code somewhere that can be adapted for this. Then we just pass the required include paths into the build for each guest thunk library. This way, we avoid full containers; We avoid git submodules; We avoid any chrooting; And we avoid all dependencies on host packages (except clang) |
Yup, if providing a cross-toolchain for Arch isn't that big of a deal, then containers don't provide much of a benefit here.
Yeah, that sounds fine for the time being too. Some libraries might need additional defines (which would normally be set up by pkgconf/CMake), but we can continue setting these on a case-by-case basis for now. |
I'll whip up a prototype on Monday, double check that this is a sane direction. Theoretically, such a system could extended in the future to automatically handle pkgconf, but we might be better off with the extra control that setting these manually gets us. |
FEX is a C++ project. If you see an applicable idea in this 40-minute-long article, please summarize your proposal here. |
Sorry, I'm not familiar enough with things to be able to offer any concrete proposals. I just came across this issue while trying to compile thunks on Fedora, which lacks a cross gcc toolchain.
But it does seem like zig supports C++ too (including |
Oh, this is a neat idea. Going to give this a whirl, thanks for the suggestion! |
My FEX repo's zig/cc branch has a proof of concept of building with x86_64 thunks with zig cc on fedora 39, no special rootfs's etc. glxgears works, so far no steam games do. Still promising, think I'll push on this some more next week. @teohhanhui Is this interesting from a fedora packaging perspective? or just for developer convenience? |
I'm not (yet?) a Fedora packager, just someone trying to build a package: https://github.com/teohhanhui/rpms/tree/f39/fex-emu (but hopefully I could get this accepted into Fedora repos?) So I think you'd have to ask someone else ^^ Might have better luck with f40? zig in f39 is 2 major versions behind. |
Anything that is found that could make packaging easier for Fedora on our end would be good to know. Currently I manage the Canonical launchpad ppa builds which mostly works out of the box, so I don't know what troubles other distros would have. |
For Fedora, I wonder if there'd be any problems if we just ask the user to create a separate installroot for the guest libs? So just build the guest libs normally on the x86_64 build, and install it on your aarch64 system to a separate installroot e.g. Could only the HostLibs be built as part of the aarch64 build, and would that work with GuestLibs built as part of the x86_64 build? |
That's part of what #3597 does, is just annoying if you don't have x86 hardware 😉 |
Currently we rely on debian's
gcc-x86-64-linux-gnu
package to supply a working x86_64 cross-compiler on Debian/Ubuntu distros. But other distros (like Arch Linux) are missing such handy packages.I've done a bit of preliminary research, and it seems like these are our rough options:
Option One - Use clang instead:
Clang helpfully includes compilers for all triples by default, and cross-compiling is simply a matter of passing the correct triple into clang/clang++. This seems like an elegant solution, we already require clang for thunk generation, why not use it for building thunks too.
However... This solution only gets you a compiler.
The
gcc-x86-64-linux-gnu
package (and theg++
/multilib-i686
variants) actually pull in a bunch of other packages to supply a full libc and libc++ and other support libraries that our thunks need to build. If we go with the clang option, then we need to supply the missing include from somewhere else.But from where? We have a two potential options:
Option Two - Generate equivalent packages for Arch
These packages are clearly useful for Debian, would be nice to have equivalents in Arch Linux ARM.
There are some downsides to this approach:
Idea three - Just use a native x86 toolchain inside our rootfs
This is an ugly and lazy option. Requires a large download (and probably unpacking the rootfs to install a compiler)
Whatever solution we go with, we should standardise across all distros, so we aren't using widely different approaches on different distros. I'm currently leaning towards Option One, with us packaging headers, not just for libc/libstdc++, but all libraries we thunk.
The text was updated successfully, but these errors were encountered: