Skip to content

Support for custom targets #770

Closed
Closed

Description

@davidskidmore

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.

Activity

  1. hlopko commented on Jun 23, 2021

    @hlopko
    Member

    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?

  2. davidskidmore commented on Jun 23, 2021

    @davidskidmore
    ContributorAuthor

    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.

  3. davidskidmore commented on Jul 14, 2021

    @davidskidmore
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions