Use docker cross-build crystal compiler without install bdwgc successful, But, why? shouldn't bdwgc be a required dependency?

Following is a Dockerfile for cross compile a crystal compiler for ARM, it works quite well.

dockerfile
# -*- mode: dockerfile-ts; -*-

# 确保 build 和 linking 是同一个 alpine 版本
ARG alpine_version=3.19
# mirrors.ustc.edu.cn mirrors.tuna.tsinghua.edu.cn
ARG alpine_mirror=mirrors.ustc.edu.cn
ARG llvm_version=17
# https://pkgs.alpinelinux.org/package 搜索 gc 查看版本
ARG gc_version=8.2.4

# =============== 使用本地主机相同的架构 cross compile ===============

# 如果这里不指定 --platform, 则 docker 会自动选择根据命令行 --platform 指定的架构
# 这里强制使用当前 build 所在平台的架构,来高性能的 cross compile.
FROM --platform=$BUILDPLATFORM alpine:$alpine_version AS base

ARG alpine_mirror
ARG llvm_version
RUN sed -i "s/dl-cdn.alpinelinux.org/$alpine_mirror/g" /etc/apk/repositories

# Add trusted CAs for communicating with external services and required build tooling
# 额外添加了 -dev 包,也允许编译动态版本。
# crystal 依赖:libevent-dev libevent-static llvm16-libs musl-dev pcre2-dev gc-dev gcc
RUN set -eux; \
    apk add \
    --update \
    ca-certificates \
    yaml-dev \
    openssl-dev \
    zlib-dev \
    libunwind-dev \
    libssh2-dev \
    lz4-dev \
    sqlite-dev \
    libxml2-dev \
    tzdata \
    crystal shards \
    ;

# build Crystal 编译器必须,build 普通程序一般不需要。
RUN set -eux; \
    apk add \
    --update \
    llvm${llvm_version}-dev \
    g++ make automake libtool autoconf \
    ;

# 为了 https 的情况下,将证书一起部署可以工作,这个似乎是必须的。
RUN update-ca-certificates

# RUN --mount=type=cache,target=/var/cache/apk \
#     set -eux; \
#     apk add \
#     --update \
#     --repository=http://$alpine_mirror/alpine/edge/main \
#     --repository=http://$alpine_mirror/alpine/edge/community \
#     crystal \
#     shards

RUN addgroup -g 1000 docker && \
    adduser -u 1000 -G docker -h /home/docker -s /bin/sh -D docker

USER docker:docker
# WORKDIR 应该放在 USER 后面,因为如果 /app 不存在,需要使用 user docker 创建这个文件夹
WORKDIR /app

FROM base AS build_cross_platform

ARG TARGETARCH

COPY --chown=docker:docker . .

RUN make clean && make crystal stats=1 target=$TARGETARCH static=1 FLAGS="--no-debug --link-flags=-s" |grep '^cc ' |tee app.sh && DESTDIR=/app/tmp/crystal_arm make install && rm -f src/llvm/ext/llvm_ext.o

RUN cat app.sh

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

# ============================== 使用目标系统架构 link binary ==============================

FROM alpine:$alpine_version as link_target

ARG alpine_mirror
ARG llvm_version
RUN sed -i "s/dl-cdn.alpinelinux.org/$alpine_mirror/g" /etc/apk/repositories

# Add trusted CAs for communicating with external services and required build tooling
# 额外添加了 -dev 包,也允许编译动态版本。
# g++ 依赖 libc-dev, libc-dev 依赖 musl-dev
RUN set -eux; \
    apk add \
    --update \
    gc-dev pcre2-dev \
    libevent-static \
    sqlite-static \
    openssl-libs-static \
    yaml-static \
    zlib-static \
    zstd-static \
    libxml2-static \
    llvm${llvm_version}-dev llvm${llvm_version}-static \
    g++ make automake libtool autoconf git \
    ;

# 为了 https 的情况下,将证书一起部署可以工作,这个似乎是必须的。
# RUN update-ca-certificates

# ARG gc_version
# RUN mkdir /bdwgc && cd /bdwgc && \
#     git clone --depth=1 --single-branch --branch=v${gc_version} https://github.com/ivmai/bdwgc.git . && \
#     ./autogen.sh && \
#     ./configure --disable-debug --disable-shared --enable-large-config --prefix=/usr && \
#     make -j$(nproc) CFLAGS="-DNO_GETCONTEXT -pipe -fPIE -O3" && \
#     make install

RUN addgroup -g 1000 docker && \
    adduser -u 1000 -G docker -h /home/docker -s /bin/sh -D docker

USER docker:docker

# WORKDIR 应该放在 USER 后面,因为如果 /app 不存在,需要创建这个文件夹
WORKDIR /app

# All new files and directories are created with a UID and GID of 0, unless the optional --chown flag
COPY --from=build_cross_platform --chown=docker:docker /app/Makefile .
COPY --from=build_cross_platform --chown=docker:docker /app/src/llvm/ext src/llvm/ext
COPY --from=build_cross_platform --chown=docker:docker /app/.build .build
COPY --from=build_cross_platform --chown=docker:docker /app/tmp tmp
COPY --from=build_cross_platform --chown=docker:docker /app/app.sh .

RUN make llvm_ext

RUN sed -i 's#\(cc .*\)#\1 -Wl,-L/app -s#' app.sh
RUN sh -ex app.sh

# Build a minimal docker image
FROM scratch AS mini
WORKDIR /
ENV PATH=$PATH:/

# Copy the user information over
COPY --from=build_cross_platform /etc/passwd /etc/passwd
COPY --from=build_cross_platform /etc/group /etc/group

# These are required for communicating with external services
COPY --from=build_cross_platform /etc/hosts /etc/hosts

# These provide certificate chain validation where communicating with external services over TLS
COPY --from=build_cross_platform /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

# This is required for Timezone support
COPY --from=build_cross_platform /usr/share/zoneinfo/ /usr/share/zoneinfo/

# This is your application
COPY --from=link_target /app /
# COPY --from=build_cross_platform /app/openapi.yml /openapi.yml

USER docker:docker

# Spider-gazelle has a built in helper for health checks (change this as desired for your applications)
# HEALTHCHECK CMD ["/app", "-c", "http://127.0.0.1:3000/"]

# Run the app binding on port 3000
# EXPOSE 3000
ENTRYPOINT ["/app/bin/app"]
# CMD ["/app", "-b", "0.0.0.0", "-p", "3000"]

There are many details we don’t care, anyway, it works.

the question is, when i link the compiler in the target platform, i delete(comment) those code which
compile and install bdwgc, as following:

# ARG gc_version
# RUN mkdir /bdwgc && cd /bdwgc && \
#     git clone --depth=1 --single-branch --branch=v${gc_version} https://github.com/ivmai/bdwgc.git . && \
#     ./autogen.sh && \
#     ./configure --disable-debug --disable-shared --enable-large-config --prefix=/usr && \
#     make -j$(nproc) CFLAGS="-DNO_GETCONTEXT -pipe -fPIE -O3" && \
#     make install

It’s seem like all process work just well.

docker logs

╰─ $ crystal_build_cross_compile_binary crystal_cross_compile_builder

  1. aarch64-linux-musl 4) aarch64-darwin 7) i386-linux-musl 10) x86_64-darwin
  2. x86_64-linux-musl 5) arm-linux-gnueabihf 8) x86_64-openbsd 11) x86_64-linux-gnu
  3. aarch64-linux-gnu 6) i386-linux-gnu 9) x86_64-freebsd
    Select Crystal cross compile target:2

Selected target=x86_64-linux-musl

  1. linux/arm64/v8 3) linux/386 5) linux/arm/v7 7) linux/ppc64le
  2. linux/amd64 4) linux/arm/v6 6) linux/386 8) linux/s390x
    Select docker buildx arch for linking:2

