Open nikclayton-dfinity opened 3 years ago
https://developer.apple.com/documentation/xcode-release-notes/xcode-10-release-notes?preferredLanguage=occ suggests that on recent OSX libstd++ is no longer supported and libc++ should be used instead.
https://github.com/bazelbuild/rules_rust/issues/226 is probably the real bug here.
Add this to the bottom of the WORKSPACE
file:
# Everything below here is key to building on OSX. Load a custom Clang
# toolchain rather than whatever happens to be installed on the machine.
#
# The entry in .bazelrc automatically selects this toolchain for building.
http_archive(
name = "com_grail_bazel_toolchain",
url = "https://github.com/grailbio/bazel-toolchain/archive/0.5.6.zip",
sha256 = "759e6c10e7883b5969db01b5bdb01c5518bcf7ae637972d5a109eb994a669487",
strip_prefix = "bazel-toolchain-0.5.6",
)
load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")
bazel_toolchain_dependencies()
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
llvm_toolchain(
name = "llvm_toolchain",
absolute_paths = True,
llvm_version = "9.0.0",
)
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
llvm_register_toolchains()
and create .bazelrc
in the same directory as the WORKSPACE
file with the following contents:
build --crosstool_top=@llvm_toolchain//:toolchain
Then everything works for the no_deps
example.
complicated_cargo_library
also works.
non_cratesio
doesn't.
It builds, but running it produces no output.
% cd examples/remote/non_cratesio
% cargo raze
% bazel build :non_cratesio_remote
INFO: Analyzed target //remote/non_cratesio:non_cratesio_remote (44 packages loaded, 563 targets configured).
INFO: Found 1 target...
Target //remote/non_cratesio:non_cratesio_remote up-to-date:
bazel-bin/remote/non_cratesio/non_cratesio_remote
INFO: Elapsed time: 8.716s, Critical Path: 8.37s
INFO: 28 processes: 5 internal, 23 darwin-sandbox.
INFO: Build completed successfully, 28 total actions
% RUST_LOG=info bazel run :non_cratesio_remote
INFO: Analyzed target //remote/non_cratesio:non_cratesio_remote (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //remote/non_cratesio:non_cratesio_remote up-to-date:
bazel-bin/remote/non_cratesio/non_cratesio_remote
INFO: Elapsed time: 0.091s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
However, running it with Cargo has the same problem:
% RUST_LOG=info cargo run
warning: unused manifest key: raze
Compiling compile_with_bazel v0.1.0 (/Users/nik/github/cargo-raze/examples/remote/non_cratesio)
Finished dev [unoptimized + debuginfo] target(s) in 0.73s
Running `target/debug/non_cratesio`
so I'm not sure what's going on there.
Without digging too deeply, is this a bug in cargo-raze
or in rules_rust
? (as per https://github.com/google/cargo-raze/issues/247#issuecomment-707796112)
The primary bug is in rules_rust
.
I think there's probably two bugs in the cargo-raze
examples.
WORKSPACE
file.The most version I have of those additions is:
http_archive(
name = "com_grail_bazel_toolchain",
url = "https://github.com/grailbio/bazel-toolchain/archive/0.5.6.zip",
sha256 = "759e6c10e7883b5969db01b5bdb01c5518bcf7ae637972d5a109eb994a669487",
strip_prefix = "bazel-toolchain-0.5.6",
)
load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")
bazel_toolchain_dependencies()
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
llvm_toolchain(
name = "llvm_toolchain",
absolute_paths = True,
llvm_version = "10.0.0",
)
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
llvm_register_toolchains()
non_cratesio
producing no output irrespective of how it's built (https://github.com/google/cargo-raze/issues/247#issuecomment-708230957).1. They don't work out of the box on macOS, you need to do [bazelbuild/rules_rust#226 (comment)](https://github.com/bazelbuild/rules_rust/issues/226#issuecomment-626378800) in the `WORKSPACE` file.
Odd, I'm able to build the examples on MacOS just fine. Perhaps the rust rules are relying on some specific machine setup. It might be good to open a pull request to rules_rust
making it's tooling more explicit so users see consistent behavior regardless of how their machines are configured (if that is indeed the case here).
2. `non_cratesio` producing no output irrespective of how it's built ([#247 (comment)](https://github.com/google/cargo-raze/issues/247#issuecomment-708230957)).
Interesting, seems to me like env_logger
wasn't setup correctly? It does seem to be though. From some quick tests it doesn't seem like the logger is initializing to log Info
level logs. Adding the following always panics
if !log_enabled!(log::Level::Info) {
panic!("uh-oh");
}
This should definitely be looked at and updated. I may take a stab at it when I can find the time.
Sorry this isn't much help. But it's good to know where the issue is. You should chime in on https://github.com/bazelbuild/rules_rust/issues/226 and let the owners know users are still running into that issue 😄
For folks experiencing ld: library not found for -lstdc++
, this is a bug in bazel I've submitted a patch for, for more details see https://github.com/bazelbuild/bazel/issues/14395#issuecomment-1009490593
with the landing of bazelbuild/bazel#14750 I believe this issue can be closed
Building a fresh checkout of
examples/remote/no_deps
with Bazel 3.6.0 fails on MacOS with the error:Reproduction recipe:
cargo-raze
repository.