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

Support for custom targets #770

Closed
davidskidmore opened this issue Jun 17, 2021 · 3 comments
Closed

Support for custom targets #770

davidskidmore opened this issue Jun 17, 2021 · 3 comments

Comments

@davidskidmore
Copy link
Contributor

I'm having difficulty using bazel with a custom target based on x86_64-unknown-linux-gnu. In theory, given a simple library:

#![no_std]

#[no_mangle]
pub extern "C" fn rust_function() {}

After bootstrapping libcore and friends I can now build the library for my new target:

rustc --crate-type=lib foo.rs --target x86_64-unknown-none.json \
  -L dependency=~/rust_libs/ \
  --extern 'noprelude:core=~/rust_libs/libcore-7363d577ba15c1d7.rmeta' \
  --extern 'noprelude:compiler_builtins=~/rust_libs/libcompiler_builtins-b774e5dde03423fb.rmeta' \
  -Z unstable-options

I'm aware of how to accomplish the cross build with cargo, but I'm not sure how to do this with bazel. There doesn't seem to be a way for me to pass my target JSON through a new rust_toolchain definition.

@hlopko
Copy link
Member

hlopko commented Jun 23, 2021

So AFAIU the request is to add a way to pass target.json to the rust_toolchain. That's quite a simple change, and I'd say not very controversial. @davidskidmore, do you want to give creating a PR a try?

@davidskidmore
Copy link
Contributor Author

I've tried hacking something together, but haven't been able to get something working that will both accept the new json as a target and successfully use my prebuilt libraries.

@davidskidmore
Copy link
Contributor Author

I have successfully built and linked my own libraries, and created #836 to show my approach in adding support for passing a custom target specification. I can't tell if this is the "right" way, so let me know if you have any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants