Skip to content

Commit

Permalink
feat: Add minicoro/coroutines support (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibordp authored Sep 9, 2024
1 parent 4dcc284 commit 1fc7262
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ RUN apt-get update && apt-get install -y \
make \
pkg-config \
protobuf-compiler \
gosu
gosu \
curl

WORKDIR /build/nsjail
RUN git clone https:/google/nsjail.git .
RUN make -j8
WORKDIR /build/libbacktrace
RUN git clone https:/ianlancetaylor/libbacktrace.git .
RUN ./configure && make -j8
WORKDIR /build/minicoro
RUN curl -Ss -o minicoro.h https://raw.githubusercontent.com/edubart/minicoro/main/minicoro.h
RUN gcc -O0 -g3 -fPIE -rdynamic -DMINICORO_IMPL -xc -c -o minicoro.o minicoro.h && \
ar rcs libminicoro.a minicoro.o

FROM ubuntu:24.04 as combined

Expand Down Expand Up @@ -66,6 +71,7 @@ RUN /usr/bin/alumina-boot \
--debug \
--cfg threading \
--cfg use_libbacktrace \
--cfg coroutines \
-Zast-only \
-Zdump-ast=/usr/include/alumina/sysroot.ast

Expand All @@ -75,14 +81,17 @@ RUN /usr/bin/alumina-boot \
--cfg test \
--cfg threading \
--cfg use_libbacktrace \
--cfg coroutines \
-Zast-only \
-Zdump-ast=/usr/include/alumina/sysroot-test.ast

COPY --from=deps /build/nsjail/nsjail /usr/bin/nsjail
COPY --from=deps /build/libbacktrace/.libs/libbacktrace.a /usr/local/lib/libbacktrace.a
COPY --from=deps /build/minicoro/libminicoro.a /usr/local/lib/libminicoro.a
COPY --from=combined /app .

RUN ranlib /usr/local/lib/libbacktrace.a
RUN ranlib /usr/local/lib/libbacktrace.a && \
ranlib /usr/local/lib/libminicoro.a

ENV NODE_ENV production
ENV CACHE_AST 1
Expand Down
6 changes: 3 additions & 3 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ touch compiler.output

if [[ -v TEST ]]; then
minimum_security_prison $ALUMINA_BOOT \
$alumina_extra_args --debug --cfg threading --cfg use_libbacktrace --cfg test \
$alumina_extra_args --debug --cfg threading --cfg use_libbacktrace --cfg coroutines --cfg test \
playground=program.alu \
-o program.c &>> compiler.output
extra_env="-E CLICOLOR_FORCE=1"
else
minimum_security_prison $ALUMINA_BOOT \
$alumina_extra_args --debug --cfg threading --cfg use_libbacktrace \
$alumina_extra_args --debug --cfg threading --cfg use_libbacktrace --cfg coroutines \
playground=program.alu \
-o program.c &>> compiler.output
extra_env=""
fi

minimum_security_prison gcc -w -fdiagnostics-color=always \
-O0 -g3 -fPIE -rdynamic -o program.out program.c -lm -lpthread -lbacktrace \
-O0 -g3 -fPIE -rdynamic -o program.out program.c -lm -lpthread -lbacktrace -lminicoro \
&>> compiler.output

echo 0 > program.ret
Expand Down

0 comments on commit 1fc7262

Please sign in to comment.