-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Support for Fuchsia RISC-V target #108722
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
These commits modify compiler targets. |
de1bcef
to
7b848bc
Compare
This comment has been minimized.
This comment has been minimized.
Fuchsia is in the process of implementing the RISC-V support. This change implements the minimal Rust compiler support. The support for building runtime libraries will be implemented in follow up changes once Fuchsia SDK has the RISC-V support.
I'll fill out the Tier 3 target policy here as per these instructions:
The existing rust fuchsia team will maintain this target along with the existing aarch64 and x86_64 fuchsia targets.
Understood.
Understood.
Understood.
I'm not sure whether they fall into this category but
To my knowledge all tools required to build for fuchsia are permissively licensed. The Fuchsia licensing policy states that development tools should all be FOSS licensed.
@tmandry is the only Fuchsia target maintainer that's on another Rust team (lang) and he won't be approving target-tier decisions for this target.
There is existing std support for Fuchsia targets and this riscv target should be able to share almost all of that code.
We'll make a followup change in to the Fuchsia-support docs soon. The process of building and running tests should be very similar to the existing Fuchsia targets.
Understood.
We'll make sure that any changes to Fuchsia-specific code in std or elsewhere don't introduce breakages in any of the Fuchsia targets. Ditto for other riscv targets. |
r? compiler-team |
@bors r+ rollup |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#108722 (Support for Fuchsia RISC-V target) - rust-lang#108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests) - rust-lang#108909 (Fix object safety checks for new RPITITs) - rust-lang#108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics) - rust-lang#108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty) - rust-lang#109101 (Fall back to old metadata computation when type references errors) - rust-lang#109105 (Don't ICE for late-bound consts across `AnonConstBoundary`) - rust-lang#109110 (Don't codegen impossible to satisfy impls) - rust-lang#109116 (Emit diagnostic when calling methods on the unit type in method chains) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…arget, r=tmandry Fix riscv64 fuchsia LLVM target name Currently, riscv64gc-unknown-fuchsia (added in rust-lang#108722) sets riscv64*gc*-unknown-fuchsia as the LLVM target. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs#L5 However, riscv64*gc*-\* is not a valid LLVM target and causes the following error. ```console $ rustc --print cfg --target riscv64gc-unknown-fuchsia error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` As with other RISC-V targets, the LLVM target should use riscv64-\*, not riscv64*gc*-\*. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs#L5 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs#L5 I confirmed that riscv64-unknown-fuchsia is recognized as a valid LLVM target by using custom targets. ```console # create a custom target with `"llvm-target": "riscv64-unknown-fuchsia" from no-std riscv64gc target. $ rustc --print target-spec-json -Z unstable-options --target riscv64gc-unknown-none-elf | grep -v is-builtin | sed 's/"llvm-target".*/"llvm-target": "riscv64-unknown-fuchsia",/' > riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json debug_assertions panic="abort" target_abi="" target_arch="riscv64" target_endian="little" target_env="" target_feature="a" target_feature="c" target_feature="d" target_feature="f" target_feature="m" ... $ cat riscv64gc-unknown-fuchsia.json { "arch": "riscv64", "code-model": "medium", "cpu": "generic-rv64", "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128", "eh-frame-header": false, "emit-debug-gdb-scripts": false, "features": "+m,+a,+f,+d,+c", "linker": "rust-lld", "linker-flavor": "ld.lld", "llvm-abiname": "lp64d", "llvm-target": "riscv64-unknown-fuchsia", "max-atomic-width": 64, "panic-strategy": "abort", "relocation-model": "static", "supported-sanitizers": [ "kernel-address" ], "target-pointer-width": "64" } # Check the current master's LLVM target name causes an error $ sed -i 's/riscv64-unknown-fuchsia/riscv64gc-unknown-fuchsia/' riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` r? `@tmandry`
…arget, r=tmandry Fix riscv64 fuchsia LLVM target name Currently, riscv64gc-unknown-fuchsia (added in rust-lang#108722) sets riscv64*gc*-unknown-fuchsia as the LLVM target. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs#L5 However, riscv64*gc*-\* is not a valid LLVM target and causes the following error. ```console $ rustc --print cfg --target riscv64gc-unknown-fuchsia error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` As with other RISC-V targets, the LLVM target should use riscv64-\*, not riscv64*gc*-\*. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs#L5 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs#L5 I confirmed that riscv64-unknown-fuchsia is recognized as a valid LLVM target by using custom targets. ```console # create a custom target with `"llvm-target": "riscv64-unknown-fuchsia" from no-std riscv64gc target. $ rustc --print target-spec-json -Z unstable-options --target riscv64gc-unknown-none-elf | grep -v is-builtin | sed 's/"llvm-target".*/"llvm-target": "riscv64-unknown-fuchsia",/' > riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json debug_assertions panic="abort" target_abi="" target_arch="riscv64" target_endian="little" target_env="" target_feature="a" target_feature="c" target_feature="d" target_feature="f" target_feature="m" ... $ cat riscv64gc-unknown-fuchsia.json { "arch": "riscv64", "code-model": "medium", "cpu": "generic-rv64", "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128", "eh-frame-header": false, "emit-debug-gdb-scripts": false, "features": "+m,+a,+f,+d,+c", "linker": "rust-lld", "linker-flavor": "ld.lld", "llvm-abiname": "lp64d", "llvm-target": "riscv64-unknown-fuchsia", "max-atomic-width": 64, "panic-strategy": "abort", "relocation-model": "static", "supported-sanitizers": [ "kernel-address" ], "target-pointer-width": "64" } # Check the current master's LLVM target name causes an error $ sed -i 's/riscv64-unknown-fuchsia/riscv64gc-unknown-fuchsia/' riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` r? ``@tmandry``
…arget, r=tmandry Fix riscv64 fuchsia LLVM target name Currently, riscv64gc-unknown-fuchsia (added in rust-lang#108722) sets riscv64*gc*-unknown-fuchsia as the LLVM target. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs#L5 However, riscv64*gc*-\* is not a valid LLVM target and causes the following error. ```console $ rustc --print cfg --target riscv64gc-unknown-fuchsia error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` As with other RISC-V targets, the LLVM target should use riscv64-\*, not riscv64*gc*-\*. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs#L5 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs#L5 I confirmed that riscv64-unknown-fuchsia is recognized as a valid LLVM target by using custom targets. ```console # create a custom target with `"llvm-target": "riscv64-unknown-fuchsia" from no-std riscv64gc target. $ rustc --print target-spec-json -Z unstable-options --target riscv64gc-unknown-none-elf | grep -v is-builtin | sed 's/"llvm-target".*/"llvm-target": "riscv64-unknown-fuchsia",/' > riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json debug_assertions panic="abort" target_abi="" target_arch="riscv64" target_endian="little" target_env="" target_feature="a" target_feature="c" target_feature="d" target_feature="f" target_feature="m" ... $ cat riscv64gc-unknown-fuchsia.json { "arch": "riscv64", "code-model": "medium", "cpu": "generic-rv64", "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128", "eh-frame-header": false, "emit-debug-gdb-scripts": false, "features": "+m,+a,+f,+d,+c", "linker": "rust-lld", "linker-flavor": "ld.lld", "llvm-abiname": "lp64d", "llvm-target": "riscv64-unknown-fuchsia", "max-atomic-width": 64, "panic-strategy": "abort", "relocation-model": "static", "supported-sanitizers": [ "kernel-address" ], "target-pointer-width": "64" } # Check the current master's LLVM target name causes an error $ sed -i 's/riscv64-unknown-fuchsia/riscv64gc-unknown-fuchsia/' riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` r? ```@tmandry```
…arget, r=tmandry Fix riscv64 fuchsia LLVM target name Currently, riscv64gc-unknown-fuchsia (added in rust-lang#108722) sets riscv64*gc*-unknown-fuchsia as the LLVM target. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs#L5 However, riscv64*gc*-\* is not a valid LLVM target and causes the following error. ```console $ rustc --print cfg --target riscv64gc-unknown-fuchsia error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` As with other RISC-V targets, the LLVM target should use riscv64-\*, not riscv64*gc*-\*. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs#L5 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs#L5 I confirmed that riscv64-unknown-fuchsia is recognized as a valid LLVM target by using custom targets. ```console # create a custom target with `"llvm-target": "riscv64-unknown-fuchsia" from no-std riscv64gc target. $ rustc --print target-spec-json -Z unstable-options --target riscv64gc-unknown-none-elf | grep -v is-builtin | sed 's/"llvm-target".*/"llvm-target": "riscv64-unknown-fuchsia",/' > riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json debug_assertions panic="abort" target_abi="" target_arch="riscv64" target_endian="little" target_env="" target_feature="a" target_feature="c" target_feature="d" target_feature="f" target_feature="m" ... $ cat riscv64gc-unknown-fuchsia.json { "arch": "riscv64", "code-model": "medium", "cpu": "generic-rv64", "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128", "eh-frame-header": false, "emit-debug-gdb-scripts": false, "features": "+m,+a,+f,+d,+c", "linker": "rust-lld", "linker-flavor": "ld.lld", "llvm-abiname": "lp64d", "llvm-target": "riscv64-unknown-fuchsia", "max-atomic-width": 64, "panic-strategy": "abort", "relocation-model": "static", "supported-sanitizers": [ "kernel-address" ], "target-pointer-width": "64" } # Check the current master's LLVM target name causes an error $ sed -i 's/riscv64-unknown-fuchsia/riscv64gc-unknown-fuchsia/' riscv64gc-unknown-fuchsia.json $ rustc --print cfg --target riscv64gc-unknown-fuchsia.json error: could not create LLVM TargetMachine for triple: riscv64gc-unknown-fuchsia: No available targets are compatible with triple "riscv64gc-unknown-fuchsia" ``` r? ````@tmandry````
Fuchsia is in the process of implementing the RISC-V support. This change implements the minimal Rust compiler support. The support for building runtime libraries will be implemented in follow up changes once Fuchsia SDK has the RISC-V support.