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

cannot compile due to linker error #1411

Closed
xxchan opened this issue Nov 1, 2023 · 5 comments
Closed

cannot compile due to linker error #1411

xxchan opened this issue Nov 1, 2023 · 5 comments
Labels
C-bug Category: This is a bug.

Comments

@xxchan
Copy link

xxchan commented Nov 1, 2023

git clone https://github.com/risingwavelabs/risingwave && cd risingwave
CARGO_PROFILE_DEV_CODEGEN_BACKEND=cranelift cargo +nightly build -p risingwave_cmd_all -Zcodegen-backend

returns error:

   Compiling risingwave_cmd_all v1.3.0-alpha (/home/ubuntu/risingwave/src/cmd_all)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/ubuntu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/ubuntu/.cargo/bin:/home/ubuntu/.local/bin:~/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/ubuntu/go/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcSUh3Ay/symbols.o" "/home/ubuntu/risingwave/target/debug/deps/risingwave-0f44522398583e0a.117wr16f0zv4owp7.rcgu.o" 

... (*.rcgu.o omitted)

"-Wl,--as-needed" "-L" "/home/ubuntu/risingwave/target/debug/deps" "-L" "/home/ubuntu/risingwave/target/debug/build/ring-295e4d5a72f6c9a1/out" "-L" "/home/ubuntu/risingwave/target/debug/build/openssl-sys-4b216140687680a4/out/openssl-build/install/lib" "-L" "/home/ubuntu/risingwave/target/debug/build/rdkafka-sys-7b4c46238de0af7c/out/lib" "-L" "/home/ubuntu/risingwave/target/debug/build/sasl2-sys-ae02c4603182a808/out/install/lib" "-L" "/home/ubuntu/risingwave/target/debug/build/krb5-src-6c6ede5cad31dc32/out/install/lib" "-L" "/home/ubuntu/risingwave/target/debug/build/zstd-sys-7acade90b63de0dd/out" "-L" "/home/ubuntu/risingwave/target/debug/build/libsqlite3-sys-fd47f4cd4ea537d5/out" "-L" "/home/ubuntu/risingwave/target/debug/build/tikv-jemalloc-sys-03bc23037f6b203b/out/build/lib" "-L" "/home/ubuntu/risingwave/target/debug/build/lz4-sys-5fa5a6e8cdc247d9/out" "-L" "/home/ubuntu/risingwave/target/debug/build/bzip2-sys-0a595fa06a25a2a0/out/lib" "-L" "/home/ubuntu/risingwave/target/debug/build/lzma-sys-7721cc3b511644c1/out" "-L" "/home/ubuntu/risingwave/target/debug/build/clickhouse-rs-cityhash-sys-e0f2baabdd2f7d1b/out" "-L" "/home/ubuntu/risingwave/target/debug/build/protobuf-native-dd44909f657c749c/out" "-L" "/home/ubuntu/risingwave/target/debug/build/protobuf-src-582908d925ed8959/out/install/lib" "-L" "/home/ubuntu/risingwave/target/debug/build/cxx-9ce18e047b917dac/out" "-L" "/home/ubuntu/risingwave/target/debug/build/link-cplusplus-6a873b20f2a3b1bc/out" "-L" "/home/ubuntu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/ubuntu/risingwave/target/debug/deps/libtikv_jemallocator-cb0e4fc1ce108d06.rlib" 

... (*.rlib omitted)

"-Wl,-Bdynamic" "-ldl" "-lresolv" "-lstdc++" "-lstdc++" "-lz" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/ubuntu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/ubuntu/risingwave/target/debug/deps/risingwave-0f44522398583e0a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-fuse-ld=lld" "-Wl,--no-rosegment"
  = note: ld.lld: error: undefined symbol: protobuf_native::io::DeleteCodedOutputStream(google::protobuf::io::CodedOutputStream*)
          >>> referenced by io.rs.cc:1087 (/home/ubuntu/risingwave/target/debug/build/protobuf-native-dd44909f657c749c/out/cxxbridge/sources/protobuf-native/src/io.rs.cc:1087)
          >>>               0139aaaaf1d215a5-io.rs.o:(protobuf_native$io$cxxbridge1$DeleteCodedOutputStream) in archive /home/ubuntu/risingwave/target/debug/deps/libprotobuf_native-a25d55b0a835aa3f.rlib
          collect2: error: ld returned 1 exit status


error: could not compile `risingwave_cmd_all` (bin "risingwave") due to previous error
@xxchan
Copy link
Author

xxchan commented Nov 1, 2023

I thought it might be because of our linker config

https://github.com/risingwavelabs/risingwave/blob/7122d6cf9768642fea3cd15f96ed3982d05502f9/.cargo/config.toml#L13-L18

# Extra flags for Linux targets.
[target.'cfg(target_os = "linux")']
rustflags = [
    "-Clink-arg=-fuse-ld=lld",       #2781
    "-Clink-arg=-Wl,--no-rosegment", #4574
]

