pub struct RiscvTarget { /* private fields */ }Expand description
Struct that represents a RISC-V target.
Implementations§
Source§impl RiscvTarget
impl RiscvTarget
Sourcepub fn build<'a>(
target: &'a str,
cargo_flags: &'a str,
) -> Result<Self, Error<'a>>
pub fn build<'a>( target: &'a str, cargo_flags: &'a str, ) -> Result<Self, Error<'a>>
Builds a RISC-V target from a target triple and cargo flags. This function is expected to be called from a build script.
The target triple is expected to be in the form riscv{width}{extensions}-vendor-os[-bin].
If the target triple is invalid, an error is returned.
§Example
// In build.rs
let target = std::env::var("TARGET").unwrap();
let cargo_flags = std::env::var("CARGO_ENCODED_RUSTFLAGS").unwrap();
let target = riscv_target_parser::RiscvTarget::build(&target, &cargo_flags).unwrap(); // This will panic if the target is invalidSourcepub fn rustc_flags(&self) -> Vec<String>
pub fn rustc_flags(&self) -> Vec<String>
Returns a list of flags to pass to rustc for the given RISC-V target.
This function is expected to be called from a build script.
§Example
let target = std::env::var("TARGET").unwrap();
let cargo_flags = std::env::var("CARGO_ENCODED_RUSTFLAGS").unwrap();
let target = riscv_target_parser::RiscvTarget::build(&target, &cargo_flags).unwrap();
for flag in target.rustc_flags() {
println!("cargo:rustc-check-cfg=cfg({})", flag);
println!("cargo:rustc-cfg={}", flag);
}Sourcepub fn llvm_base_isa(&self) -> String
pub fn llvm_base_isa(&self) -> String
Returns the LLVM base ISA for the given RISC-V target.
Sourcepub fn llvm_arch_patch(&self) -> String
pub fn llvm_arch_patch(&self) -> String
Sourcepub fn base_extension(&self) -> Option<Extension>
pub fn base_extension(&self) -> Option<Extension>
Returns the base extension of the RISC-V architecture (if any).
Trait Implementations§
Source§impl Clone for RiscvTarget
impl Clone for RiscvTarget
Source§fn clone(&self) -> RiscvTarget
fn clone(&self) -> RiscvTarget
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RiscvTarget
impl Debug for RiscvTarget
Source§impl PartialEq for RiscvTarget
impl PartialEq for RiscvTarget
Source§impl<'a> TryFrom<TargetTriple<'a>> for RiscvTarget
impl<'a> TryFrom<TargetTriple<'a>> for RiscvTarget
impl Eq for RiscvTarget
impl StructuralPartialEq for RiscvTarget
Auto Trait Implementations§
impl Freeze for RiscvTarget
impl RefUnwindSafe for RiscvTarget
impl Send for RiscvTarget
impl Sync for RiscvTarget
impl Unpin for RiscvTarget
impl UnwindSafe for RiscvTarget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more