dart-lang / dart-docker

Docker images for the Dart programming language (https://dart.dev)
BSD 3-Clause "New" or "Revised" License
67 stars 15 forks source link

libatomic.so.1 needed in /runtime for RISC-V #141

Open cpswan opened 1 year ago

cpswan commented 1 year ago

Whilst testing container images with AOT binaries created from build images based on #140 I found that they wouldn't run:

/myaotbinaryname: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory

This can be remedied by copying /usr/lib/riscv64-linux-gnu/libatomic.so.1 into /runtime so it's available in the container.

I'm not entirely sure that this is a RISC-V specific thing, but given that many more people are likely to be testing Dart 3 betas on other platforms it's a strong possibility.

docker run atsigncompany/dartshowplatform:GHA_634 provides an example of a container without libatomic.so.1:

Unable to find image 'atsigncompany/dartshowplatform:GHA_634' locally
GHA_634: Pulling from atsigncompany/dartshowplatform
Digest: sha256:b85c81c69810999812baa6cc3e9ba32375d983bc4b5a9b27c4b15122093b5e6a
Status: Downloaded newer image for atsigncompany/dartshowplatform:GHA_634
/app/dartshowplatform: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory

Whilst docker run atsigncompany/dartshowplatform:GHA_635 provides an example of a container with libatomic.so.1 in the linux/riscv64 image:

Unable to find image 'atsigncompany/dartshowplatform:GHA_635' locally
GHA_635: Pulling from atsigncompany/dartshowplatform
Digest: sha256:a3bb9afd99a2b981ac29fd8d4dea21d1d6a03f1cd03b3dfd9e36adf864b6e24c
Status: Downloaded newer image for atsigncompany/dartshowplatform:GHA_635
3.0.0-290.3.beta (beta) (Tue Mar 21 16:51:50 2023 +0000) on "linux_riscv64"

Source for the examples above is at https://github.com/atsign-company/at_dockerfiles

cpswan commented 1 year ago

It seems that libatomic.so.1 has been removed from the debian:unstable image for linux/riscv64 but it's still needed by dart compile exe (testing with 3.2.0-42.1.beta).

To deal with this I've modified the Dockerfile to install libatomic1:

RUN set -eux; \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        dnsutils \
        git \
        libatomic1 \
        openssh-client \
        unzip \
    ; \
    rm -rf /var/lib/apt/lists/*

and then added the library to the list that gets copied into runtime:

        riscv64) \
            TRIPLET="riscv64-linux-gnu" ; \
            FILES="/lib/ld-linux-riscv64-lp64d.so.1 \
                /lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1 \
                /usr/lib/riscv64-linux-gnu/libatomic.so.1" ;; \
cpswan commented 13 hours ago

Seems this isn't needed for Ubuntu 24.04.