I am encountering problems to install and run the MLton compiler in a Docker container using Alpine Linux. Is there a way to install this compiler on this system?
Try #1
Using the standard `alpine base image and the binary distribution of MLton:
$ curl http://sourceforge.net/projects/mlton/files/mlton/20130715/mlton-20130715-1.amd64-linux.tgz --output mlton-20130715-1.amd64-linux.tgz
$ docker build .
With the following Dockerfile:
FROM alpine
COPY mlton-20130715-1.amd64-linux.tgz /
RUN apk add --no-cache bash build-base gmp-dev linux-headers \
&& tar xf /mlton-20130715-1.amd64-linux.tgz \
--directory /usr/ \
--strip-components 1 \
&& echo 'print "Hello, world!\n";' >> hello-world.sml \
&& mlton hello-world.sml
Docker build fails with the following error message, probably because glibc
is missing.
/usr/bin/mlton: line 52: /usr/lib/mlton/mlton-compile: No such file or directory
Try #2
The same as above, with a base Docker image that embeds glibc
:
FROM frolvlad/alpine-glibc
This time, mlton
runs, but produces the following error:
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/lib/mlton/targets/self/libmlton.a(platform.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
...
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
call to system failed with exit status 1:
gcc -o hello-world /tmp/fileGEluFu.o /tmp/fileYnNjh9.o -L/usr/lib/mlton/targets/self -lmlton -lgdtoa -lm -lgmp -m64 -Wl,-znoexecstack
Any idea on how to solve this problem?