Code Monkey home page Code Monkey logo

bazel-rust-docker-example's People

Contributors

nickdecooman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

quentinperez

bazel-rust-docker-example's Issues

Rust macros fail to cross-compile

When a crate contains Rust macros, cross-compiling the target from MacOS to Linux fails. An example is the postgres crate.

bazel build //cargo:postgres --platforms //build/platform:musl

can't find crate for futures_macro
--> external/raze__futures_util__0_3_19/src/async_await/stream_select_mod.rs:6:9
|
6 | pub use futures_macro::stream_select_internal;
| ^^^^^^^^^^^^^ can't find crate
|
= note: extern location for futures_macro is of an unknown type: bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/raze__futures_macro__0_3_19/libfutures_macro-152066848.dylib
= help: file name should be lib*.rlib or lib*..so

The error is caused because, for the futures_macro crate, a .dylib file was generated instead of a .rlib (or .so?) file.

The issue also occurs when I write my own macros and use the rust_proc_macro Bazel rule.

Let's say I have this src/lib.rs

use proc_macro::TokenStream;

#[proc_macro_derive(HelloWorld)]
pub fn hello_world(_input: TokenStream) -> TokenStream {
    TokenStream::new()
}

and BUILD.bazel like this:

load("@rules_rust//rust:defs.bzl", "rust_proc_macro")

rust_proc_macro(
    name = "macro",
    srcs = [
        "src/lib.rs",
    ],
    edition = "2018",
)

Running bazel build //:macro now builds a valid .dylib file. However, bazel build //:macro --platforms //build/platform:musl fails with the following error:

note: /usr/local/bin/x86_64-linux-musl-ld: cannot find -lgcc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.