From e054af58c65b9345b3bfcacd34966c2009edca7c Mon Sep 17 00:00:00 2001 From: Emil Abbasov Date: Thu, 30 May 2024 22:23:40 -0400 Subject: [PATCH] =?UTF-8?q?-=20upgraded=20to=20LLVM=5FVERSION=3D13=20both?= =?UTF-8?q?=20on=20sledge=20&=20AWSM=20-=20updated=20dockerfile,=20main.ya?= =?UTF-8?q?ml=20-=20added=20new=20uninstall=5Fllvm.sh=20script=20to=20ease?= =?UTF-8?q?=C2=A0LLVM=C2=A0removal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yaml | 7 ++++--- Dockerfile.x86_64 | 8 +++++--- applications/Makefile | 7 +------ install_deb.sh | 8 +++++--- install_llvm.sh | 26 +++++++++++++------------- uninstall_llvm.sh | 21 +++++++++++++++++++++ 6 files changed, 49 insertions(+), 28 deletions(-) create mode 100755 uninstall_llvm.sh diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d1bd04f2a..736dc7136 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,7 +4,7 @@ on: [push, pull_request] env: LLVM_VERSION: 13 - WASI_SDK_URL: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz + WASI_SDK_VERSION: 12 WASI_SDK_PATH: /opt/wasi-sdk LANG: C.UTF-8 LANGUAGE: C.UTF-8 @@ -18,10 +18,10 @@ jobs: - name: Apt Update run: sudo apt-get update - uses: actions/checkout@v2 - - name: Install LLVM + - name: Install Clang Format run: | sudo ./install_llvm.sh $LLVM_VERSION - - name: Clang Format + - name: Run Clang Format run: ./format.sh -d test: runs-on: ubuntu-20.04 @@ -62,6 +62,7 @@ jobs: echo "/root/.cargo/bin:$PATH" >> $GITHUB_PATH - name: Get wasi-sdk run: | + WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-linux.tar.gz wget $WASI_SDK_URL -O wasi-sdk.tar.gz mkdir -p $WASI_SDK_PATH tar xvfz wasi-sdk.tar.gz --strip-components=1 -C $WASI_SDK_PATH diff --git a/Dockerfile.x86_64 b/Dockerfile.x86_64 index 35c4d3aaa..fb9163f92 100644 --- a/Dockerfile.x86_64 +++ b/Dockerfile.x86_64 @@ -1,9 +1,12 @@ # using ubuntu 20 docker image FROM ubuntu:focal +ENV LLVM_VERSION=13 +ENV WASI_SDK_VERSION=12 + ARG DEBIAN_FRONTEND=noninteractive ARG HEY_URL=https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 -ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk_12.0_amd64.deb +ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb ARG SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.2.4/shfmt_v3.2.4_linux_amd64 ARG SHELLCHECK_URL=https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz @@ -74,12 +77,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ vim \ wabt -ENV LLVM_VERSION=12 ADD install_llvm.sh /sledge/install_llvm.sh RUN ./sledge/install_llvm.sh $LLVM_VERSION # WASI-SDK -RUN curl -sS -L -O $WASI_SDK_URL && dpkg -i wasi-sdk_12.0_amd64.deb && rm -f wasi-sdk_12.0_amd64.deb +RUN curl -sS -L -O $WASI_SDK_URL && dpkg -i wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb && rm -f wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb ENV WASI_SDK_PATH=/opt/wasi-sdk # Create non-root user and add to sudoers diff --git a/applications/Makefile b/applications/Makefile index d600d7879..382b87026 100644 --- a/applications/Makefile +++ b/applications/Makefile @@ -28,15 +28,10 @@ all: \ resize_image.install \ cnn_face_detection.install \ get_jpeg_resolution.install \ - scratch_storage_get.install \ - scratch_storage_set.install \ - scratch_storage_delete.install \ - scratch_storage_upsert.install \ .PHONY: clean clean: @make -C wasm_apps clean - @make -C scratch_storage clean @rm -rf dist @rm -rf ../runtime/bin/*.so @@ -70,7 +65,7 @@ dist/%.bc: ./wasm_apps/dist/%.wasm dist ${AWSMCC} ${AWSMFLAGS} $< -o $@ dist/%.ll: dist/%.bc - llvm-dis-12 $< -o $@ + llvm-dis $< -o $@ dist/%.wasm.so: dist/%.bc ${CC} ${CFLAGS} ${LDFLAGS} $^ -o $@ diff --git a/install_deb.sh b/install_deb.sh index 796c031b6..b83e1e921 100755 --- a/install_deb.sh +++ b/install_deb.sh @@ -1,12 +1,14 @@ #!/bin/bash -LLVM_VERSION=12 +# Note, wasi-sdk versions do NOT match llvm versions, e.g. wasi-sdk-12 actually uses llvm-11 +LLVM_VERSION=13 +WASI_SDK_VERSION=12 ARCH=$(uname -m) if [[ $ARCH = "x86_64" ]]; then SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.4.3/shfmt_v3.4.3_linux_amd64 - WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk_12.0_amd64.deb + WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb elif [[ $ARCH = "aarch64" ]]; then SHFMT_URL=https://github.com/patrickvane/shfmt/releases/download/master/shfmt_linux_arm echo "ARM64 support is still a work in progress!" @@ -64,7 +66,7 @@ wget $SHFMT_URL -O shfmt && chmod +x shfmt && sudo mv shfmt /usr/local/bin/shfmt sudo ./install_llvm.sh $LLVM_VERSION -curl -sS -L -O $WASI_SDK_URL && sudo dpkg -i wasi-sdk_12.0_amd64.deb && rm -f wasi-sdk_12.0_amd64.deb +curl -sS -L -O $WASI_SDK_URL && sudo dpkg -i wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb && rm -f wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb if [ -z "${WASI_SDK_PATH}" ]; then export WASI_SDK_PATH=/opt/wasi-sdk diff --git a/install_llvm.sh b/install_llvm.sh index 635031acf..515385738 100755 --- a/install_llvm.sh +++ b/install_llvm.sh @@ -8,28 +8,28 @@ echo "Installing LLVM $LLVM_VERSION" # Script Installs clang, lldb, lld, and clangd curl --proto '=https' --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | bash -s -- "$LLVM_VERSION" +# Installing "libc++-xx-dev" automagically installs "libc++1-xx", "libunwind-xx" and "libunwind-xx-dev" apt-get install -y --no-install-recommends \ "libc++-$LLVM_VERSION-dev" \ "libc++abi-$LLVM_VERSION-dev" \ - "libc++1-$LLVM_VERSION" \ - "libunwind-$LLVM_VERSION" \ - "libunwind-$LLVM_VERSION-dev" \ "clang-tools-$LLVM_VERSION" \ "clang-tidy-$LLVM_VERSION" \ "clang-format-$LLVM_VERSION" -sudo update-alternatives --remove-all clang-format -sudo update-alternatives --remove-all clang -sudo update-alternatives --remove-all clang++ -sudo update-alternatives --remove-all llvm-config -sudo update-alternatives --remove-all llvm-objdump -sudo update-alternatives --remove-all llvm-objdump -sudo update-alternatives --remove-all clang-tidy +update-alternatives --remove-all wasm-ld +update-alternatives --remove-all llvm-config +update-alternatives --remove-all llvm-objdump +update-alternatives --remove-all llvm-dis +update-alternatives --remove-all clang-format +update-alternatives --remove-all clang +update-alternatives --remove-all clang++ +update-alternatives --remove-all clang-tidy +update-alternatives --install /usr/bin/wasm-ld wasm-ld "/usr/bin/wasm-ld-$LLVM_VERSION" 100 +update-alternatives --install /usr/bin/llvm-config llvm-config "/usr/bin/llvm-config-$LLVM_VERSION" 100 +update-alternatives --install /usr/bin/llvm-objdump llvm-objdump "/usr/bin/llvm-objdump-$LLVM_VERSION" 100 +update-alternatives --install /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-$LLVM_VERSION 100 update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-$LLVM_VERSION" 100 update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-$LLVM_VERSION" 100 update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-$LLVM_VERSION" 100 -update-alternatives --install /usr/bin/llvm-config llvm-config "/usr/bin/llvm-config-$LLVM_VERSION" 100 -update-alternatives --install /usr/bin/llvm-objdump llvm-objdump "/usr/bin/llvm-objdump-$LLVM_VERSION" 100 update-alternatives --install /usr/bin/clang-tidy clang-tidy "/usr/bin/clang-tidy-$LLVM_VERSION" 100 -update-alternatives --install /usr/bin/wasm-ld wasm-ld "/usr/bin/wasm-ld-$LLVM_VERSION" 100 diff --git a/uninstall_llvm.sh b/uninstall_llvm.sh new file mode 100755 index 000000000..d76ca266a --- /dev/null +++ b/uninstall_llvm.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Uninstalls all LLVM tooling as much as possible + +echo "Uninstalling LLVM" + +apt-get remove -y --purge \ + "llvm*" \ + "lld*" \ + "libc++*" \ + "libunwind*" \ + "clang*" \ + +apt-get autoremove -y + +update-alternatives --remove-all clang-format +update-alternatives --remove-all clang +update-alternatives --remove-all clang++ +update-alternatives --remove-all llvm-config +update-alternatives --remove-all llvm-objdump +update-alternatives --remove-all clang-tidy +update-alternatives --remove-all wasm-ld \ No newline at end of file