cloudflare / workerd

The JavaScript / Wasm runtime that powers Cloudflare Workers
https://blog.cloudflare.com/workerd-open-source-workers-runtime/
Apache License 2.0
6.28k stars 303 forks source link

Docker alpine compilation error #286

Closed sagarparker closed 1 year ago

sagarparker commented 1 year ago

I have been trying to compile workerd inside docker using alpine:3.17 as the base image.

FROM alpine:3.17

RUN apk update && apk add python3 py3-pip git libc-dev libstdc++ clang gcompat alpine-sdk ca-certificates wget gnupg 

RUN apk add --no-cache git build-base
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing bazel
RUN git clone https://github.com/cloudflare/workerd.git
RUN bazel --version
RUN clang --version
RUN cd workerd && bazel build -c opt //src/workerd/server:workerd
COPY hello.js ./
COPY config.capnp ./
RUN ls

ENTRYPOINT ["workerd","serve","config.capnp"]

Getting this error during building with bazel :

Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Loading: 
Loading: 1 packages loaded
Analyzing: target //src/workerd/server:workerd (2 packages loaded, 0 targets configured)
Analyzing: target //src/workerd/server:workerd (82 packages loaded, 678 targets configured)
WARNING: Download from https://zlib.net/zlib-1.2.11.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
Analyzing: target //src/workerd/server:workerd (93 packages loaded, 904 targets configured)
Analyzing: target //src/workerd/server:workerd (93 packages loaded, 904 targets configured)
Analyzing: target //src/workerd/server:workerd (111 packages loaded, 1441 targets configured)
Analyzing: target //src/workerd/server:workerd (111 packages loaded, 1441 targets configured)
Analyzing: target //src/workerd/server:workerd (111 packages loaded, 1441 targets configured)
DEBUG: Rule 'v8' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1668534691 +0000"
DEBUG: Repository v8 instantiated at:
  /workerd/WORKSPACE:244:15: in <toplevel>
Repository rule git_repository defined at:
  /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
DEBUG: Rule 'com_googlesource_chromium_base_trace_event_common' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1662669790 -0700"
DEBUG: Repository com_googlesource_chromium_base_trace_event_common instantiated at:
  /workerd/WORKSPACE:268:19: in <toplevel>
Repository rule new_git_repository defined at:
  /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/bazel_tools/tools/build_defs/repo/git.bzl:186:37: in <toplevel>
Analyzing: target //src/workerd/server:workerd (121 packages loaded, 4908 targets configured)
Analyzing: target //src/workerd/server:workerd (121 packages loaded, 4908 targets configured)
Analyzing: target //src/workerd/server:workerd (121 packages loaded, 4908 targets configured)
DEBUG: Rule 'com_googlesource_chromium_icu' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1662576452 +0000"
DEBUG: Repository com_googlesource_chromium_icu instantiated at:
  /workerd/WORKSPACE:259:19: in <toplevel>
Repository rule new_git_repository defined at:
  /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/bazel_tools/tools/build_defs/repo/git.bzl:186:37: in <toplevel>
Analyzing: target //src/workerd/server:workerd (123 packages loaded, 6371 targets configured)
Analyzing: target //src/workerd/server:workerd (123 packages loaded, 6371 targets configured)
Analyzing: target //src/workerd/server:workerd (123 packages loaded, 6371 targets configured)
INFO: Analyzed target //src/workerd/server:workerd (220 packages loaded, 16336 targets configured).

INFO: Found 1 target...
[0 / 225] [Prepa] BazelWorkspaceStatusAction stable-status.txt ... (16 actions, 0 running)
ERROR: /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/v8/BUILD.bazel:3553:11: Compiling src/base/bounded-page-allocator.cc [for host] failed: (Exit 1): clang-15 failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/sandbox/processwrapper-sandbox/4/execroot/workerd && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
  /usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/host/bin/external/v8/_objs/v8_libbase/bounded-page-allocator.d '-frandom-seed=bazel-out/host/bin/external/v8/_objs/v8_libbase/bounded-page-allocator.o' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_ENABLE_WEBASSEMBLY -DGOOGLE3 -DENABLE_DEBUGGER_SUPPORT -DV8_ADVANCED_BIGINT_ALGORITHMS -DV8_CONCURRENT_MARKING -DV8_TARGET_ARCH_X64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_LINUX -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_SHORT_BUILTIN_CALLS -iquote external/v8 -iquote bazel-out/host/bin/external/v8 -isystem external/v8/include -isystem bazel-out/host/bin/external/v8/include -g0 -g0 '-std=c++20' -fcoroutines-ts '-stdlib=libc++' -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-ignored-qualifiers -Wno-ambiguous-reversed-operator -fPIC -fno-strict-aliasing -Werror -Wextra -Wno-unknown-warning-option -Wno-bitwise-instead-of-logical -Wno-builtin-assume-aligned-alignment -Wno-unused-parameter -Wno-implicit-int-float-conversion -Wno-deprecated-copy -Wno-non-virtual-dtor -isystem . -Wno-invalid-offsetof '-std=c++17' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/v8/src/base/bounded-page-allocator.cc -o bazel-out/host/bin/external/v8/_objs/v8_libbase/bounded-page-allocator.o)
# Configuration: 8d64a6aea5704656354b9a9a5eb85747f5a7e0b5b88897893c95d4855b66925c
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/v8/src/base/bounded-page-allocator.cc:5:
In file included from external/v8/src/base/bounded-page-allocator.h:8:
external/v8/include/v8-platform.h:11:10: fatal error: 'memory' file not found
#include <memory>
         ^~~~~~~~
1 error generated.
ERROR: /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/capnp-cpp/src/kj/BUILD.bazel:5:11: Compiling src/kj/debug.c++ failed: (Exit 1): clang-15 failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/sandbox/processwrapper-sandbox/12/execroot/workerd && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
  /usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_objs/kj/debug.d '-frandom-seed=bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_objs/kj/debug.o' -DKJ_HAS_OPENSSL -DKJ_HAS_ZLIB -DKJ_HAS_LIBDL '-DKJ_SAVE_ACQUIRED_LOCK_INFO=0' '-DKJ_TRACK_LOCK_BLOCKING=0' -iquote external/capnp-cpp -iquote bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_virtual_includes/kj -g0 -g0 '-std=c++20' -fcoroutines-ts '-stdlib=libc++' -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-ignored-qualifiers -Wno-ambiguous-reversed-operator -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/capnp-cpp/src/kj/debug.c++ -o bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_objs/kj/debug.o)
# Configuration: 9703786d901484debd915663b994ba1cf6a24545c8ade525d67d00aa8301d644
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/capnp-cpp/src/kj/debug.c++:26:
In file included from external/capnp-cpp/src/kj/debug.h:117:
external/capnp-cpp/src/kj/string.h:24:10: fatal error: 'initializer_list' file not found
#include <initializer_list>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
ERROR: /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/v8/BUILD.bazel:3553:11: Compiling src/base/file-utils.cc [for host] failed: (Exit 1): clang-15 failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/sandbox/processwrapper-sandbox/16/execroot/workerd && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
  /usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/host/bin/external/v8/_objs/v8_libbase/file-utils.d '-frandom-seed=bazel-out/host/bin/external/v8/_objs/v8_libbase/file-utils.o' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_ENABLE_WEBASSEMBLY -DGOOGLE3 -DENABLE_DEBUGGER_SUPPORT -DV8_ADVANCED_BIGINT_ALGORITHMS -DV8_CONCURRENT_MARKING -DV8_TARGET_ARCH_X64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_LINUX -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_SHORT_BUILTIN_CALLS -iquote external/v8 -iquote bazel-out/host/bin/external/v8 -isystem external/v8/include -isystem bazel-out/host/bin/external/v8/include -g0 -g0 '-std=c++20' -fcoroutines-ts '-stdlib=libc++' -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-ignored-qualifiers -Wno-ambiguous-reversed-operator -fPIC -fno-strict-aliasing -Werror -Wextra -Wno-unknown-warning-option -Wno-bitwise-instead-of-logical -Wno-builtin-assume-aligned-alignment -Wno-unused-parameter -Wno-implicit-int-float-conversion -Wno-deprecated-copy -Wno-non-virtual-dtor -isystem . -Wno-invalid-offsetof '-std=c++17' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/v8/src/base/file-utils.cc -o bazel-out/host/bin/external/v8/_objs/v8_libbase/file-utils.o)
# Configuration: 8d64a6aea5704656354b9a9a5eb85747f5a7e0b5b88897893c95d4855b66925c
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/v8/src/base/file-utils.cc:5:
external/v8/src/base/file-utils.h:8:10: fatal error: 'memory' file not found
#include <memory>
         ^~~~~~~~
