-
Notifications
You must be signed in to change notification settings - Fork 402
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
Custom toolchain fails if stdlib is not coupled to compiler #213
Comments
iirc rustc by default finds its shared libraries and the stdlib based on
directory structure, don't know off hand how to change that. I
think @acmcarther has come across this / it might be mentioned in an issue
for cross compilation.
…On Sun, Apr 7, 2019 at 11:54 PM Rafael Marinheiro ***@***.***> wrote:
I'm trying to create a custom toolchain in which the compiler and the
stdlib are in separate repositories. I'm trying to do this to make bazel
download only the pieces I want.
An example toolchain definition looks as follows (note that rust_lib comes
from a different repo):
rust_toolchain(
name = "rust-toolchain-x86_64-unknown-linux-gnu-to-x86_64-unknown-linux-gnu-impl",
rust_doc = ***@***.***_1.33.0_x86_64-unknown-linux-gnu//:rustdoc",
rust_lib = ***@***.***_std_1.33.0_x86_64-unknown-linux-gnu//:rust_lib",
rustc = ***@***.***_1.33.0_x86_64-unknown-linux-gnu//:rustc",
rustc_lib = ***@***.***_1.33.0_x86_64-unknown-linux-gnu//:rustc_lib",
staticlib_ext = ".a",
dylib_ext = ".so",
os = "linux",
exec_triple = "x86_64-unknown-linux-gnu",
target_triple = "x86_64-unknown-linux-gnu",
visibility = ["//visibility:public"],
)
toolchain(
name = "rust-toolchain-x86_64-unknown-linux-gnu-to-x86_64-unknown-linux-gnu",
exec_compatible_with = ***@***.***_tools//platforms:linux", ***@***.***_tools//platforms:x86_64"],
target_compatible_with = ***@***.***_tools//platforms:linux", ***@***.***_tools//platforms:x86_64"],
toolchain = "rust-toolchain-x86_64-unknown-linux-gnu-to-x86_64-unknown-linux-gnu-impl",
toolchain_type = ***@***.***_bazel_rules_rust//rust:toolchain",
)
In this case both the compiler and the library are targeting the same
platform. When I try to compile a hello world I get the following error:
$ bazel build -s //hello:hello
INFO: Analysed target //hello:hello (13 packages loaded, 230 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //hello:hello [action 'Compiling Rust bin hello (1 files)']
(cd /home/marinheiro/.cache/bazel/_bazel_marinheiro/d06419e7e664fd9ccf9c83b04640a470/execroot/testing && \
exec env - \
CARGO_PKG_AUTHORS='' \
CARGO_PKG_DESCRIPTION='' \
CARGO_PKG_HOMEPAGE='' \
CARGO_PKG_NAME=hello \
CARGO_PKG_VERSION=0.0.0 \
CARGO_PKG_VERSION_MAJOR=0 \
CARGO_PKG_VERSION_MINOR=0 \
CARGO_PKG_VERSION_PATCH=0 \
CARGO_PKG_VERSION_PRE='' \
/bin/bash -c 'external/rustc_1.33.0_x86_64-unknown-linux-gnu/bin/rustc "$@" --remap-path-prefix="$(pwd)"=__bazel_redacted_pwd' '' hello/hello.rs '--crate-name=hello' '--crate-type=bin' '--codegen=metadata=' '--out-dir=bazel-out/k8-fastbuild/bin/hello' '--codegen=extra-filename=' '--codegen=opt-level=0' '--codegen=debuginfo=0' '--emit=dep-info,link' '--color=always' '--target=x86_64-unknown-linux-gnu' '--codegen=linker=/usr/bin/gcc' --codegen 'link-args=-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -pass-exit-codes -lstdc++ -lm')
ERROR: /home/marinheiro/Code/embedded/hello/BUILD:6:1: error executing shell command: '/bin/bash -c external/rustc_1.33.0_x86_64-unknown-linux-gnu/bin/rustc "$@" --remap-path-prefix="$(pwd)"=__bazel_redacted_pwd hello/hello.rs --crate-name=hello --crate-t
ype=bin --codegen=metadata= ...' failed (Exit 1) bash failed: error executing command /bin/bash -c 'external/rustc_1.33.0_x86_64-unknown-linux-gnu/bin/rustc "$@" --remap-path-prefix="$(pwd)"=__bazel_redacted_pwd' '' hello/hello.rs '--crate-name=hello' '--crate-type=bin' ... (remaining 11 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
error[E0463]: can't find crate for `std`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
Target //hello:hello failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.246s, Critical Path: 0.08s
INFO: 0 processes.
FAILED: Build did NOT complete successfull
From the output it looks like the generated command does not add the
stdlib to the linker search path. Looking through the code it seems that it
simply ignores that. Fixing it could be as simple as simply adding the -L
flag to the generated command. I have not tried that yet, though.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#213>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACLjeJYdtMACDKXY35ebGG00oda9tEXOks5ver1cgaJpZM4chPrd>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to create a custom toolchain in which the compiler and the stdlib are in separate repositories. I'm trying to do this to make bazel download only the pieces I want.
An example toolchain definition looks as follows (note that rust_lib comes from a different repo):
In this case both the compiler and the library are targeting the same platform. When I try to compile a hello world I get the following error:
From the output it looks like the generated command does not add the stdlib to the linker search path. Looking through the code it seems that it simply ignores that. Fixing it could be as simple as simply adding the -L flag to the generated command. I have not tried that yet, though.
The text was updated successfully, but these errors were encountered: