diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..aa67819 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,158 @@ +name: Build + +on: [push] + +jobs: + build: + name: Build + + strategy: + matrix: + target: + - id: 'linux-amd64' + os: 'ubuntu-20.04' + - id: 'darwin-amd64' + os: 'macos-13' + - id: 'darwin-aarch64' + os: 'macos-latest' + - id: 'windows-amd64' + os: 'windows-2022' + # When unpacking an archive on Windows, the symlinks can't be + # created unless the target path already exists. This causes + # problems when the linked file is ordered after the link + # inside the archive. Dereferencing the files when packing them + # adds an additional copy per link, but it reliably works and + # the additional size is not too large on Windows. + tar_extra_args: '--dereference' + tag: ['11.6'] + fail-fast: true + + runs-on: ${{ matrix.target.os }} + + steps: + - name: Check out the code + uses: actions/checkout@v3 + + - name: Install `ninja` on Ubuntu + if: startsWith(matrix.target.id, 'linux-') + shell: bash + run: | + sudo apt-get install ninja-build -y + + - name: Install `ninja` on macOS + if: startsWith(matrix.target.id, 'darwin-') + shell: bash + run: | + brew install ninja + + - name: Install `ninja` on Windows + if: startsWith(matrix.target.id, 'windows-') + shell: bash + run: | + choco install ninja + + - name: Setup MSVC (Windows) + uses: ilammy/msvc-dev-cmd@v1 + if: matrix.target.id == 'windows-amd64' + + - name: Build + if: matrix.target.id != 'windows-amd64' + shell: bash + run: | + ./build.sh + + - name: Build (Windows) + if: matrix.target.id == 'windows-amd64' + run: | + ./build.ps1 + + - name: Zip + shell: bash + run: | + mkdir -p dist + tar --directory v8-cmake/build/destdir --create --xz --verbose ${{ matrix.target.tar_extra_args }} --file dist/wee8.tar.xz . + ls -lh dist/wee8.tar.xz + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.target.id }}-${{ matrix.tag }} + path: dist + if-no-files-found: error + retention-days: 1 + + release: + name: Release + + runs-on: ubuntu-latest + + needs: [build] + + + strategy: + matrix: + tag: ['11.6'] + + + steps: + - name: Download the Artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Inspect + shell: bash + run: | + ls -laGiR ./* + + - name: Create Release + id: create_release + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: ${{ matrix.tag }} + name: Release ${{ matrix.tag }} + allowUpdates: true + draft: false + prerelease: false + + - name: Upload Release Asset Linux + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/linux-amd64-${{matrix.tag}}/wee8.tar.xz + asset_name: wee8-linux-amd64.tar.xz + asset_content_type: application/gzip + + - name: Upload Release Asset Darwin + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/darwin-amd64-${{matrix.tag}}/wee8.tar.xz + asset_name: wee8-darwin-amd64.tar.xz + asset_content_type: application/gzip + + - name: Upload Release Asset Darwin (aarch64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/darwin-aarch64-${{matrix.tag}}/wee8.tar.xz + asset_name: wee8-darwin-aarch64.tar.xz + asset_content_type: application/gzip + + - name: Upload Release Asset Windows + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/windows-amd64-${{matrix.tag}}/wee8.tar.xz + asset_name: wee8-windows-amd64.tar.xz + asset_content_type: application/gzip diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..62bb543 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present Wasmer, Inc. and its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..11556db --- /dev/null +++ b/README.md @@ -0,0 +1,249 @@ +
+ + Wasmer logo + + +

LLVM Custom Builds

+ +

+ + Build Status + + + License + +

+ +

+ Website + + Docs + + Slack Channel +