Selected arch=linux/amd64

crystal_cross_compile_builder * docker-container
crystal_cross_compile_builder0 unix:///var/run/docker.sock running v0.12.4 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386
#0 building with “crystal_cross_compile_builder” instance using docker-container driver

#1 [internal] load build definition from crystal_cross_compile_builder.dockerfile
#1 transferring dockerfile: 5.65kB done
#1 DONE 0.0s

#2 [auth] library/alpine:pull token for registry-1.docker.io
#2 DONE 0.0s

#3 [internal] load metadata for Docker
#3 DONE 3.5s

#4 [internal] load .dockerignore
#4 transferring context: 2B done
#4 DONE 0.0s

#5 [link_target 1/13] FROM Docker
#5 resolve Docker done
#5 DONE 0.0s

#6 [internal] load build context
#6 transferring context: 1.39GB 5.1s
#6 transferring context: 1.71GB 6.5s done
#6 DONE 6.6s

#7 [base 5/7] RUN update-ca-certificates
#7 CACHED

#8 [base 6/7] RUN addgroup -g 1000 docker && adduser -u 1000 -G docker -h /home/docker -s /bin/sh -D docker
#8 CACHED

#9 [link_target 2/13] RUN sed -i “s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g” /etc/apk/repositories
#9 CACHED

#10 [base 3/7] RUN set -eux; apk add --update ca-certificates yaml-dev openssl-dev zlib-dev libunwind-dev libssh2-dev lz4-dev sqlite-dev libxml2-dev tzdata crystal shards ;
#10 CACHED

#11 [base 4/7] RUN set -eux; apk add --update llvm17-dev g++ make automake libtool autoconf ;
#11 CACHED

#12 [base 7/7] WORKDIR /app
#12 CACHED

#13 [build_cross_platform 1/3] COPY --chown=docker:docker . .
#13 DONE 4.8s

#14 [build_cross_platform 2/3] RUN make clean && make crystal stats=1 target=x86_64-linux-musl static=1 FLAGS=“–no-debug --link-flags=-s” |grep ‘^cc ’ |tee app.sh && DESTDIR=/app/tmp/crystal_arm make install && rm -f src/llvm/ext/llvm_ext.o
#14 0.330 rm -rf .build
#14 0.331 rm -rf ./docs
#14 0.332 rm -rf src/llvm/ext/llvm_ext.o
#14 0.333 rm -rf man/*.gz
#14 0.367 Using /usr/bin/llvm-config [version= 17.0.5]cc .build/crystal.o -o .build/crystal -s -rdynamic -static -L/usr/bin/…/lib/crystal /app/src/llvm/ext/llvm_ext.o /usr/bin/llvm-config --libs --system-libs --ldflags --link-static 2> /dev/null -lstdc++ -lpcre2-8 -lgc -lpthread -ldl -levent
#14 36.74 Using /usr/bin/llvm-config [version= 17.0.5]CRYSTAL_CONFIG_BUILD_COMMIT=“0aa30372c” CRYSTAL_CONFIG_PATH=’$ORIGIN/…/share/crystal/src’ SOURCE_DATE_EPOCH=“1705004137” CRYSTAL_CONFIG_LIBRARY_PATH=‘$ORIGIN/…/lib/crystal’ ./bin/crystal build -D strict_multi_assign -D preview_overload_order -Dwithout_interpreter -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib -D use_pcre2
#14 63.19 gzip -c -9 man/crystal.1 > man/crystal.1.gz
#14 63.19 /usr/bin/install -d -m 0755 “/app/tmp/crystal_arm/usr/local/bin/”
#14 63.19 /usr/bin/install -m 0755 “.build/crystal” “/app/tmp/crystal_arm/usr/local/bin/crystal”

#14 63.31 /usr/bin/install -m 644 etc/completion.fish “/app/tmp/crystal_arm/usr/local/share/fish/vendor_completions.d/crystal.fish”
#14 DONE 63.5s

#15 [build_cross_platform 3/3] RUN cat app.sh
#15 0.073 cc .build/crystal.o -o .build/crystal -s -rdynamic -static -L/usr/bin/…/lib/crystal /app/src/llvm/ext/llvm_ext.o /usr/bin/llvm-config --libs --system-libs --ldflags --link-static 2> /dev/null -lstdc++ -lpcre2-8 -lgc -lpthread -ldl -levent
#15 DONE 0.1s

#9 [link_target 2/13] RUN sed -i “s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g” /etc/apk/repositories
#9 CACHED

#16 [link_target 3/13] RUN set -eux; apk add --update gc-dev pcre2-dev libevent-static sqlite-static openssl-libs-static yaml-static zlib-static zstd-static libxml2-static llvm17-dev llvm17-static g++ make automake libtool autoconf git ;
#16 0.091 + apk add --update gc-dev pcre2-dev libevent-static sqlite-static openssl-libs-static yaml-static zlib-static zstd-static libxml2-static llvm17-dev llvm17-static g++ make automake libtool autoconf git
#16 0.094 fetch https://mirrors.ustc.edu.cn/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
#16 1.014 fetch https://mirrors.ustc.edu.cn/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
#16 1.510 (1/84) Installing m4 (1.4.19-r3)
#16 1.630 (2/84) Installing libbz2 (1.0.8-r6)
#16 1.727 (3/84) Installing perl (5.38.2-r0)
#16 3.439 (4/84) Installing autoconf (2.71-r2)
#16 3.610 (5/84) Installing automake (1.16.5-r2)
#16 3.761 (6/84) Installing libgcc (13.2.1_git20231014-r0)
#16 3.858 (7/84) Installing libstdc++ (13.2.1_git20231014-r0)
#16 4.077 (8/84) Installing libstdc+±dev (13.2.1_git20231014-r0)
#16 4.700 (9/84) Installing jansson (2.14-r4)
#16 4.788 (10/84) Installing zstd-libs (1.5.5-r8)
#16 4.937 (11/84) Installing binutils (2.41-r0)
#16 5.485 (12/84) Installing libgomp (13.2.1_git20231014-r0)
#16 5.596 (13/84) Installing libatomic (13.2.1_git20231014-r0)
#16 5.683 (14/84) Installing gmp (6.3.0-r0)
#16 5.802 (15/84) Installing isl26 (0.26-r1)
#16 6.020 (16/84) Installing mpfr4 (4.2.1-r0)
#16 6.154 (17/84) Installing mpc1 (1.3.1-r1)
#16 6.254 (18/84) Installing gcc (13.2.1_git20231014-r0)
#16 13.98 (19/84) Installing musl-dev (1.2.4_git20230717-r4)
#16 14.57 (20/84) Installing libc-dev (0.7.2-r5)
#16 14.65 (21/84) Installing g++ (13.2.1_git20231014-r0)
#16 16.96 (22/84) Installing gc (8.2.4-r1)
#16 17.06 (23/84) Installing libgc++ (8.2.4-r1)
#16 17.15 (24/84) Installing pkgconf (2.1.0-r0)
#16 17.24 (25/84) Installing gc-dev (8.2.4-r1)
#16 17.41 (26/84) Installing ca-certificates (20230506-r0)
#16 17.53 (27/84) Installing brotli-libs (1.1.0-r1)
#16 17.68 (28/84) Installing c-ares (1.24.0-r0)
#16 17.77 (29/84) Installing libunistring (1.1-r2)
#16 17.96 (30/84) Installing libidn2 (2.3.4-r4)
#16 18.07 (31/84) Installing nghttp2-libs (1.58.0-r0)
#16 18.17 (32/84) Installing libcurl (8.5.0-r0)
#16 18.30 (33/84) Installing libexpat (2.5.0-r2)
#16 18.40 (34/84) Installing pcre2 (10.42-r2)
#16 18.53 (35/84) Installing git (2.43.0-r0)
#16 19.08 (36/84) Installing perl-error (0.17029-r2)
#16 19.17 (37/84) Installing perl-git (2.43.0-r0)
#16 19.27 (38/84) Installing git-perl (2.43.0-r0)
#16 19.35 (39/84) Installing libevent-static (2.1.12-r7)
#16 19.49 (40/84) Installing libltdl (2.4.7-r3)
#16 19.59 (41/84) Installing libtool (2.4.7-r3)
#16 19.76 (42/84) Installing libffi (3.4.4-r3)
#16 19.85 (43/84) Installing gdbm (1.23-r1)
#16 19.94 (44/84) Installing xz-libs (5.4.5-r0)
#16 20.04 (45/84) Installing mpdecimal (2.5.1-r2)
#16 20.14 (46/84) Installing ncurses-terminfo-base (6.4_p20231125-r0)
#16 20.23 (47/84) Installing libncursesw (6.4_p20231125-r0)
#16 20.34 (48/84) Installing libpanelw (6.4_p20231125-r0)
#16 20.42 (49/84) Installing readline (8.2.1-r2)
#16 20.53 (50/84) Installing sqlite-libs (3.44.2-r0)
#16 20.73 (51/84) Installing python3 (3.11.6-r1)
#16 22.11 (52/84) Installing python3-pycache-pyc0 (3.11.6-r1)
#16 22.98 (53/84) Installing pyc (3.11.6-r1)
#16 23.07 (54/84) Installing python3-pyc (3.11.6-r1)
#16 23.15 (55/84) Installing libxml2-static (2.11.6-r0)
#16 23.68 (56/84) Installing libxml2 (2.11.6-r0)
#16 23.84 (57/84) Installing llvm17-libs (17.0.5-r0)
#16 32.74 (58/84) Installing llvm17-linker-tools (17.0.5-r0)
#16 32.84 (59/84) Installing llvm17 (17.0.5-r0)
#16 40.16 (60/84) Installing linux-headers (6.5-r0)
#16 40.53 (61/84) Installing libffi-dev (3.4.4-r3)
#16 40.63 (62/84) Installing zlib-dev (1.3-r2)
#16 40.73 (63/84) Installing zstd (1.5.5-r8)
#16 40.83 (64/84) Installing zstd-dev (1.5.5-r8)
#16 40.94 (65/84) Installing llvm17-test-utils (17.0.5-r0)
#16 41.11 (66/84) Installing llvm17-test-utils-pyc (17.0.5-r0)
#16 41.22 (67/84) Installing llvm17-dev (17.0.5-r0)
#16 42.08 (68/84) Installing llvm17-static (17.0.5-r0)
#16 56.00 (69/84) Installing make (4.4.1-r2)
#16 56.11 (70/84) Installing openssl-libs-static (3.1.4-r3)
#16 57.85 (71/84) Installing bsd-compat-headers (0.7.2-r5)
#16 57.94 (72/84) Installing libformw (6.4_p20231125-r0)
#16 58.03 (73/84) Installing libmenuw (6.4_p20231125-r0)
#16 58.13 (74/84) Installing libncurses++ (6.4_p20231125-r0)
#16 58.21 (75/84) Installing ncurses-dev (6.4_p20231125-r0)
#16 58.32 (76/84) Installing libedit (20230828.3.1-r3)
#16 58.43 (77/84) Installing libedit-dev (20230828.3.1-r3)
#16 58.51 (78/84) Installing libpcre2-16 (10.42-r2)
#16 58.64 (79/84) Installing libpcre2-32 (10.42-r2)
#16 58.76 (80/84) Installing pcre2-dev (10.42-r2)
#16 58.98 (81/84) Installing sqlite-static (3.44.2-r0)
#16 59.19 (82/84) Installing yaml-static (0.2.5-r2)
#16 59.29 (83/84) Installing zlib-static (1.3-r2)
#16 59.39 (84/84) Installing zstd-static (1.5.5-r8)
#16 60.02 Executing busybox-1.36.1-r15.trigger
#16 60.03 Executing ca-certificates-20230506-r0.trigger
#16 60.06 OK: 1039 MiB in 99 packages
#16 DONE 60.3s

#17 [link_target 4/13] RUN addgroup -g 1000 docker && adduser -u 1000 -G docker -h /home/docker -s /bin/sh -D docker
#17 DONE 0.1s

#18 [link_target 5/13] WORKDIR /app
#18 DONE 0.0s

#19 [link_target 6/13] COPY --from=build_cross_platform --chown=docker:docker /app/Makefile .
#19 DONE 0.0s

#20 [link_target 7/13] COPY --from=build_cross_platform --chown=docker:docker /app/src/llvm/ext src/llvm/ext
#20 DONE 0.0s

#21 [link_target 8/13] COPY --from=build_cross_platform --chown=docker:docker /app/.build .build
#21 DONE 0.2s

#22 [link_target 9/13] COPY --from=build_cross_platform --chown=docker:docker /app/tmp tmp
#22 DONE 0.6s

#23 [link_target 10/13] COPY --from=build_cross_platform --chown=docker:docker /app/app.sh .
#23 DONE 0.0s

#24 [link_target 11/13] RUN make llvm_ext
#24 0.046 find: spec: No such file or directory
#24 0.059 Using /usr/bin/llvm-config [version= 17.0.5]g++ -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/lib/llvm17/include -std=c++17 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
#24 DONE 1.2s

#25 [link_target 12/13] RUN sed -i ‘s#(cc .*)#\1 -Wl,-L/app -s#’ app.sh
#25 DONE 0.1s

#26 [link_target 13/13] RUN sh -ex app.sh
#26 0.020 + /usr/bin/llvm-config --libs --system-libs --ldflags --link-static
#26 0.023 + cc .build/crystal.o -o .build/crystal -s -rdynamic -static -L/usr/bin/…/lib/crystal /app/src/llvm/ext/llvm_ext.o -L/usr/lib/llvm17/lib -lLLVMWindowsManifest -lLLVMXRay -lLLVMLibDriver -lLLVMDlltoolDriver -lLLVMCoverage -lLLVMLineEditor -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMX86TargetMCA -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyUtils -lLLVMWebAssemblyDesc -lLLVMWebAssemblyInfo -lLLVMVEDisassembler -lLLVMVEAsmParser -lLLVMVECodeGen -lLLVMVEDesc -lLLVMVEInfo -lLLVMSystemZDisassembler -lLLVMSystemZAsmParser -lLLVMSystemZCodeGen -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcAsmParser -lLLVMSparcCodeGen -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMRISCVTargetMCA -lLLVMRISCVDisassembler -lLLVMRISCVAsmParser -lLLVMRISCVCodeGen -lLLVMRISCVDesc -lLLVMRISCVInfo -lLLVMPowerPCDisassembler -lLLVMPowerPCAsmParser -lLLVMPowerPCCodeGen -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430AsmParser -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsAsmParser -lLLVMMipsCodeGen -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMLoongArchDisassembler -lLLVMLoongArchAsmParser -lLLVMLoongArchCodeGen -lLLVMLoongArchDesc -lLLVMLoongArchInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFAsmParser -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMAVRDisassembler -lLLVMAVRAsmParser -lLLVMAVRCodeGen -lLLVMAVRDesc -lLLVMAVRInfo -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDesc -lLLVMARMUtils -lLLVMARMInfo -lLLVMAMDGPUTargetMCA -lLLVMAMDGPUDisassembler -lLLVMAMDGPUAsmParser -lLLVMAMDGPUCodeGen -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMAArch64Disassembler -lLLVMAArch64AsmParser -lLLVMAArch64CodeGen -lLLVMAArch64Desc -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMPerfJITEvents -lLLVMOrcJIT -lLLVMWindowsDriver -lLLVMMCJIT -lLLVMJITLink -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMOrcTargetProcess -lLLVMOrcShared -lLLVMDWP -lLLVMDebugInfoLogicalView -lLLVMDebugInfoGSYM -lLLVMOption -lLLVMObjectYAML -lLLVMObjCopy -lLLVMMCA -lLLVMMCDisassembler -lLLVMLTO -lLLVMPasses -lLLVMCFGuard -lLLVMCoroutines -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMInstrumentation -lLLVMFrontendOpenMP -lLLVMFrontendOpenACC -lLLVMFrontendHLSL -lLLVMExtensions -lLLVMDWARFLinkerParallel -lLLVMDWARFLinker -lLLVMGlobalISel -lLLVMMIRParser -lLLVMAsmPrinter -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMTarget -lLLVMObjCARCOpts -lLLVMCodeGenTypes -lLLVMIRPrinter -lLLVMInterfaceStub -lLLVMFileCheck -lLLVMFuzzMutate -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMSymbolize -lLLVMDebugInfoBTF -lLLVMDebugInfoPDB -lLLVMDebugInfoMSF -lLLVMDebugInfoDWARF -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMIRReader -lLLVMAsmParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMBitReader -lLLVMFuzzerCLI -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMTargetParser -lLLVMTableGen -lLLVMSupport -lLLVMDemangle -lrt -ldl -lm -lz -lzstd -lxml2 -lstdc++ -lpcre2-8 -lgc -lpthread -ldl -levent -Wl,-L/app -s
#26 DONE 4.4s

#27 [mini 1/7] COPY --from=build_cross_platform /etc/passwd /etc/passwd
#27 DONE 0.0s

#28 [mini 2/7] COPY --from=build_cross_platform /etc/group /etc/group
#28 DONE 0.0s

#29 [mini 3/7] COPY --from=build_cross_platform /etc/hosts /etc/hosts
#29 DONE 0.0s

#30 [mini 4/7] COPY --from=build_cross_platform /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
#30 DONE 0.0s

#31 [mini 5/7] COPY --from=build_cross_platform /usr/share/zoneinfo/ /usr/share/zoneinfo/
#31 DONE 0.1s

#32 [mini 6/7] COPY --from=link_target /app /
#32 DONE 0.7s

#33 exporting to client directory
#33 copying files 54.69MB 0.1s
#33 copying files 330.84MB 0.7s done
#33 DONE 0.7s

As above logs, i even cross compile a static AMD64 compiler on the AMD64 linux host use docker, and try
build some of my projects use new compiler, it works, just there are a lot of warnings when compiling.

Interesting, so what exactly is the difference with or without bdwgc? how to know that?

why no bdwgc, my compiled program can run?

Thanks

You’re installing the libgc dev package two commands above.

Yes, i know, it necessary for linking like -lgc, is there something I understand wrong?

Current gc version is 8.2.4, my question is, why not install git clone --depth=1 --single-branch --branch=v8.2.4 https://github.com/ivmai/bdwgc.git, i can still successfully compile Crystal and run it?

What is missing? If don’t run the following code on the linking stage.

git clone --depth=1 --single-branch --branch=v8.2.4 https://github.com/ivmai/bdwgc.git . && \
    ./autogen.sh && \
    ./configure --disable-debug --disable-shared --enable-large-config --prefix=/usr && \
    make -j$(nproc) CFLAGS="-DNO_GETCONTEXT -pipe -fPIE -O3" && \
    make install

The “gc-dev” is the name label for the bdwgc package, which can also be installed manually from GitHub.

I may not have understood your question correctly, but I think that is what straight-shoota meant in his answer.

Thank you, I understand now, it seems completely unnecessary compile https://github.com/ivmai/bdwgc.git myself, it same as gc-dev