RustCrypto / hashes

Collection of cryptographic hash functions written in pure Rust
1.81k stars 245 forks source link

fix(?): some `extern` functions couldn't be found #500

Closed jjangga0214 closed 1 year ago

jjangga0214 commented 1 year ago

Hi, after adding sha1 to cargo, build fails for x86_64-unknown-linux-gnu-gcc.

I build in docker (for specific requirement). I guess there might be some system library dependencies that the docker image misses. If there's something like that, please let me know.

Thanks!

스크린샷 2023-08-28 오후 7 44 47
error: linking with `x86_64-unknown-linux-gnu-gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/tmp/xfs-acdf631d:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/x86_64-unknown-linux-gnu/bin" VSLANG="1033" "x86_64-unknown-linux-gnu-gcc" "-m64" "/tmp/rustctynOVy/symbols.o" "/build/target/x86_64-unknown-linux-gnu/release/deps/n_rs_kakao-027917a54b8d2e2d.n_rs_kakao.fd05ee83d8e82615-cgu.1.rcgu.o" "-Wl,--as-needed" "-L" "/build/target/x86_64-unknown-linux-gnu/release/deps" "-L" "/build/target/release/deps" "-L" "/build/target/x86_64-unknown-linux-gnu/release/build/libsqlite3-sys-e260ea2f164305a0/out" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-2a597573799b576f.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/build/target/x86_64-unknown-linux-gnu/release/deps/n_rs_kakao-027917a54b8d2e2d" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /usr/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot/usr/lib/../lib64/Scrt1.o: in function `_start':
          /build/.build/src/glibc-2.17/csu/../sysdeps/x86_64/start.S:106: undefined reference to `__libc_csu_fini'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /build/.build/src/glibc-2.17/csu/../sysdeps/x86_64/start.S:107: undefined reference to `__libc_csu_init'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_symbind_alt@GLIBC_PRIVATE'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__nptl_change_stack_perm@GLIBC_PRIVATE'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_find_dso_for_object@GLIBC_PRIVATE'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_fatal_printf@GLIBC_PRIVATE'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_exception_create@GLIBC_PRIVATE'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__tunable_get_val@GLIBC_PRIVATE'
          /usr/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../x86_64-unknown-linux-gnu/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_preinit@GLIBC_PRIVATE'
          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 `n-rs-kakao` (bin "n-rs-kakao") due to previous error
warning: build failed, waiting for other jobs to finish...
warning: `n-rs-kakao` (lib) generated 10 warnings (run `cargo fix --lib -p n-rs-kakao` to apply 2 suggestions)
Internal Error: Command failed: cargo build --release --target x86_64-unknown-linux-gnu
    at checkExecSyncError (node:child_process:885:11)
    at Object.execSync (node:child_process:957:15)
    at BuildCommand.<anonymous> (/build/node_modules/@napi-rs/cli/scripts/index.js:11515:30)
    at Generator.next (<anonymous>)
    at /build/node_modules/@napi-rs/cli/scripts/index.js:3552:69
    at new Promise (<anonymous>)
    at __awaiter$1 (/build/node_modules/@napi-rs/cli/scripts/index.js:3548:10)
    at BuildCommand.execute (/build/node_modules/@napi-rs/cli/scripts/index.js:11292:16)
    at BuildCommand.validateAndExecute (/build/node_modules/@napi-rs/cli/scripts/index.js:2113:37)
tarcieri commented 1 year ago

This is a linking error of the sort you wouldn't normally expect from pure Rust code, especially on a target like x86_64-unknown-linux-gnu. I'm guessing it's some sort of environmental issue.

Can you post a full reproduction, including the Cargo project and ideally the Dockerfile as well?

jjangga0214 commented 1 year ago

@tarcieri You're right. I thought the only change I made was adding sha1, but actually an unexpected change was committed without my knowing. Thanks a lot.