Skip to content

Commit

Permalink
Makes the devcontainer use our assertion-enabled binaries. (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrahams authored Mar 1, 2024
1 parent 649255c commit 9834afc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
27 changes: 22 additions & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
ARG SWIFT_VERSION
ARG SWIFT_VERSION=5.9

FROM swift:${SWIFT_VERSION}

RUN apt-get update && \
apt-get install -y \
libllvm15 llvm-15 llvm-15-dev llvm-15-doc llvm-15-examples llvm-15-runtime
ARG HYLO_LLVM_BUILD_RELEASE=2024-02-29-r2
ARG LLVM_VERSION=17.0.6

RUN ln -s /usr/bin/llvm-config-15 /usr/bin/llvm-config
ENV HYLO_LLVM_DOWNLOAD_URL="https://github.com/hylo-lang/llvm-build/releases/download"

RUN apt-get clean
RUN apt-get update
RUN apt-get install -y tar zstd libzstd1 libzstd-dev

ADD ${HYLO_LLVM_DOWNLOAD_URL}/${HYLO_LLVM_BUILD_RELEASE}/llvm-${LLVM_VERSION}-x86_64-unknown-linux-gnu-Debug.tar.zst /opt
RUN tar -x --zstd -f /opt/llvm-${LLVM_VERSION}-x86_64-unknown-linux-gnu-Debug.tar.zst -C /opt

ADD ${HYLO_LLVM_DOWNLOAD_URL}/${HYLO_LLVM_BUILD_RELEASE}/llvm-${LLVM_VERSION}-x86_64-unknown-linux-gnu-MinSizeRel.tar.zst /opt
RUN tar -x --zstd -f /opt/llvm-${LLVM_VERSION}-x86_64-unknown-linux-gnu-MinSizeRel.tar.zst -C /opt

ADD ${HYLO_LLVM_DOWNLOAD_URL}/${HYLO_LLVM_BUILD_RELEASE}/llvm-${LLVM_VERSION}-aarch64-unknown-linux-gnu-Debug.tar.zst /opt
RUN tar -x --zstd -f /opt/llvm-${LLVM_VERSION}-aarch64-unknown-linux-gnu-Debug.tar.zst -C /opt

ADD ${HYLO_LLVM_DOWNLOAD_URL}/${HYLO_LLVM_BUILD_RELEASE}/llvm-${LLVM_VERSION}-aarch64-unknown-linux-gnu-MinSizeRel.tar.zst /opt
RUN tar -x --zstd -f /opt/llvm-${LLVM_VERSION}-aarch64-unknown-linux-gnu-MinSizeRel.tar.zst -C /opt

RUN rm /opt/llvm-*.tar.zst
15 changes: 9 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "Swift",
"name": "Hylo LLVM",
"build": {
"dockerfile": "Dockerfile",
"args": {
"SWIFT_VERSION" : "5.7"
"SWIFT_VERSION" : "5.9"
}
},
"features": {
Expand Down Expand Up @@ -40,10 +40,13 @@
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "swift --version && sudo ./Tools/make-pkgconfig.sh /usr/local/lib/pkgconfig/llvm.pc",

"containerEnv": {
"HYLO_LLVM_BUILD_TYPE": "${localEnv:HYLO_LLVM_BUILD_TYPE:MinSizeRel}"
},
"remoteEnv": {
"PATH": "/opt/llvm-${containerEnv:HYLO_LLVM_BUILD_TYPE}/bin:${containerEnv:PATH}"
},
"postCreateCommand": "sudo ./.devcontainer/postCreateCommand.sh",
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
12 changes: 12 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
set -o pipefail

echo "Hylo LLVM build type: $HYLO_LLVM_BUILD_TYPE"
echo

ln -s /opt/llvm-*-$(uname -m)-*-Debug /opt/llvm-Debug
ln -s /opt/llvm-*-$(uname -m)-*-MinSizeRel /opt/llvm-MinSizeRel

export PATH="/opt/llvm-$HYLO_LLVM_BUILD_TYPE/bin:$PATH"
./Tools/make-pkgconfig.sh /usr/local/lib/pkgconfig/llvm.pc
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:

- name: Build and run devcontainer task
uses: devcontainers/[email protected]
env:
HYLO_LLVM_BUILD_TYPE: ${{ matrix.configuration == 'debug' && 'Debug' || 'MinSizeRel' }}
with:
runCmd: swift test --parallel -v -c ${{ matrix.configuration }} ${{ matrix.host.test-options }}

Expand Down

0 comments on commit 9834afc

Please sign in to comment.