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

full picture of cross-compiling #5

Open
scottlamb opened this issue Mar 2, 2022 · 1 comment
Open

full picture of cross-compiling #5

scottlamb opened this issue Mar 2, 2022 · 1 comment

Comments

@scottlamb
Copy link

scottlamb commented Mar 2, 2022

I love the idea of Rust cross-compiling to arbitrary glibc versions as easily as Zig does. Seems like parsing Zig's abilists is one part of that goal. Are you working on the complete picture? Is anyone?

My understanding (which could be way off) is that in general terms, Zig uses these abilists to represent the ABI (exported symbols, some with versioning/weak definition or something) of all versions of glibc. You can select one and the linker essentially assumes the existence of a matching .so somehow.

So how can this work for Rust out of the box? My thoughts below but perhaps yours are more fleshed out...

Short-term: maybe a linker script that can be dropped in via target.<triple>.linker (see docs) and actually constructs a dummy .so file (a .so with the correct definitions and non-functioning implementations) and somehow sets up linker arguments to assume it's installed in the system search path (i.e., not adding an rpath entry to a tempdir or some such).

Long-term: it'd be nice if you could just add glibc-version to a [target.<arch>-unknown-linux-gnu] section of your .cargo/config.toml and cargo plumbed along the option to rustc, which took care of the rest for you. Maybe it does what that linker script does, or maybe the linker does/should provide some more abstract interface than an existing .so file.

@ErichDonGubler
Copy link
Owner

Oh hey! Welcome! 👋😊

I love the idea of Rust cross-compiling to arbitrary glibc versions as easily as Zig does. Seems like parsing Zig's abilists is one part of that goal.

Ditto! I don't have much experience with actually working on the compilation toolchain itself or doing advanced linking configuration in any language, but I'm excited to contribute. :) It was easy enough for me to write a binary parsing lib -- now I'm hoping I can actually get familiar with the domain it'll actually get used in!

Are you working on the complete picture? Is anyone?

WRT glibc symbols? IDK, actually. I'm asking on the #t-compiler stream right now in the official Rust Zulip.


RE: your long- and short-term suggestions: I unfortunately don't feel like I have a good enough grasp on the process of actually targeting different glibc versions to give intelligent feedback, unfortunately! I would like to learn enough to change that, and maybe you could help me do that.

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

No branches or pull requests

2 participants