1 error generated.
ERROR: /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/capnp-cpp/src/kj/BUILD.bazel:5:11: Compiling src/kj/string.c++ failed: (Exit 1): clang-15 failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/sandbox/processwrapper-sandbox/9/execroot/workerd && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
  /usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_objs/kj/string.d '-frandom-seed=bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_objs/kj/string.o' -DKJ_HAS_OPENSSL -DKJ_HAS_ZLIB -DKJ_HAS_LIBDL '-DKJ_SAVE_ACQUIRED_LOCK_INFO=0' '-DKJ_TRACK_LOCK_BLOCKING=0' -iquote external/capnp-cpp -iquote bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp -Ibazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_virtual_includes/kj -g0 -g0 '-std=c++20' -fcoroutines-ts '-stdlib=libc++' -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-ignored-qualifiers -Wno-ambiguous-reversed-operator -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/capnp-cpp/src/kj/string.c++ -o bazel-out/k8-opt-exec-2B5CBBC6/bin/external/capnp-cpp/src/kj/_objs/kj/string.o)
# Configuration: 9703786d901484debd915663b994ba1cf6a24545c8ade525d67d00aa8301d644
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/capnp-cpp/src/kj/string.c++:22:
external/capnp-cpp/src/kj/string.h:24:10: fatal error: 'initializer_list' file not found
#include <initializer_list>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
ERROR: /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/external/v8/BUILD.bazel:3553:11: Compiling src/base/strings.cc [for host] failed: (Exit 1): clang-15 failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/8de071431a6d3a79427aa3f0e24254ca/sandbox/processwrapper-sandbox/3/execroot/workerd && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
  /usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/host/bin/external/v8/_objs/v8_libbase/strings.d '-frandom-seed=bazel-out/host/bin/external/v8/_objs/v8_libbase/strings.o' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_ENABLE_WEBASSEMBLY -DGOOGLE3 -DENABLE_DEBUGGER_SUPPORT -DV8_ADVANCED_BIGINT_ALGORITHMS -DV8_CONCURRENT_MARKING -DV8_TARGET_ARCH_X64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_LINUX -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_SHORT_BUILTIN_CALLS -iquote external/v8 -iquote bazel-out/host/bin/external/v8 -isystem external/v8/include -isystem bazel-out/host/bin/external/v8/include -g0 -g0 '-std=c++20' -fcoroutines-ts '-stdlib=libc++' -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-ignored-qualifiers -Wno-ambiguous-reversed-operator -fPIC -fno-strict-aliasing -Werror -Wextra -Wno-unknown-warning-option -Wno-bitwise-instead-of-logical -Wno-builtin-assume-aligned-alignment -Wno-unused-parameter -Wno-implicit-int-float-conversion -Wno-deprecated-copy -Wno-non-virtual-dtor -isystem . -Wno-invalid-offsetof '-std=c++17' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/v8/src/base/strings.cc -o bazel-out/host/bin/external/v8/_objs/v8_libbase/strings.o)
# Configuration: 8d64a6aea5704656354b9a9a5eb85747f5a7e0b5b88897893c95d4855b66925c
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/v8/src/base/strings.cc:5:
In file included from external/v8/src/base/strings.h:9:
external/v8/src/base/macros.h:8:10: fatal error: 'limits' file not found
#include <limits>
         ^~~~~~~~
1 error generated.
Target //src/workerd/server:workerd failed to build
INFO: Elapsed time: 148.032s, Critical Path: 0.41s
INFO: 517 processes: 517 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
The command '/bin/sh -c cd workerd && bazel build -c opt //src/workerd/server:workerd' returned a non-zero code: 1
mikea commented 1 year ago

try installing libc++-dev & libc++abi-dev?

sagarparker commented 1 year ago

try installing libc++-dev & libc++abi-dev?

Alpine doesn't seem to have libc++-dev & libc++abi-dev.

kentonv commented 1 year ago

Hi @sagarparker,

libc++ is a required dependency of workerd. In particular we need it in order to be able to use coroutines in Clang, and a lot of our code is written to use coroutines. (libc++ and Clang are both parts of the LLVM project.)

It appears Alpine may not have a libc++ package. Unfortunately this probably means it's not going to be easy to use workerd on Alpine.

Sorry, but this isn't something we're able to help with. However, if you discover that there is some way to get this working with minimal changes to workerd, we're happy to consider PRs.

HeyITGuyFixIt commented 1 year ago

I'm also using Alpine v3.17 in docker. Alpine does have libc++-dev, but I haven't found libc++abi-dev. It still doesn't build after installing libc++-dev, but fails with a similar error as in #320 for me.