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

Add support for our temporary target #68

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/compiler/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@
//! translation—the benefits of not having to manually perform this additional
//! work far outweighs that downside. If we _do_ need any additional control, we
//! can always modify this process at a later date.

#[cfg(test)]
mod test {}
14 changes: 3 additions & 11 deletions crates/rust-test-input/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
#![no_std]

/// Adds two numbers together.
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
iamrecursion marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions docs/Getting LLVM IR Output.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ this project.
## Rust

`rustc` will emit LLVM IR when passed the `--emit=llvm-ir` flag, and LLVM bytecode when passed the
`--emit=llvm-bc`. This will output `.ll` files into the `target` directory corresponding to your
compiled file. For more information, see the
[`rustc` developer guide](https://rustc-dev-guide.rust-lang.org/backend/debugging.html).
`--emit=llvm-bc`. This will output `.ll` (or `.bc`) files into the `target` directory corresponding
to your compiled file (usually in `build-type/deps/crate-name-hash.ll`). For more information, see
the [`rustc` developer guide](https://rustc-dev-guide.rust-lang.org/backend/debugging.html).

- This can be passed to the correct compiler when using cargo by calling
`cargo rustc -- --emit=llvm-ir`.
Expand Down
12 changes: 10 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@
flake-utils.lib.eachDefaultSystem (system:
let
# We grab our expected rust version from the Cargo.toml.
rustVersion = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.rust-version;
rustVersion = (lib.importTOML ./Cargo.toml).workspace.package.rust-version;

# Then we set up our libraries for building this thing.
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
fenixLib = fenix.packages.${system};
toolchainHash = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
fenixStable = fenixLib.fromToolchainName {
name = rustVersion;
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
sha256 = toolchainHash;
};

# A target of the same version for our temporary "source" ABI
fenixAarch64 = fenixLib.targets.aarch64-unknown-none-softfloat.toolchainOf {
channel = rustVersion;
sha256 = toolchainHash;
};

# As we want nightly Rustfmt, we have to build a custom toolchain.
Expand All @@ -40,6 +47,7 @@
"rust-std"
"rustc"
])
fenixAarch64.rust-std
];

# The crane library configures the Rust toolchain, along with the components we expect it
Expand Down
Loading