Skip to content

add first HelenOS compilation targets #139310

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mvolfik
Copy link

@mvolfik mvolfik commented Apr 3, 2025

I'm working on adding a HelenOS compilation target for Rust as my bachelor thesis. I understood that the policy for tier 3 targets is quite liberal, so here's my attempt at upstreaming the initial support. I'm quite new to Rust internals, so thanks in advance for all assistance with my stupid questions :)

libstd support is coming, but I understood compiler support must come first before libc bindings can get merged (rust-lang/libc#4355 (comment))

Locally, I also needed to update cc-rs, to do two things:

  • add here the binutils prefixes (x86_64-unknown-helenos -> amd64-helenos
  • add the targets to generated.rs

From the "Adding tier 3 target" guide it sound like the latter will happen automatically, the first I need to do manually? I'm not sure if the test suite will pass or fail without it.

I'm also quite unsure about all the target spec configuration flags. I copied the specs from other small OSs with some tweaks and things seems to work now, but I have no idea how to better judge if it's correct.

Finally, I'm also working on support for arm (32-bit and 64), but there I'm currently running into some issues with linking, so I'll send that later, if I figure it out.


Tier 3 policy "form"

A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

That would be me, I suppose. I agree.

Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

I'm using the standard Rust conventions.

Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

  • The target must not introduce license incompatibilities.
  • Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

I am not aware of any legal issues. HelenOS itself is open-source under BSD license. All code contributed in this PR (and later for libstd) is either fully my own or an adaptation of existing code from this repo (some PAL pieces).

  • The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

I am not adding any new dependencies.

  • Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

The HelenOS build tools consist of open-source patches to GCC and binutils, so I suppose we're fine.

Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

Understood.

Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

The libstd PR will fully support core+alloc, and enough of std to run interesting programs (stdio, argv and fs) - so we can run tools like imagecli. But yes, major parts of std are missing - pipe, process and net are currently forwarded to unsupported(). Some barebones net should be possible, but e.g. cloning of the descriptor is unheard of in HelenOS, so it won't be as straightforward as the rest. Also, some places of the fs and thread module are also quite stubby (but part of it is just because HelenOS has no file permissions, for example). HelenOS is a small, experimental OS, so its own libc is stubbed out as well in some places. I hope this state is acceptable?

The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

I hope the guide in doc is sufficient.

Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via @) to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Understood.

Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

Understood.

Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

Umm, I think this is satisfied? Code generation works with the default LLVM backend, even though it has no idea about HelenOS. And our GCC patch is then used only for linking.

@rustbot
Copy link
Collaborator

rustbot commented Apr 3, 2025

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 3, 2025

These commits modify compiler targets.
(See the Target Tier Policy.)

Some changes occurred in src/doc/rustc/src/platform-support

cc @Noratrieb

@mvolfik
Copy link
Author

mvolfik commented Apr 3, 2025

Ah, sorry, of course I forgot to do this

r? compiler

@rustbot rustbot assigned wesleywiser and unassigned BoxyUwU Apr 3, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Apr 17, 2025

☔ The latest upstream changes (presumably #138011) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants