Last active
September 15, 2024 11:36
-
-
Save kesor/68df53a5d76784a235ca6b0e7efed4d9 to your computer and use it in GitHub Desktop.
Compile DENO on Alpine (w/MUSL C)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM rust:alpine | |
RUN apk add --no-cache \ | |
bash \ | |
binutils-gold \ | |
ca-certificates \ | |
clang \ | |
curl \ | |
g++ \ | |
git \ | |
glib-dev \ | |
icu-dev \ | |
libgc++ \ | |
libstdc++ \ | |
libunwind-dev \ | |
llvm-libunwind \ | |
llvm9-dev \ | |
llvm9-libs \ | |
make \ | |
musl-dev \ | |
ninja \ | |
python2 \ | |
re2c \ | |
sed \ | |
tar \ | |
vim \ | |
wget \ | |
xen-dev \ | |
xz | |
RUN git clone --recurse-submodules https://github.com/denoland/deno.git | |
WORKDIR /deno | |
RUN git clone https://gn.googlesource.com/gn \ | |
&& cd gn \ | |
&& python build/gen.py \ | |
&& ninja -C out \ | |
&& out/gn_unittests \ | |
&& cp out/gn /usr/local/bin/ | |
ENV V8_FROM_SOURCE=1 | |
ENV CLANG_BASE_PATH /usr | |
ENV NINJA /usr/bin/ninja | |
ENV GN /usr/local/bin/gn | |
ENV TARGET x86_64-alpine-linux-musl | |
ENV GN_ARGS no_inline_line_tables=false use_lld=false | |
ENV RUSTFLAGS -C target-feature=-crt-static | |
RUN cargo fetch | |
COPY rusty-changed-build.diff . | |
RUN patch -p0 < rusty-changed-build.diff | |
RUN cargo build --release | |
# --- | |
FROM alpine | |
RUN apk add --no-cache libgcc | |
COPY --from=0 /deno/target/release/deno /usr/bin/ | |
CMD [ "/usr/bin/deno" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /tmp/rusty_v8/BUILD.gn | |
+++ /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_v8-0.4.2/BUILD.gn | |
@@ -28,12 +28,15 @@ | |
# internal V8 headers. | |
include_dirs = [ | |
"v8", | |
+ "/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/include", | |
"$target_gen_dir/v8", | |
] | |
if (is_debug) { | |
defines = [ "DEBUG" ] | |
} | |
+ | |
+ defines = ["_LIBCPP_HAS_MUSL_LIBC"] | |
if (is_clang) { | |
cflags += [ | |
--- /tmp/rusty_v8/build/config/compiler/BUILD.gn | |
+++ /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_v8-0.4.2/build/config/compiler/BUILD.gn | |
@@ -416,7 +416,7 @@ | |
# Linux-specific compiler flags setup. | |
# ------------------------------------ | |
if ((is_posix || is_fuchsia) && use_lld) { | |
- ldflags += [ "-fuse-ld=lld" ] | |
+ ldflags += [ "-fuse-ld=gold" ] | |
if (current_cpu == "arm64") { | |
# Reduce the page size from 65536 in order to reduce binary size slightly | |
# by shrinking the alignment gap between segments. This also causes all | |
@@ -492,9 +492,9 @@ | |
if (is_win) { | |
# On Windows, we call the linker directly, instead of calling it through | |
# the driver. | |
- ldflags += [ "--color-diagnostics" ] | |
+ ldflags += [ ] | |
} else { | |
- ldflags += [ "-Wl,--color-diagnostics" ] | |
+ ldflags += [ ] | |
} | |
} | |
--- /tmp/rusty_v8/buildtools/third_party/libc++/BUILD.gn | |
+++ /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_v8-0.4.2/buildtools/third_party/libc++/BUILD.gn | |
@@ -124,7 +124,7 @@ | |
configs += [ "//build/config/gcc:symbol_visibility_default" ] | |
} | |
- defines = [ "_LIBCPP_BUILDING_LIBRARY" ] | |
+ defines = [ "_LIBCPP_BUILDING_LIBRARY", "_LIBCPP_HAS_MUSL_LIBC" ] | |
if (!is_clang && libcxx_is_shared) { | |
# This is a temporary workaround to get libc++ builds working with | |
# gcc. It can be removed with either | |
--- /tmp/rusty_v8/third_party/zlib/BUILD.gn | |
+++ /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_v8-0.4.2/third_party/zlib/BUILD.gn | |
@@ -13,7 +13,10 @@ | |
} | |
config("zlib_config") { | |
- include_dirs = [ "." ] | |
+ include_dirs = [ | |
+ ".", | |
+ "/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/include" | |
+ ] | |
} | |
config("zlib_internal_config") { | |
@@ -30,8 +33,8 @@ | |
} | |
} | |
-use_x86_x64_optimizations = | |
- (current_cpu == "x86" || current_cpu == "x64") && !is_ios | |
+use_x86_x64_optimizations = false | |
+# (current_cpu == "x86" || current_cpu == "x64") && !is_ios | |
config("zlib_adler32_simd_config") { | |
if (use_x86_x64_optimizations) { | |
--- /tmp/rusty_v8/tools/clang/scripts/build.py | |
+++ /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_v8-0.4.2/tools/clang/scripts/build.py | |
@@ -538,10 +538,10 @@ | |
base_cmake_args.append('-DLLVM_USE_CRT_RELEASE=MT') | |
# Require zlib compression. | |
- zlib_dir = AddZlibToPath() | |
- cflags.append('-I' + zlib_dir) | |
- cxxflags.append('-I' + zlib_dir) | |
- ldflags.append('-LIBPATH:' + zlib_dir) | |
+ # zlib_dir = AddZlibToPath() | |
+ # cflags.append('-I' + zlib_dir) | |
+ # cxxflags.append('-I' + zlib_dir) | |
+ # ldflags.append('-LIBPATH:' + zlib_dir) | |
if sys.platform != 'win32': | |
# libxml2 is required by the Win manifest merging tool used in cross-builds. | |
--- /tmp/rusty_v8/v8/BUILD.gn | |
+++ /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_v8-0.4.2/v8/BUILD.gn | |
@@ -354,7 +353,7 @@ | |
if (is_component_build) { | |
defines = [ "USING_V8_BASE_SHARED" ] | |
} | |
- libs = [] | |
+ libs = ["execinfo"] | |
if (is_android && current_toolchain != host_toolchain) { | |
libs += [ "log" ] | |
} | |
@@ -562,7 +561,7 @@ | |
config("toolchain") { | |
visibility = [ ":*" ] # Only targets in this file can depend on this. | |
- defines = [] | |
+ defines = ["_LIBCPP_HAS_MUSL_LIBC"] | |
cflags = [] | |
ldflags = [] | |
@@ -3558,7 +3557,7 @@ | |
} | |
deps += [ | |
- "//third_party/zlib", | |
+ # "//third_party/zlib", | |
"//third_party/zlib/google:compression_utils_portable", | |
] | |
--- /tmp/rusty_v8/v8/DEPS | |
+++ /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rusty_v8-0.4.2/v8/DEPS | |
@@ -269,8 +269,8 @@ | |
Var('android_url') + '/platform/external/perfetto.git' + '@' + '9bd480acdcad450c5ed5d2aa329eb603c53e5f40', | |
'v8/third_party/protobuf': | |
Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + 'b68a347f56137b4b1a746e8c7438495a6ac1bd91', | |
- 'v8/third_party/zlib': | |
- Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '21c6af6f18e5ad9c3b9d103f8cfdbf926ca35f7c', | |
+ # 'v8/third_party/zlib': | |
+ # Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '21c6af6f18e5ad9c3b9d103f8cfdbf926ca35f7c', | |
'v8/third_party/jsoncpp/source': | |
Var('chromium_url') + '/external/github.com/open-source-parsers/jsoncpp.git'+ '@' + '645250b6690785be60ab6780ce4b58698d884d11', | |
'v8/third_party/ittapi': { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah - this doesn't work anymore.