FROM gcc:12-bookworm@sha256:3d3af69c72edf0652bb3a829965142e81891899c7827d849bc3c0dbb9edd216a

WORKDIR /src
COPY . /src

RUN chmod +x configure tools/install.sh \
	&& sh ./configure \
		--prefix=/opt/musl \
		--syslibdir=/opt/musl/lib \
	&& make -s -j"$(nproc)" \
	&& make -s install

RUN /opt/musl/bin/musl-gcc \
	-O2 \
	-g \
	-fno-omit-frame-pointer \
	-static \
	-no-pie \
	-o /opt/posix-memalign-extreme \
	/src/poc/malloc/posix-memalign-extreme.c

ENTRYPOINT []
CMD ["/bin/sh", "-c", "ulimit -c 0; exec /opt/posix-memalign-extreme"]
