-
Notifications
You must be signed in to change notification settings - Fork 13.3k
native dependencies fail to link on nightly-2022-04-01 #95561
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
Comments
It passes build on MacOS, but the tests show that a global shared static variable between rust side and C side is wrong. |
It's introduced by #93901 |
I'll check what happens. |
It's actually both. Dependency orderThe build script in diff --git a/tirocks-sys/build.rs b/tirocks-sys/build.rs
index 1e1bcf7..b65f479 100644
--- a/tirocks-sys/build.rs
+++ b/tirocks-sys/build.rs
@@ -206,7 +206,7 @@ fn build_titan(build: &mut Build) {
build.include(cur_dir.join("titan"));
}
-fn build_rocksdb(build: &mut Build) {
+fn build_rocksdb(build: &mut Build) -> PathBuf {
let target = env::var("TARGET").expect("TARGET was not set");
let mut cfg = Config::new("rocksdb");
cfg.out_dir(format!("{}/rocksdb", env::var("OUT_DIR").unwrap()));
@@ -225,7 +225,6 @@ fn build_rocksdb(build: &mut Build) {
.build_target("rocksdb")
.very_verbose(true)
.build();
- figure_link_lib(&dst, "rocksdb");
if cfg!(target_os = "windows") {
build.define("OS_WIN", None);
@@ -251,6 +250,11 @@ fn build_rocksdb(build: &mut Build) {
build.define("OPENSSL", None);
}
+ dst
+}
+
+fn link_rocksdb(dst: PathBuf) {
+ figure_link_lib(&dst, "rocksdb");
println!("cargo:rustc-link-lib=static=z");
println!("cargo:rustc-link-lib=static=bz2");
println!("cargo:rustc-link-lib=static=lz4");
@@ -262,13 +266,15 @@ fn main() {
patch_libz_env();
let mut build = Build::new();
build_titan(&mut build);
- build_rocksdb(&mut build);
+ let rocksdb_dst = build_rocksdb(&mut build);
build.cpp(true).file("crocksdb/c.cc");
if !cfg!(target_os = "windows") {
build.flag("-std=c++11");
build.flag("-fno-rtti");
}
- link_cpp(&mut build);
build.warnings(false).compile("libcrocksdb.a");
+
+ link_rocksdb(rocksdb_dst);
+ link_cpp(&mut build);
}
|
I guess a topological sorting is necessary to get all dependencies order right. |
I change to the link order you suggested, but then the smoke case fails on both MacOS and Linux with the stable toolchain. Changing it to |
Fixed in #95606. |
FWIW difftastic is also affected by this: running Build log: https://github.com/Wilfred/difftastic/runs/5791227463?check_suite_focus=true |
Nightly no longer compiles difftastic due to a rust issue with linking: rust-lang/rust#95561
@Wilfred diff --git a/build.rs b/build.rs
index 4788fa6b0..977a0a518 100644
--- a/build.rs
+++ b/build.rs
@@ -22,6 +22,13 @@ impl TreeSitterParser {
}
}
+ let mut build = cc::Build::new();
+ build.include(&dir).warnings(false); // ignore unused parameter warnings
+ for file in c_files {
+ build.file(dir.join(file));
+ }
+ build.compile(self.name);
+
if !cpp_files.is_empty() {
let mut cpp_build = cc::Build::new();
cpp_build
@@ -42,13 +49,6 @@ impl TreeSitterParser {
}
cpp_build.compile(&format!("{}-cpp", self.name));
}
-
- let mut build = cc::Build::new();
- build.include(&dir).warnings(false); // ignore unused parameter warnings
- for file in c_files {
- build.file(dir.join(file));
- }
- build.compile(self.name);
}
} It doesn't involve the " |
@petrochenkov that works perfectly, huge thanks for taking a look :) Do you know why this changed on nightly? I see |
Sorry, I don't have a minimal reproduction repo. The error can be found at https://github.com/BusyJay/tirocks/runs/5784258424?check_suite_focus=true.
It doesn't seem to be able to resolve the required symbols somehow. I can verify that it compiles with the same code on nightly-2022-03-31.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: