-
Notifications
You must be signed in to change notification settings - Fork 13k
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 managarm as a tier 3 target #123319
Open
no92
wants to merge
4
commits into
rust-lang:master
Choose a base branch
from
no92:managarm-target
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−3
Open
Add managarm as a tier 3 target #123319
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dedc082
compiler: Add `x86_64-unknown-managarm-mlibc` target
no92 eba9cc1
doc: Add `*-unknown-managarm-mlibc` documentation
no92 2a74533
fixup! doc: Add `*-unknown-managarm-mlibc` documentation
no92 6883e01
fixup! compiler: Add `x86_64-unknown-managarm-mlibc` target
no92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use crate::spec::{cvs, RelroLevel, TargetOptions}; | ||
|
||
pub fn opts() -> TargetOptions { | ||
TargetOptions { | ||
os: "managarm".to_string().into(), | ||
env: "mlibc".to_string().into(), | ||
dynamic_linking: true, | ||
executables: true, | ||
families: cvs!["unix"], | ||
has_rpath: true, | ||
position_independent_executables: true, | ||
relro_level: RelroLevel::Full, | ||
has_thread_local: true, | ||
crt_static_respected: true, | ||
..Default::default() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
compiler/rustc_target/src/spec/targets/x86_64_unknown_managarm_mlibc.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata}; | ||
|
||
pub fn target() -> Target { | ||
let mut base = base::managarm_mlibc::opts(); | ||
base.cpu = "x86-64".to_string().into(); | ||
base.max_atomic_width = Some(64); | ||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); | ||
base.stack_probes = StackProbeType::Inline; | ||
|
||
Target { | ||
llvm_target: "x86_64-unknown-managarm-mlibc".to_string().into(), | ||
pointer_width: 64, | ||
data_layout: | ||
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" | ||
.to_string() | ||
.into(), | ||
arch: "x86_64".to_string().into(), | ||
options: base, | ||
metadata: TargetMetadata { std: Some(false), tier: Some(3), ..Default::default() }, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# `*-unknown-managarm-mlibc` | ||
|
||
**Tier: 3** | ||
|
||
## Target Maintainers | ||
|
||
- [@no92](https://github.com/no92) | ||
- [@64](https://github.com/64) | ||
- [@Dennisbonke](https://github.com/Dennisbonke) | ||
|
||
## Requirements | ||
|
||
This target is cross-compiled. There is currently no support for `std` yet. It generates binaries in the ELF format. | ||
|
||
## Building the target | ||
|
||
For now, building a patched LLVM with [our patches located here](https://github.com/managarm/bootstrap-managarm/tree/master/patches/llvm) is necessary. | ||
|
||
Once that is done, set up your `config.toml` like this: | ||
|
||
```toml | ||
change-id = 102579 | ||
|
||
[llvm] | ||
targets = "X86" | ||
download-ci-llvm = false | ||
|
||
[build] | ||
target = ["x86_64-unknown-managarm-mlibc", "x86_64-unknown-linux-gnu"] | ||
|
||
[target.x86_64-unknown-linux-gnu] | ||
llvm-config = "/path/to/your/llvm/bin/llvm-config" | ||
|
||
[target.x86_64-unknown-managarm-mlibc] | ||
llvm-config = "/path/to/your/llvm/bin/llvm-config" | ||
``` | ||
|
||
## Building Rust programs | ||
|
||
Build a `x86_64-managarm-gcc` using our [gcc fork](https://github.com/managarm/gcc). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does lld not work for this target? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
|
||
```toml | ||
[build] | ||
rustc = "/path/to/the/rust-prefix/bin/rustc" | ||
target = "x86_64-unknown-managarm-mlibc" | ||
|
||
[target.x86_64-unknown-managarm-mlibc] | ||
linker = "/path/to/the/managarm-gcc/bin/x86_64-managarm-gcc" | ||
``` | ||
|
||
## Testing | ||
|
||
This target does not support running the Rust testsuite yet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wesleywiser do we have any other targets which need a patched LLVM? I think we might want this to wait for support to exist in LLVM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any other targets currently need a patched LLVM to build (of course, newer LLVMs might work better). If I remember correctly, the loongarch targets waited until we had updated to a version of LLVM with sufficient support to link
libcore
before being merged.@no92 is there urgency to land this PR now or can we wait until an LLVM release picks up support for managarm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no urgency, so we're happy to merge our changes into LLVM first if that makes more sense.
But it would be nice if we could get this merged fairly soon after our changes hit LLVM master, because it blocks us upstreaming our changes to other Rust crates, and that's the bulk of the maintenance effort on our end: supporting locally patched crates (and sometimes multiple versions thereof!) has proved quite tricky to manage
Anyway, we'll check back once our LLVM changes are merged and see how people feel :)