-
Notifications
You must be signed in to change notification settings - Fork 138
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
Cannot find linker script memory.x: cargo workspaces #461
Comments
Moving memory.x to the workspace root does work, but that of course isn't doable when you have >1 target within a workspace |
The usual thing is a I guess you could also just put the crate path into the linker search path too, |
I had the same issue: I created a Cargo workspace with several binary and library packages and the linker was unable to find the As @adamgreig pointed out, I created a use std::{env, error::Error, fs::File, io::prelude::Write, path::PathBuf};
fn main() -> Result<(), Box<dyn Error>> {
// Make `memory.x` available to the linker.
let out_dir = env::var("OUT_DIR")?;
let out_dir = PathBuf::from(out_dir);
let memory_x = include_bytes!("memory.x").as_ref();
File::create(out_dir.join("memory.x"))?.write_all(memory_x)?;
// Tell Cargo where to find the file.
println!("cargo:rustc-link-search={}", out_dir.display());
// Tell Cargo to rebuild if `memory.x` is updated.
println!("cargo:rerun-if-changed=memory.x");
Ok(())
} This solved the problem for me. |
Hello all,
Does anyone have a workaround for the following error:
that arises when compiling packages within workspaces?
I've tried a few things like adding
println!("cargo:rustc-link-arg=-T{}/memory.x", env!("CARGO_MANIFEST_DIR"));
to my build.rs, but nothing has worked so far.Whatever the solution is, it would likely be good to document it somewhere
The text was updated successfully, but these errors were encountered: