-
-
Notifications
You must be signed in to change notification settings - Fork 6
Add Library API #4
Comments
Yeah thats fine |
Do these changes work? |
I'm going to try to build a proof of concept with it over the next couple of days, but it looks good to me just reviewing the code. |
So one thing I don't understand in the current API, is why does Lines 62 to 66 in 4a0c48b
|
Another thing is that this currently builds every sysroot crate, but right now |
|
Allows controling which sysroot crates to build. No longer automatically inherits profile overrides. Part of the rust-gpu effort re: #4
With this, testing seems to have worked!! Woo! Part of #4
Okay, hows it look now? The Theres no option for compiler_builtins itself because, besides core, everything else depends on it. For core it simply isn't included at all, but I can change that if need be. |
Thank you so much for working on this! The API is much improved.
That would be great, as it seems that those compiler_builtins are required for core, even if they aren't built. At least trying to build a module with just core available in the sysroot provides a Build env::set_var("RUSTFLAGS", format!("-Zcodegen-backend={}", path_to_backend.display()));
let sysroot = cargo_sysroot::build_sysroot_with(
None,
&target_dir,
"spirv-unknown-unknown".as_ref(),
&src,
cargo_sysroot::Sysroot::Core,
false,
).map_err(|e| eyre!("Error building sysroot: {}", e))?;
env::remove_var("RUSTFLAGS"); Command
lib.rs #![feature(lang_items)]
#![no_std]
#![feature(register_attr)]
#![register_attr(spirv)]
#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
loop {}
}
#[lang = "eh_personality"]
extern "C" fn rust_eh_personality() {}
#[spirv(vertex)]
pub fn main() {
} |
Thats odd, I wonder whats requiring it, I thought missing compiler_builtins usually caused linker errors. I tried to reproduce it and couldn't, though using a different target. May be specific to your target? In light of that, instead of making Core bring in compiler_builtins, I've added |
compiler_builtins itself depends on core, so it doesn't need to be listed here too. Also, the rustc-dep-of-std and mem features were accidentally left out. Part of #4
Thank you so much again for working on this! I've now managed to create a working prototype that builds the |
Can you elaborate on setting rustc flags? Why do you need to build in two steps right now? As for a builder-style interface, I can add that |
Sure, here's the relevant code. fn rust_flags(backend: &Path, sysroot: Option<&Path>) -> String {
use std::fmt::Write;
let mut buf = String::new();
let _ = write!(&mut buf, "-Zcodegen-backend={}", backend.display());
if let Some(sysroot) = sysroot {
let _ = write!(&mut buf, " --sysroot={}", sysroot.display());
}
buf
}
// Build core without `--sysroot`
env::set_var("RUSTFLAGS", rust_flags(&backend, None));
let sysroot = cargo_sysroot::build_sysroot_with(
None,
&target_dir,
TARGET_NAME.as_ref(),
&src,
cargo_sysroot::Sysroot::Core,
false,
).map_err(|e| eyre!("{}", e))?;
// Build compiler_builtins with `spirv_unknown_unknown` sysroot
env::set_var("RUSTFLAGS", rust_flags(&backend, Some(&sysroot)));
let sysroot = cargo_sysroot::build_sysroot_with(
None,
&target_dir,
TARGET_NAME.as_ref(),
&src,
cargo_sysroot::Sysroot::CompilerBuiltins,
false,
).map_err(|e| eyre!("{}", e))?;
env::remove_var("RUSTFLAGS"); |
I'm more confused. Why are you building core explicitly? |
Apparently, because if I comment out the second one and change
|
Well, that shouldn't happen.. I'll see whats causing that |
Should fix compiler_builtins missing core. Part of #4
Okay, that should fix it. Thats embarrassing. A simple mixed conditional. |
Should help prevent more silly errors like with #4
I'm now getting a
|
Thats.. never happened before. No idea how to reproduce that. Is that the entire error message? It's not supposed to be.. |
Don't think I can do anything about this without more details on the error, so the above commit should help with that. Maybe it's something apple specific? But I have no way to test that.. Maybe Rust changed some layouts? What nightly are you on? I'm on |
Hmm but wait, it worked for you before didnt it? But I shouldn't have changed anything that could break it.. |
Not seeing anything that could've affected it between 2adf1bd and now.. |
It is the full error, I'll try some different nightlies on my end and get back to you.
|
Thats.. extremely odd. Are you using the latest master, b8b0c4d added some more context hopefully to improve it |
Okay it seems |
Actually I found the issue. If I have a |
Oh great! With that I should be able to reproduce and fix it to.. not fail. |
Should be far more reliable now, using rustc --print target-libdir to get the host target triple. Part of #4
And with the above commit, it should be fixed. |
Added a builder API in 9d61d0b, including the ability to set rustc flags. |
Passing them on the command-line only passes to *final* compiler call. Rather essential fix for #4
@DianaNites Thank you again for all this work! It's very stable now, would you be up for releasing this version on crates.io? |
I can do a crates.io release, yeah! But what about #6? |
Published as v0.8.0 |
Great, the library API itself is still good, and for now we can just not run clippy on those examples in my PR. We can track progress in more specific issues. |
Hello, I'm working on EmbarkStudios/rust-gpu and we're currently looking at how we can build our own sysroot as part of our build process (EmbarkStudios/rust-gpu#48). Cargo's
-Zbuild-std
is currently not sufficient for us, as we want to be able to re-use the sysroot both for development and across multiple tests. Using cargo's-Zbuild-std
either requires locking dependencies, redundantly compiling sysroot multiple times, or generate a complicated setup for tests so that they can re-use libcore. Ideally we'd like to just compile it once and re-use it throughout the build.While investigating what was already available in this space I came across your crate, and found that it mostly does what we need for the project except for generating a
.cargo/config.toml
and being only available as a binary tool. Would you be interested in adding alib.rs
that allows a user to just build the sysroot? I would be willing to contribute the work for the change.The text was updated successfully, but these errors were encountered: