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

Auto-detection of RV32E #17

Open
lrettig opened this issue Jun 8, 2024 · 0 comments
Open

Auto-detection of RV32E #17

lrettig opened this issue Jun 8, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@lrettig
Copy link
Contributor

lrettig commented Jun 8, 2024

If we're ever going to support both riscv32e and riscv32i, it would be helpful to remove the hardcoded rv32e feature flag added in #15 and make this detection automatic instead. See #1 (comment).

I don't think it's possible to do this using plain compiler directives. They're not granular enough to distinguish between the two; both show up as target_arch = riscv32. However auto-detection could be done in a build script based on the target:

build.rs:

use std::env;

fn main() {
    // Example: Check an environment variable to determine if we're targeting `riscv32e`
    let target = env::var("TARGET").unwrap_or_default();
    if target.contains("riscv32e") {
        println!("cargo:rustc-cfg=feature=\"riscv32e\"");
    }
}

inline:

#![cfg_attr(feature = "riscv32e", allow(dead_code))]

#[cfg(feature = "riscv32e")]
fn riscv32e_specific_function() {
    // Implementation for riscv32e
}
@lrettig lrettig added the help wanted Extra attention is needed label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant