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

Add Redox OS as a target #93568

Merged
merged 1 commit into from Jul 22, 2020
Merged

Add Redox OS as a target #93568

merged 1 commit into from Jul 22, 2020

Conversation

aaronjanse
Copy link
Member

lib/systems: Add Redox platform definitions

Motivation for this change

Redox is a Unix-like Operating System written in Rust, aiming to bring the innovations of Rust to a modern microkernel and full set of applications.

Per RFC0046, I hope for Redox to be a tier 5 platform, unsupported and somewhat functional. I'm developing a redoxpkgs overlay (inspired by @ehmry's genodepkgs) to patch packages to work for Redox. With this overlay, I can compile functioning packages such as binutils and the Rust cross-compiler. In turn, packages such as hexyl can be compiled without further modification beyond adding Redox to the package's meta.plaforms.

I marked this PR as a draft because it contains some changes (see below) that may need to be removed. More specifically, I made a few conditional changes that I couldn't figure out how to do via an overlay.

Note that relibc is downloaded precompiled from a filehosting service. It's precompiled because I've tried to compile relibc from source but it crashes during runtime on Redox. It's from a filehosting service because https://static.redox-os.org continually replaces its contents with new versions, breaking the Nix fetch hash. I've contacted Redox maintainers about this; it sounds like https://static.redox-os.org will have pinned versions in the future. I understand if using a third party filehosting service is a blocking security issue.

Things done

Things I'd like to keep in this PR:

  • updated lib/system to add x86_64-redox
  • added derivation relibc, the POSIX C standard library for Redox.
  • enabled the static overlay for Redox

Things I'm comfortable removing from this PR if necessary:

  • slightly modified gcc6 and rustc to support Redox (see note above)

  • slightly modified all-packages.nix to choose versions of toolchain packages based on isRedox

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)

  • Built on platform(s)

    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)

  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"

  • Tested execution of all binary files (usually in ./result/bin/)

  • Determined the impact on package closure size (by running nix path-info -S before and after)

  • Ensured that relevant documentation is up to date

  • Fits CONTRIBUTING.md.


I think @NixOS/exotic-platform-maintainers would find this PR interesting, so I'll ping them here

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/redox-nix-was-where-does-the-cc-environment-variable-come-from/7784/9

@ofborg ofborg bot added 6.topic: rust 6.topic: stdenv Standard environment labels Jul 21, 2020
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

This PR looks nice and unobtrusive to me. Very excited to escape the confines of Unix!

@aaronjanse aaronjanse marked this pull request as ready for review July 21, 2020 01:46
@aaronjanse
Copy link
Member Author

Sweet! I just marked the PR as mergable (no longer a draft) :-)

worldofpeace
worldofpeace previously approved these changes Jul 21, 2020
Copy link
Contributor

@worldofpeace worldofpeace left a comment

Choose a reason for hiding this comment

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

See above comments

@aaronjanse
Copy link
Member Author

I added the tests (85486ec) based on the Genode PR

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

diff LGTM

all of the fixup commits could be squashed (at least from my perspective).

not sure what the first commit should be named?

redox: Add as target

if someone could can think of a better commit message, then please prefer that.

@jonringer
Copy link
Contributor

jonringer commented Jul 21, 2020

I understand if using a third party filehosting service is a blocking security issue.

If you verified that the contents are correct, then they sha will validate that contents haven't changed. I think that's alright.

Edit: format

@aaronjanse
Copy link
Member Author

I just squashed :-)

[ ../use-source-date-epoch.patch ./0001-Fix-build-for-glibc-2.31.patch ]
++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
patches = optionals (!stdenv.targetPlatform.isRedox) [
../use-source-date-epoch.patch ./0001-Fix-build-for-glibc-2.31.patch
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these patches not apply cleanly on the redox gcc fork, or are already applied there?

We usually try to apply patches unconditionally of the platform.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct. Both patches fail to apply to the redox gcc fork

Copy link
Contributor

@ehmry ehmry left a comment

Choose a reason for hiding this comment

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

I hesitate to endorse adding a new libc without a clear way to test it, but I think that adding platform definitions early is ok.

lib/systems/inspect.nix Show resolved Hide resolved
@jackpot51
Copy link

Testing could be done with redoxer

@aaronjanse
Copy link
Member Author

I hesitate to endorse adding a new libc without a clear way to test

I understand this. I just force-pushed a commit to this PR to remove platforms.linux from relibc's meta.platforms. I think it would be cool to allow relibc for Linux packages, but not in this PR.

However, I don't see any harm in keeping relibc, with Redox as the only supported platform.

@worldofpeace
Copy link
Contributor

@ofborg build relibc

description = "C Library in Rust for Redox and Linux";
license = licenses.mit;
maintainers = [ maintainers.aaronjanse ];
platforms = platforms.redox;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add Linux here if it supports it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, then we can check if it builds on ofborg

Copy link
Member Author

Choose a reason for hiding this comment

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

I just realized that while relibc supports Linux, that specific precompiled version does not

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I try conditionally compiling from source (!stdenv.hostPlatform.isRedox) for the Linux version? I think that might be good for a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, I think this libc is fine as a placeholder for now, and then you can work further on it at the overlay.

@ehmry
Copy link
Contributor

ehmry commented Jul 21, 2020

I hesitate to endorse adding a new libc without a clear way to test

I understand this. I just force-pushed a commit to this PR to remove platforms.linux from relibc's meta.platforms. I think it would be cool to allow relibc for Linux packages, but not in this PR.

I didn't realize the libc was compatible with Linux, in that case its better to merge relibc with a Linux meta.platforms initially so that automated build tests work.

I see you found updateAutotoolsGnuConfigScriptsHook, roughly how much of the existing packages do you think will build?

@aaronjanse
Copy link
Member Author

I see you found updateAutotoolsGnuConfigScriptsHook, roughly how much of the existing packages do you think will build?

Inititally, very few, because many packages still need patches

@Mic92
Copy link
Member

Mic92 commented Jul 21, 2020

Looks like @jD91mZM2 is contributor to redox itself.

@aaronjanse
Copy link
Member Author

aaronjanse commented Jul 21, 2020 via email

@aaronjanse
Copy link
Member Author

I see you found updateAutotoolsGnuConfigScriptsHook

H/t to @boomshroom for helping me find this. While attempting Redox+Nix in the past, they documented their progress and questions on IRC. I stumbled upon those IRC logs while searching the web, and they've been super helpful

@boomshroom
Copy link
Contributor

I barely remember making those. In fact I had forgotten before you posted that, and I still didn't remember the updateAutotoolsGnuConfigScriptsHook part. I'm flattered that something I'd written was useful. I certainly didn't expect it, but I'm glad to see this here!

Copy link
Member

@jD91mZM2 jD91mZM2 left a comment

Choose a reason for hiding this comment

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

I have no comments, only congratulations and cheering. Absolutely brilliant work, thank you! 😄

@Ericson2314
Copy link
Member

Yeah this looks good I don't wanna wait any longer :).

@Ericson2314
Copy link
Member

I made #93661, #93662, and #93663 for @aaronjanse to hopefully have time to look at.

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

Successfully merging this pull request may close these issues.

None yet