Skip to content

Commit

Permalink
Hermetify
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Nov 28, 2024
1 parent 24edfac commit dbf1e5e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Dockerfile.lfortran
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ RUN apt update -y -q && apt upgrade -y -q && apt update -y -q && \
git \
libzstd-dev \
llvm-12-dev \
ninja-build \
patchelf \
python-is-python3 \
python3 \
re2c \
Expand Down
32 changes: 27 additions & 5 deletions lfortran/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,33 @@ REVISION=$(get_remote_revision "${URL}" "${REMOTE}")

initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"

OUTPUT=$(realpath "${OUTPUT}")

git clone "${URL}" --depth=1 "--branch=${BRANCH}"
cd lfortran
./build_release.sh
DEST=$(realpath inst)

OUTPUT=$(realpath "${OUTPUT}")
DEST=$(realpath prefix)
SOURCE=$(realpath lfortran)

mkdir build
cmake \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_RELEASE="-Wall -Wextra -O3 -funroll-loops -DNDEBUG" \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_INSTALL_PREFIX="${DEST}" \
-DCMAKE_INSTALL_LIBDIR=share/lfortran/lib \
-Bbuild \
-S"${SOURCE}"
ninja -C build
ninja -C build install

mkdir "${DEST}/lib"

# Copy all shared object dependencies into the release directory to create a hermetic build, per
# Compiler Explorer requirements. Update rpath for these objects to $ORIGIN.
cp $(ldd "${DEST}/bin/lfortran" | grep -E '=> /' | grep -Ev 'lib(pthread|c|dl|rt).so' | awk '{print $3}') "${DEST}/lib"
patchelf --set-rpath '$ORIGIN/../lib' "${DEST}/bin/lfortran"

complete "${DEST}" "${FULLNAME}" "${OUTPUT}"

0 comments on commit dbf1e5e

Please sign in to comment.