But after removing it, compilation still fails (with a different msg)

  = note: /usr/bin/ld: /home/ubuntu/risingwave/target/debug/deps/libprotobuf_native-a25d55b0a835aa3f.rlib(0139aaaaf1d215a5-io.rs.o): in function `protobuf_native$io$cxxbridge1$DeleteCodedOutputStream':
          /home/ubuntu/risingwave/target/debug/build/protobuf-native-dd44909f657c749c/out/cxxbridge/sources/protobuf-native/src/io.rs.cc:1087: undefined reference to `protobuf_native::io::DeleteCodedOutputStream(google::protobuf::io::CodedOutputStream*)'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `risingwave_cmd_all` (bin "risingwave") due to previous error

@xxchan
Copy link
Author

xxchan commented Nov 1, 2023

I tried this, and them compilation succeeded..

diff --git a/Cargo.toml b/Cargo.toml
index dc38b19e2..a5663eccb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -193,6 +193,9 @@ redundant_explicit_links = "allow"
 [profile.dev]
 lto = 'off'

+[profile.dev.package.protobuf-native]
+codegen-backend = "llvm"
+
 [profile.release]
 debug = "full"
 split-debuginfo = "packed"

@bjorn3
Copy link
Member

bjorn3 commented Nov 7, 2023

Sorry for the delay, was busy for the last couple of days. I can reproduce this by trying to compile the test suite of protobuf-native. I don't have a clue what the issue could be though unfortunately. I indeed can't find any definition of the symbol in question. In fact I can't find where it is supposed to be defined anywhere in the source code.

@bjorn3 bjorn3 added the C-bug Category: This is a bug. label Nov 7, 2023
def- added a commit to def-/materialize that referenced this issue Feb 12, 2024
  RUSTC_WRAPPER=$PWD/misc/fuzzshim/rustc_wrapper.py cargo fuzz run --dev --sanitizer none fuzz_target_1

Unfortunately still failing lining on protobuf-native:

  target/x86_64-unknown-linux-gnu/debug/build/protobuf-native-b0ba7c5e922fceec/out/cxxbridge/sources/protobuf-native/src/io.rs.cc:1086:(.text.protobuf_native$io$cxxbridge1$DeleteCodedOutputStream+0x13): undefined reference to `protobuf_native::io::DeleteCodedOutputStream(google::protobuf::io::CodedOutputStream*)'

There was a similar error before in rust-lang/rustc_codegen_cranelift#1411, but their workaround doesn't work for me (we're already using llvm codegen-backend)
@def-
Copy link

def- commented Feb 13, 2024

This is actually a bug in rust-protobuf-native, I opened a PR: MaterializeInc/rust-protobuf-native#12

@bjorn3
Copy link
Member

bjorn3 commented Feb 13, 2024

Thanks for letting me know!

@bjorn3 bjorn3 closed this as completed Feb 13, 2024
def- added a commit to def-/materialize that referenced this issue Feb 13, 2024
  RUSTC_WRAPPER=$PWD/misc/fuzzshim/rustc_wrapper.py cargo fuzz run --dev --sanitizer none fuzz_target_1

Unfortunately still failing lining on protobuf-native:

  target/x86_64-unknown-linux-gnu/debug/build/protobuf-native-b0ba7c5e922fceec/out/cxxbridge/sources/protobuf-native/src/io.rs.cc:1086:(.text.protobuf_native$io$cxxbridge1$DeleteCodedOutputStream+0x13): undefined reference to `protobuf_native::io::DeleteCodedOutputStream(google::protobuf::io::CodedOutputStream*)'

There was a similar error before in rust-lang/rustc_codegen_cranelift#1411, but their workaround doesn't work for me (we're already using llvm codegen-backend)
def- added a commit to def-/materialize that referenced this issue Feb 21, 2024
  RUSTC_WRAPPER=$PWD/misc/fuzzshim/rustc_wrapper.py cargo fuzz run --dev --sanitizer none fuzz_target_1

Unfortunately still failing lining on protobuf-native:

  target/x86_64-unknown-linux-gnu/debug/build/protobuf-native-b0ba7c5e922fceec/out/cxxbridge/sources/protobuf-native/src/io.rs.cc:1086:(.text.protobuf_native$io$cxxbridge1$DeleteCodedOutputStream+0x13): undefined reference to `protobuf_native::io::DeleteCodedOutputStream(google::protobuf::io::CodedOutputStream*)'

There was a similar error before in rust-lang/rustc_codegen_cranelift#1411, but their workaround doesn't work for me (we're already using llvm codegen-backend)
def- added a commit to def-/materialize that referenced this issue Feb 21, 2024
  RUSTC_WRAPPER=$PWD/misc/fuzzshim/rustc_wrapper.py cargo fuzz run --dev --sanitizer none fuzz_target_1

Unfortunately still failing lining on protobuf-native:

  target/x86_64-unknown-linux-gnu/debug/build/protobuf-native-b0ba7c5e922fceec/out/cxxbridge/sources/protobuf-native/src/io.rs.cc:1086:(.text.protobuf_native$io$cxxbridge1$DeleteCodedOutputStream+0x13): undefined reference to `protobuf_native::io::DeleteCodedOutputStream(google::protobuf::io::CodedOutputStream*)'

There was a similar error before in rust-lang/rustc_codegen_cranelift#1411, but their workaround doesn't work for me (we're already using llvm codegen-backend)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants