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

Linking error when building deno for Alpine Docker #3243

Closed
hayd opened this issue Oct 30, 2019 · 6 comments
Closed

Linking error when building deno for Alpine Docker #3243

hayd opened this issue Oct 30, 2019 · 6 comments
Labels

Comments

@hayd
Copy link
Contributor

hayd commented Oct 30, 2019

When building from this Docker file, I am able to build all rust modules but in fails in the last few steps (xlink #1658 #1456):

  Installing deno_cli v0.22.0 (/deno/cli)
    Updating crates.io index
warning: package `rand v0.7.1` in Cargo.lock is yanked in registry `crates.io`, consider running without --locked
   Compiling deno_cli v0.22.0 (/deno/cli)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--eh-frame-hdr" "-m64" "-L" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_
build.5wit2qlf-cgu.0.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.1.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d
91b95cc90a61.build_script_build.5wit2qlf-cgu.10.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.11.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc9
0a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.12.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.13.rcgu.o" "/deno/target/release
/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.14.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.2.rc
gu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.3.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_scri
pt_build.5wit2qlf-cgu.4.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.5.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9
c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.6.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.7.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc
90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.8.rcgu.o" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.build_script_build.5wit2qlf-cgu.9.rcgu.o" "-o" "/deno/target/rel
ease/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61" "/deno/target/release/build/deno_cli-9c3d91b95cc90a61/build_script_build-9c3d91b95cc90a61.29cvwrowgnvllr6g.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-zn
ow" "-Wl,-O1" "-nodefaultlibs" "-L" "/deno/target/release/deps" "-L" "/deno/target/release/obj" "-L" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib" "-Wl,-Bstatic" "/deno/target/release/deps/libdeno_typescript-83074a4610760c5f.rlib" "/den
o/target/release/deps/libdeno-01ab82fa4c1c7931.rlib" "/deno/target/release/deps/liburl-4910bde0fc98bd0f.rlib" "/deno/target/release/deps/libpercent_encoding-19c9b299852ba487.rlib" "/deno/target/release/deps/libidna-39b2af1a2235d41b.rlib"
"/deno/target/release/deps/libunicode_normalization-7eeb783a7c6a609d.rlib" "/deno/target/release/deps/libsmallvec-dc5a68122ed62519.rlib" "/deno/target/release/deps/libunicode_bidi-53506e7fc6edacf6.rlib" "/deno/target/release/deps/libmatch
es-499cb222e1515dab.rlib" "/deno/target/release/deps/libserde_json-6daec0417c0a9124.rlib" "/deno/target/release/deps/libryu-7dae8630a4e00664.rlib" "/deno/target/release/deps/libitoa-7fe292ebbed95b31.rlib" "/deno/target/release/deps/libind
exmap-4d1c0f7053260a7f.rlib" "/deno/target/release/deps/libserde-22bcfacd3774e10a.rlib" "/deno/target/release/deps/libdowncast_rs-996243fa5e2c1afe.rlib" "/deno/target/release/deps/liblibc-df9cbfaa0686721b.rlib" "/deno/target/release/deps/
libfutures-d57db70609bd0c34.rlib" "/deno/target/release/deps/liblog-f13612a401f33cf0.rlib" "/deno/target/release/deps/libcfg_if-5f8feab7a327e08a.rlib" "-Wl,--start-group" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/libstd-b600ab7f8ad6a
803.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/libpanic_unwind-0cd1497d724bde8f.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/libbacktrace-27257028ba9681c1.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/libbacktrace
_sys-85eb1fc4d7af0451.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/librustc_demangle-208e315ffc6508d0.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/libhashbrown-4c079b7253151d1d.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-m
usl/lib/librustc_std_workspace_alloc-22f8edb08149f508.rlib" "/tmp/rustcbSWclv/libunwind-f8587c5c416c0561.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/libcfg_if-f018a27f32967b17.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/
liblibc-736f7f996fb3ceba.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/liballoc-b3771e0f64391e64.rlib" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/librustc_std_workspace_core-7f914ff11baf82a8.rlib" "/usr/lib/rustlib/x86_64-alpin
e-linux-musl/lib/libcore-afb2c4dc96158fb3.rlib" "-Wl,--end-group" "/usr/lib/rustlib/x86_64-alpine-linux-musl/lib/libcompiler_builtins-f7e5cdf9235eebb4.rlib" "-Wl,-Bdynamic" "-ldeno" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-Wl,-rpath,/us
r/lib/rustlib/x86_64-alpine-linux-musl/lib" "-Wl,--enable-new-dtags"
  = note: /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /deno/target/release/obj/libdeno.a(libdeno_jumbo_1.o): in function `deno_new_snapshotter':
          libdeno_jumbo_1.cc:(.text.deno_new_snapshotter+0x3c): undefined reference to `operator new(unsigned long)'
          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libdeno_jumbo_1.cc:(.text.deno_new_snapshotter+0x65): undefined reference to `operator new(unsigned long)'
          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /deno/target/release/obj/libdeno.a(libdeno_jumbo_1.o): in function `deno::SerializeInternalFields(v8::Local<v8::Object>, int, void*)':
          libdeno_jumbo_1.cc:(.text._ZN4deno23SerializeInternalFieldsEN2v85LocalINS0_6ObjectEEEiPv+0x41): undefined reference to `operator new[](unsigned long)'
          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /deno/target/release/obj/libdeno.a(libdeno_jumbo_1.o): in function `deno_new':
          libdeno_jumbo_1.cc:(.text.deno_new+0x71): undefined reference to `operator new(unsigned long)'
          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libdeno_jumbo_1.cc:(.text.deno_new+0x36d): undefined reference to `__cxa_guard_acquire'
          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libdeno_jumbo_1.cc:(.text.deno_new+0x3f6): undefined reference to `__cxa_guard_release'
          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /deno/target/release/obj/libdeno.a(libdeno_jumbo_1.o): in function `deno::DeserializeInternalFields(v8::Local<v8::Object>, int, v8::Startup

... snipped

          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /deno/target/release/obj/libdeno.a(trace-object.o): in function `v8::platform::tracing::TraceObject::Initialize(char, unsigned char const*, char const*, char const*, unsigned long, unsigned long, int, char const**, unsigned char const*, unsigned long const*, std::unique_ptr<v8::ConvertableToTraceFormat, std::default_delete<v8::ConvertableToTraceFormat> >*, unsigned int, long, long)':
          trace-object.cc:(.text._ZN2v88platform7tracing11TraceObject10InitializeEcPKhPKcS6_mmiPS6_S4_PKmPSt10unique_ptrINS_24ConvertableToTraceFormatESt14default_deleteISB_EEjll+0x233): undefined reference to `operator delete[](void*)'
          /usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: trace-object.cc:(.text._ZN2v88platform7tracing11TraceObject10InitializeEcPKhPKcS6_mmiPS6_S4_PKmPSt10unique_ptrINS_24ConvertableToTraceFormatESt14default_deleteISB_EEjll+0x23b): undefined reference to `operator new[](unsigned long)'
          collect2: error: ld returned 1 exit status

error: aborting due to previous error

error: failed to compile `deno_cli v0.22.0 (/deno/cli)`, intermediate artifacts can be found at `/deno/target`

Caused by:
  Could not compile `deno_cli`.

I've tried toggling a bunch of v8 flags to no avail...

PATH=$PATH:/usr/lib/llvm9/bin RUST_BACKTRACE=1 DENO_NO_BINARY_DOWNLOAD=1 
DENO_BUILD_ARGS='clang_use_chrome_plugins=false treat_warnings_as_errors=false
use_sysroot=false clang_base_path="/usr" use_glib=false use_custom_libcxx=false
use_custom_libcxx_for_host=false v8_static_library=true v8_enable_gdbjit=false
symbol_level=0 binutils_path="/usr/bin" v8_enable_future=true use_allocator_shim=false
use_lld=true' DENO_GN_PATH=gn cargo install --locked --root .. --path .

I've published this mostly built docker image as hayd/test:failing-0.22.0, so you can reproduce this with the following one line Dockerfile:

FROM hayd/test:failing-0.22.0

which allows you to run into the failure in around ~15s (since most of the compilation is already done):

$ docker build -t failing -f Dockerfile .
$ docker run -it --init failing
/ #

e.g. cd deno/cli && RUST_BACKTRACE=1 DENO_NO_BINARY_DOWNLOAD=1 DENO_BUILD_ARGS='clang_use_chrome_plugins=false treat_warnings_as_errors=false use_sysroot=false clang_base_path="/usr" use_glib=false use_custom_libcxx=false use_custom_libcxx_for_host=false use_gold=true' DENO_GN_PATH=gn cargo install --locked --root .. --path .

Version info:

/deno/cli # rustc --version
rustc 1.38.0
/deno/cli # clang --version
Alpine clang version 9.0.0 (git://git.alpinelinux.org/aports 351e828ddb447e649acfc38775596d290f92cb05) (based on LLVM 9.0.0)
Target: x86_64-alpine-linux-musl
Thread model: posix
InstalledDir: /usr/bin
@hayd
Copy link
Contributor Author

hayd commented Nov 13, 2019

I wonder if the strategy here is to build on another OS using --target x86_64-unknown-linux-musl (I haven't been able to get this to work yet).

@andrewmclagan
Copy link

andrewmclagan commented May 15, 2020

DO we have any idea what is preventing this from compiling on Alpine, is it Glibc?

Edit: okay its rust and musl. Seems they are still attempting a port?

@hayd
Copy link
Contributor Author

hayd commented May 15, 2020

Glibc is essentially the issue...

The latest (and working but a hack) is here: #3711 (comment)

If we can move from is a .gn patch to using arguments and supporting it in denoland's repos that would be preferable.

@lucacasonato
Copy link
Member

Ref #1658

@stale
Copy link

stale bot commented Jan 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 6, 2021
@lucacasonato
Copy link
Member

Closing as dupe of #1658.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants