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

Fail to build static Rust binary with ekidd/rust-musl-builder #40

Open
vincent-herlemont opened this issue Apr 26, 2021 · 0 comments
Open

Comments

@vincent-herlemont
Copy link

Some linking cc fail when I try to build rust-jsonnet with rust-musl-builder for generating a static Rust binary.

Below the files that have used for reproducing the bug.

Cargo.toml :

[package]
....
[dependencies]
jsonnet-rs = "0.17.0"

Dockerfile :

FROM ekidd/rust-musl-builder:1.50.0
ADD . ./
CMD cargo build

Build error :

✗ docker build -t test1 . && docker run --rm test1
Sending build context to Docker daemon  50.18kB
Step 1/3 : FROM ekidd/rust-musl-builder:1.50.0
 ---> bb5784ce5f63
Step 2/3 : ADD . ./
 ---> Using cache
 ---> 40f7736e4195
Step 3/3 : CMD cargo build
 ---> Using cache
 ---> 68ac969460d4
Successfully built 68ac969460d4
Successfully tagged test1:latest
    Updating crates.io index
  Downloading crates ...
  Downloaded jsonnet-rs v0.17.0
  Downloaded cc v1.0.67
  Downloaded jsonnet-sys v0.17.0
  Downloaded libc v0.2.93
   Compiling libc v0.2.93
   Compiling cc v1.0.67
   Compiling jsonnet-sys v0.17.0
   Compiling jsonnet-rs v0.17.0
   Compiling rust-jsonnet v0.1.0 (/home/rust/src)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-nostartfiles" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crt1.o" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "-L" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.161wm2g1wzcwjgvj.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.17g76nh6zyv5tade.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.1987eq46n067ujzn.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.1abbep6d3mn1dgy9.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.1un33j1csb5877gg.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.1vljilws0ah901yu.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.1vm9g2b4blurtxqm.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.1xm8vfqv31jxksj8.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.27j7l36m4w6rmgp8.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.2c8nvn35g9sapb18.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.2jhs5rkzvd1jo36n.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.2kad6j71rqxbf0u9.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.2ozhh54lqq9e5gtq.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.2w3a53db7zkes2or.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.2wruq8kkmv5d5zmb.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.2xcmtkf3k4mzjj0u.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3alxf2o5rlsz7i6k.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3brkz0i0ta8x5zfj.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3d52dgmcmvpvc7d2.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3diz8n6fr3dd9apv.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3ilbig2mz3wn2rqy.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3ju3wbgel4wxv79s.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3l9dam6qy77ek27s.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3lconvqngedo2wzp.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3w4uhou73epgr6o7.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.3z9hhie2bj9la88f.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.41ycxlqudm3xpcvm.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.4c3y1mhq3n7ey0gv.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.4mglmqcgb9qcea5q.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.4nzqziykll36gv0.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.4q5siug0ctdigsoh.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.4tdvux387vbk3e0k.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.4v9jfn7jgidqkqra.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.50fpmyf1y03f02d2.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.570vp5wlegduooxi.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.59zsicpr9ird2d05.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.5c582dex2atv09sd.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.6zerhfd5dlig97r.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.aboc0uze851xo83.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.bnfu4a6o4fo3s13.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.cqs69h4nu2u3jun.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.iiscs9k9nd7v13b.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.pzypk02yxxhwn6t.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.q0ee0vehfpybip4.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.qhf48m00vwgtumh.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.vz9p7qxi5x1o14n.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.y43jij24lm9p779.rcgu.o" "-o" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91.geb96741bqnvbkg.rcgu.o" "-Wl,--gc-sections" "-static" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps" "-L" "/home/rust/src/target/debug/deps" "-L" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/build/jsonnet-sys-ec1ecc5ea86284b5/out" "-L" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/libjsonnet-d4e2953816f2eb9d.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/libjsonnet_sys-f23132dca1dd9b88.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/liblibc-77bb581c43605ad5.rlib" "-Wl,--start-group" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-f4ca16729b67f4dd.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libminiz_oxide-400395ea2841002a.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libadler-b0533ea0af675dc9.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libobject-e9d03d8a1cf7a110.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libaddr2line-fe8cb29709d122d4.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libgimli-09ef970e0d183722.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_demangle-1a8801c99e79f10f.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libhashbrown-886c89b28e5e0865.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_alloc-dcf93364faa2ceaa.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-75081e895819d734.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcfg_if-6c4598f129413e8a.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-d3a472b733fbfd21.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-2f23acd805819d02.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_core-d2b457edb67a2174.rlib" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-fc65d219541fe932.rlib" "-Wl,--end-group" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-f4df6b79d8e73f02.rlib" "-Wl,-Bdynamic" "-lstdc++" "/opt/rust/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
  = note: /home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/libjsonnet_sys-f23132dca1dd9b88.rlib(libjsonnet.o): In function `__static_initialization_and_destruction_0(int, int)':
          /usr/include/c++/7/iostream:74: undefined reference to `__dso_handle'
          /home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/libjsonnet_sys-f23132dca1dd9b88.rlib(libjsonnet.o): In function `__static_initialization_and_destruction_0(int, int)':
          /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonnet-sys-0.17.0/jsonnet/core/ast.h:1078: undefined reference to `__dso_handle'
          /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonnet-sys-0.17.0/jsonnet/core/ast.h:1079: undefined reference to `__dso_handle'
          /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonnet-sys-0.17.0/jsonnet/core/ast.h:1080: undefined reference to `__dso_handle'
          /home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/libjsonnet_sys-f23132dca1dd9b88.rlib(parser.o): In function `__static_initialization_and_destruction_0(int, int)':
          /usr/include/c++/7/iostream:74: undefined reference to `__dso_handle'
          /home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/libjsonnet_sys-f23132dca1dd9b88.rlib(parser.o):/home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonnet-sys-0.17.0/jsonnet/core/ast.h:1078: more undefined references to `__dso_handle' follow
          /usr/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/debug/deps/rust_jsonnet-0414d9e071c87c91: hidden symbol `__dso_handle' isn't defined
          /usr/bin/ld: final link failed: Bad value
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: could not compile `rust-jsonnet`

To learn more, run the command again with --verbose.

There is a way to build a static binary with rust-jsonnet?

@vincent-herlemont vincent-herlemont changed the title Fail to build static Rust binary with ekidd/rust-musl-builder. Fail to build static Rust binary with ekidd/rust-musl-builder Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant