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

fix: Add rustc dylib directory to compile action search paths #356

Closed
wants to merge 3 commits into from

Conversation

Arm1stice
Copy link
Contributor

Currently, the library paths for rustc are not included as search paths during compile time. These paths include libLLVM, which are necessary when building crates that use the rustc_private crates

Copy link
Collaborator

@damienmg damienmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if that would be feasible but that would be great to add an examples that would not work without that change. Could you do that or are those too complicated examples?

@Arm1stice
Copy link
Contributor Author

Arm1stice commented Jun 29, 2020

I made a repo that recreates the bug. The WORKSPACE in the repo contains both the master branch of rules_rust (commented out) and my PR (not commented out) so that you can switch between the two. The current master will fail to build the target :rust_example, but my PR successfully builds. https://github.com/Arm1stice/rules_rust_bug_example

@damienmg
Copy link
Collaborator

I think the bug would just repro if you would copy the main.rs and your build file in a subfolder for example, mind doing that so we have a non-regression test along?

@Arm1stice
Copy link
Contributor Author

Makes sense. I went ahead and created a new example in the examples folder. Because this example requires nightly Rust and the rustc_dev component, I also updated the rust_repository call in the examples WORKSPACE

@damienmg
Copy link
Collaborator

Now it fails on buildkite:

  | error[E0463]: can't find crate for `log` which `rustc_driver` depends on
  | --> external/examples/hello_rustc_private/main.rs:3:1
  | \|
  | 3 \| extern crate rustc_driver;
  | \| ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
  |  
  | error: aborting due to previous error

@Arm1stice
Copy link
Contributor Author

Looks like, even though external/rust_linux_x86_64/lib is included as a search path in the rustc command for the wasm target, when rustc calls the rust-lld linker, it doesn't include external/rust_linux_x86_64/lib in the linker search paths, causing the linker to fail. This error message is the same that I was getting when attempting to build binaries before, and was the basis for this PR. I wonder why the fix doesn't work for wasm?

@damienmg
Copy link
Collaborator

I don't really understand how WASM build works, @mfarrugi do you know?

@mfarrugi
Copy link
Collaborator

mfarrugi commented Jun 30, 2020 via email

@Arm1stice
Copy link
Contributor Author

I'll take another look in the next day or so. I definitely want to figure this out, because I'm currently blocked by the bug this fixes

@Arm1stice
Copy link
Contributor Author

Arm1stice commented Jul 1, 2020

So if I change the date for the nightly rust to iso_date = "2020-04-21" rather than 2020-06-23, it builds fine. Apparently newer nightlies change something that is making this process break?

EDIT:
2020-04-21 has libLLVM-9-rust-1.44.0-nightly.so while 2020-06-23 has libLLVM-10-rust-1.46.0-nightly.so

2020-05-30 also fails to build and has libLLVM-10-rust-1.45.0-nightly.so

Info so far:
Something happened between the libLLVM-9 and libLLVM-10 change. Current rules_rust master branch can build my example repo above using 2020-04-21 (libLLVM-9) but fails on 1.45 and above nightly builds that use libLLVM-10. Likewise, the WASM example builds fine on 2020-04-21 but fails on newer nightlies. My PR fixes the issue for the new example I added, but the WASM linker is still unable to find the libLLVM-10 dynamic library, even though the folder is included in the search paths passed to rust-lld

@Arm1stice
Copy link
Contributor Author

Arm1stice commented Jul 1, 2020

This actually might be caused by rust-lang/rust#70838

@Arm1stice
Copy link
Contributor Author

Closing this PR because it didn't fix the underlying issue. Please see #365 for the actual fix

@Arm1stice Arm1stice closed this Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants