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

rustup-init.sh: Check for kernel UAPI compatibility on LoongArch #3404

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

xen0n
Copy link
Contributor

@xen0n xen0n commented Jul 12, 2023

In preparation for the next release which will feature LoongArch support, for a smoother UX in case the user is running an incompatible system (see the commit message & comment for some details).

@xry111
Copy link

xry111 commented Jul 15, 2023

Would it be easier to just check uname -r like the following?

printf "5.19.0\n$(uname -r)\n" | sort -C -V

@xen0n
Copy link
Contributor Author

xen0n commented Jul 17, 2023

Would it be easier to just check uname -r like the following?

printf "5.19.0\n$(uname -r)\n" | sort -C -V

I don't have guarantees that a 5.19+ but old-world kernel would not get created and/or deployed to end users. If such guarantee would be given I'd agree this is the simpler way to go.

@xry111
Copy link

xry111 commented Jul 17, 2023

Would it be easier to just check uname -r like the following?

printf "5.19.0\n$(uname -r)\n" | sort -C -V

I don't have guarantees that a 5.19+ but old-world kernel would not get created and/or deployed to end users. If such guarantee would be given I'd agree this is the simpler way to go.

Perhaps we can ask Huacai... To me those organizations must keep to use the old-world will only update kernels to a new patch version anyway. They are quite conservative on any upgrading.

@xen0n
Copy link
Contributor Author

xen0n commented Jul 18, 2023

Self note: If we were to consider some of the early and experimental new-world distros (that have incompatible glibc symbol versions), the statically-linked helper included won't properly detect them as incompatible. We would need to link to at least one versioned symbol in libc in order to check this, but I don't think this case is worth supporting due to the explicit incompatibility notice and small user base.

@xen0n
Copy link
Contributor Author

xen0n commented Jul 18, 2023

Would it be easier to just check uname -r like the following?

printf "5.19.0\n$(uname -r)\n" | sort -C -V

I don't have guarantees that a 5.19+ but old-world kernel would not get created and/or deployed to end users. If such guarantee would be given I'd agree this is the simpler way to go.

Perhaps we can ask Huacai... To me those organizations must keep to use the old-world will only update kernels to a new patch version anyway. They are quite conservative on any upgrading.

I asked Huacai and the answer is "theoretically this can be done, but ultimately it depends on who's writing code".

Obviously, I don't trust the corporate devs making the commercial distros to always do the right thing, so I'd say checking kernel ABI would be more appropriate. (After a couple of years it may finally become evident whether the assumption actually holds, but at that time I'd expect the number of old-world-based developers to shrink enough that this is no longer a concern.)

And provide friendly diagnostics if a certain widely-deployed but
incompatible UAPI flavor (a.k.a. the "old-world" UAPI that's used by
several early and/or commercial LoongArch Linux distributions) is
detected.

The minimalistic probe was crafted by myself, checking for one of the
most prominent incompatibilities between the two UAPI flavors:
`sizeof(sigset_t)`. The probe binary is small enough to fit in 3 lines
of Base64, which is decoded into a temp file and executed for result.
The `base64(1)` command is ubiquitous (being provided by coreutils,
busybox and probably many others), and only necessary on LoongArch, so
we effectively don't lose portability.

Other irrelevant errors (e.g. /tmp being noexec) are made non-fatal,
because without the check the installer binary will instantly die
anyway on an incompatible system. A warning message is printed in case
such an error occurs.

(The installer binary, being dynamically linked, will die on a system
using the other incompatible UAPI, with a confusing error saying the
program being executed itself is not found: the actual non-existent
path is the ELF interpreter i.e. `ld.so`. Having some error messages in
case of this would hopefully reduce the technical support burden for
many.)
@rbtcollins rbtcollins merged commit bcbdca6 into rust-lang:master Aug 14, 2023
15 checks passed
@xen0n xen0n deleted the detect-loongarch-uapi branch August 15, 2023 00:43
@rami3l rami3l mentioned this pull request Jan 29, 2024
1 task
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.

None yet

3 participants