+ +
+ +
+ +> Go along your path, this is a dangerous place. + +This repository contains a small `build.sh` (or `build.ps1` for Windows +PowerShell) script that builds LLVM. The version of LLVM is defined in the CI script. +The build is run by [Github +Actions](https://github.com/wasmerio/llvm-custom-builds/actions) on 4 +platforms: Linux (Ubuntu, amd64 and aarch64), Darwin (macOS), and Windows. +Builds are attached to [Github releases as +assets](https://github.com/wasmerio/llvm-custom-builds/releases). + +## Prebuilds + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLVM versionArchitecturePlatformPackage
18amd64Darwindownload
Linuxdownload
Windowsdownload
aarch64Linuxdownload
Darwindownload
riscv64Linuxdownload
16amd64Darwindownload
Linuxdownload
Windowsdownload
aarch64Linuxdownload
riscv64Linuxdownload
15amd64Darwindownload
Linuxdownload
Windowsdownload
aarch64Linuxdownload
riscv64Linuxdownload
14amd64Darwindownload
Linuxdownload
Windowsdownload
aarch64Linuxdownload
13amd64Darwindownload
Linuxdownload
Windowsdownload
aarch64Linuxdownload
12amd64Darwindownload
Linuxdownload
Windowsdownload
aarch64Linuxdownload
11amd64Darwindownload
Linuxdownload
Windowsdownload
aarch64Linuxdownload
10amd64Darwindownload
Linuxdownload
Windowsdownload
aarchLinuxdownload
+ +## LLVM configuration + +The following configuration is the one used for all actual prebuilds: + +| Options | Value | +|-|-| +| `clang` | enabled | +| `docs` | not included | +| `examples` | not included | +| `go_tests` | not included | +| `lld` | enabled | +| `optimized_tablegen` | enabled | +| `targets_to_build` | `X86` + `AArch64` | +| `terminfo` | disabled | +| `tests` | not included | +| `tools` | included | +| `utils` | not included | +| `zlib` | disabled | + +# License + +The entire project is under the MIT License. Please read [the `LICENSE` file][license]. + + +[license]: https://github.com/wasmerio/llvm-custom-builds/blob/master/LICENSE diff --git a/build.ps1 b/build.ps1 new file mode 100755 index 0000000..3257799 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,52 @@ +$V8_REPO_URL = $args[1] + +if ([string]::IsNullOrEmpty($V8_REPO_URL)) { + $V8_REPO_URL = "https://github.com/laper32/v8-cmake.git" +} + +if ([string]::IsNullOrEmpty($LLVM_VERSION)) { + Write-Output "Usage: $PSCommandPath " + Write-Output "" + Write-Output "# Arguments" + Write-Output " v8-repository-url The URL used to clone v8-cmake sources (default: https://github.com/laper32/v8-cmake.git)" + + exit 1 +} + +# Clone the LLVM project. +if (-not (Test-Path -Path "v8-cmake" -PathType Container)) { + git clone -b "msvc" --single-branch --depth=1 "$V8_REPO_URL" v8-cmake +} + +Set-Location v8-cmake +git fetch origin + +# Create a directory to build the project. +New-Item -Path "build" -Force -ItemType "directory" +Set-Location build + +# Create a directory to receive the complete installation. +New-Item -Path "install" -Force -ItemType "directory" + +# Adjust compilation based on the OS. +$CMAKE_ARGUMENTS = "" + +# Adjust cross compilation +$CROSS_COMPILE = "" + +# Run `cmake` to configure the project, using MSVC. +$CMAKE_CXX_COMPILER="cl.exe" +$CMAKE_C_COMPILER="cl.exe" +$CMAKE_LINKER_TYPE="MSVC" + +cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel ../v8-cmake + +# Showtime! +cmake --build . --config Release --target wee8 + +# Not using DESTDIR here, quote from +# https://cmake.org/cmake/help/latest/envvar/DESTDIR.html +# > `DESTDIR` may not be used on Windows because installation prefix +# > usually contains a drive letter like in `C:/Program Files` which cannot +# > be prepended with some other prefix. +cmake --install . --strip --config Release diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..0e4b5ab --- /dev/null +++ b/build.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Display all commands before executing them. +set -o errexit +set -o errtrace + +V8_REPO_URL=${2:-https://github.com/laper32/v8-cmake.git} +LLVM_CROSS="$3" + +if [[ -z "$V8_REPO_URL" ]] +then + echo "Usage: $0 " + echo + echo "# Arguments" + echo " v8-repository-url The URL used to clone v8-cmake sources (default: $V8_REPO_URL)" + + exit 1 +fi + +if [ ! -d v8-cmake ] +then + git clone -b "msvc" --single-branch --depth=1 "$V8_REPO_URL" v8-cmake +fi + +cd v8-cmake + +# Create a directory to build the project. +mkdir -p build +cd build + +# Create a directory to receive the complete installation. +mkdir -p install + +# Adjust compilation based on the OS. +CMAKE_ARGUMENTS="" + +case "${OSTYPE}" in + darwin*) ;; + linux*) ;; + *) ;; +esac + +## Adjust cross compilation +#CROSS_COMPILE="" +# +#case "${LLVM_CROSS}" in +# aarch64*) CROSS_COMPILE="-DLLVM_HOST_TRIPLE=aarch64-linux-gnu" ;; +# riscv64*) CROSS_COMPILE="-DLLVM_HOST_TRIPLE=riscv64-linux-gnu" ;; +# *) ;; +#esac + +# Run `cmake` to configure the project. +cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel ../llvm + +# Showtime! +cmake --build . --config MinSizeRel --target wee8 +DESTDIR=destdir cmake --install . --strip --config MinSizeRel