diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000000000..34f3dfa3afe901 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,108 @@ +environment: + CIRRUS_CLONE_DEPTH: 50 + CLANG_VERSION: '15.0.3' # 15.0.6 requires a more recent libstdc++.so.6 than shipped with Ubuntu 20 + # no MLIR + LLVM_PROJECTS_TO_ENABLE: bolt;compiler-rt;lld + # keep these in sync with .github/workflows/ldc-release.yml for Linux x64: + LLVM_TARGETS_TO_BUILD: all + LLVM_EXPERIMENTAL_TARGETS_TO_BUILD: SPIRV + BASE_CMAKE_FLAGS: -DLLVM_ENABLE_UNWIND_TABLES=OFF -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DCOMPILER_RT_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF -DCOMPILER_RT_USE_LIBCXX=OFF + EXTRA_CMAKE_FLAGS: -DLLVM_BINUTILS_INCDIR=/usr/include -DLLVM_STATIC_LINK_CXX_STDLIB=ON + +task: + name: Ubuntu 20.04 $TASK_NAME_SUFFIX + compute_engine_instance: + image_project: ubuntu-os-cloud + image: family/ubuntu-2004-lts-arm64 + platform: linux + architecture: arm64 + cpu: 4 + memory: 8G + disk: 20 + timeout_in: 120m + environment: + PARALLELISM: 4 + GITHUB_TOKEN: ENCRYPTED[79b00f4f535df0fdfe3ceea87f9d4ec2ba7628e0c60730b99bcd91c7888af275409f02b2f1bc90015c2cb9cc4fb2dd12] + matrix: + - TASK_NAME_SUFFIX: aarch64 + LLVM_ENABLE_ASSERTIONS: 'OFF' + - TASK_NAME_SUFFIX: aarch64 withAsserts + LLVM_ENABLE_ASSERTIONS: 'ON' + install_prerequisites_script: | + export DEBIAN_FRONTEND=noninteractive + apt-get -q update + apt-get -yq install git-core curl xz-utils ninja-build g++ python3 pkg-config binutils-dev libxml2-dev zlib1g-dev p7zip-full + # install a more recent version of CMake + curl -fL --retry 3 --max-time 300 -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-linux-aarch64.tar.gz + mkdir cmake_bin + tar -xf cmake.tar.gz --strip 1 -C cmake_bin + rm cmake.tar.gz + # download & extract clang + curl -fL --retry 3 --max-time 300 -o clang.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-aarch64-linux-gnu.tar.xz + mkdir clang_bin + tar -xf clang.tar.xz --strip 1 -C clang_bin + rm clang.tar.xz + # make lld the default linker + ln -sf "$PWD/clang_bin/bin/ld.lld" /usr/bin/ld + ld --version + clone_submodules_script: | + git submodule update --init --depth $CIRRUS_CLONE_DEPTH + build_script: | + export PATH="$PWD/cmake_bin/bin:$PATH" + export CC="$PWD/clang_bin/bin/clang" + export CXX="$PWD/clang_bin/bin/clang++" + nproc + free + cmake --version + ninja --version + mkdir build + cd build + cmake -G Ninja ../llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$PWD/../install \ + -DLLVM_ENABLE_PROJECTS="$LLVM_PROJECTS_TO_ENABLE" \ + -DLLVM_TARGETS_TO_BUILD="$LLVM_TARGETS_TO_BUILD" \ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="$LLVM_EXPERIMENTAL_TARGETS_TO_BUILD" \ + -DLLVM_ENABLE_ASSERTIONS=$LLVM_ENABLE_ASSERTIONS \ + $BASE_CMAKE_FLAGS $EXTRA_CMAKE_FLAGS + ninja -j$PARALLELISM install + cd .. + pack_artifact_script: | + if [[ "${CIRRUS_TAG:-}" == ldc-v* ]]; then + artifactID=${CIRRUS_TAG:5} + else + artifactID=${CIRRUS_CHANGE_IN_REPO:0:8} + fi + assertsSuffix="" + if [[ "$LLVM_ENABLE_ASSERTIONS" == "ON" ]]; then + assertsSuffix="-withAsserts" + fi + artifactName=llvm-$artifactID-linux-aarch64$assertsSuffix + mv install $artifactName + chmod -R go=rX $artifactName + artifact=$artifactName.tar.xz + tar -cf - --owner=0 --group=0 $artifactName | 7za a $artifact -si -txz -mx9 -mmt$PARALLELISM + ls -lh $artifact + # Upload to GitHub release (only for branches and tags, no PRs) + upload_to_github_script: | + if [[ "${CIRRUS_TAG:-}" == ldc-v* ]]; then + releaseTag=$CIRRUS_TAG + elif [[ "${CIRRUS_TAG:-}" == "" && "${CIRRUS_PR:-}" == "" ]]; then + releaseTag=CI + else + echo 'Skipping upload' + exit 0 + fi + releaseID="$(set -eo pipefail; curl -fsS https://api.github.com/repos/ldc-developers/llvm-project/releases/tags/"$releaseTag" | grep '^ "id":' | head -n1 || echo "")" + if [[ "$releaseID" == "" ]]; then + echo "Error: no GitHub release found for tag '$releaseTag'" >&2 + exit 1 + fi + releaseID=${releaseID:8:-1} + artifact=$(ls llvm-*.tar.xz) + echo "Uploading $artifact to GitHub release $releaseTag ($releaseID)..." + curl -fsS \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @$artifact \ + https://uploads.github.com/repos/ldc-developers/llvm-project/releases/$releaseID/assets?name=$artifact diff --git a/.github/actions/1-setup/action.yml b/.github/actions/1-setup/action.yml new file mode 100644 index 00000000000000..22ecd5c94ac400 --- /dev/null +++ b/.github/actions/1-setup/action.yml @@ -0,0 +1,73 @@ +name: Install prerequisites +inputs: + clang_version: + required: true + arch: + required: true +runs: + using: composite + steps: + + - name: 'Linux: Install required apt packages' + if: runner.os == 'Linux' + shell: bash + run: | + set -eux + export DEBIAN_FRONTEND=noninteractive + sudo apt-get -q update + sudo apt-get -yq install \ + git-core cmake g++ binutils-dev python p7zip-full unzip + + - name: 'Linux: Download & extract clang' # into ../clang + if: runner.os == 'Linux' + shell: bash + run: | + set -eux + cd .. + version='${{ inputs.clang_version }}' + curl -fL --retry 3 --max-time 300 -o clang.tar.xz \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/clang+llvm-$version-x86_64-linux-gnu-ubuntu-18.04.tar.xz + mkdir clang + tar -xf clang.tar.xz --strip 1 -C clang + rm clang.tar.xz + clang/bin/clang --version + + # use it as C(++) compiler for future steps + echo "CC=$PWD/clang/bin/clang" >> $GITHUB_ENV + echo "CXX=$PWD/clang/bin/clang++" >> $GITHUB_ENV + + # make bundled lld the default linker + sudo ln -sf "$PWD/clang/bin/ld.lld" /usr/bin/ld + ld --version + - name: 'Windows: Install clang' + if: runner.os == 'Windows' + shell: bash + run: | + set -eux + cd .. + curl -fL --retry 3 --max-time 300 -o clang.exe \ + https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.clang_version }}/LLVM-${{ inputs.clang_version }}-win64.exe + ./clang.exe //S # double-slash for bash + rm clang.exe + + # C:\Program Files\LLVM\bin should already be in PATH + clang-cl --version + + # use it as C(++) compiler for future steps + echo "CC=clang-cl" >> $GITHUB_ENV + echo "CXX=clang-cl" >> $GITHUB_ENV + + if [[ '${{ inputs.arch }}' == x86 ]]; then + # make CMake configure 64-bit clang-cl for 32-bit code emission + echo "CFLAGS=-m32" >> $GITHUB_ENV + echo "CXXFLAGS=-m32" >> $GITHUB_ENV + echo "ASMFLAGS=-m32" >> $GITHUB_ENV + fi + + - name: Install ninja + uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: 'Windows: Set LDC_VSDIR env variable' + if: runner.os == 'Windows' + shell: bash + run: echo "LDC_VSDIR=$(vswhere -latest -property installationPath)" >> $GITHUB_ENV diff --git a/.github/actions/2-build/action.yml b/.github/actions/2-build/action.yml new file mode 100644 index 00000000000000..199c7b6de5951f --- /dev/null +++ b/.github/actions/2-build/action.yml @@ -0,0 +1,62 @@ +name: Build & install LLVM incl. LLD, compiler-rt, MLIR, BOLT +inputs: + arch: + required: false # Windows only + enable_projects: + required: true + targets_to_build: + required: false + default: all + experimental_targets_to_build: + required: false + default: '' + with_asserts: + required: true + extra_cmake_flags: + required: false + default: '' +runs: + using: composite + steps: + + - if: runner.os != 'Windows' + shell: bash + run: | + set -eux + cd .. + cmake --version + ninja --version + mkdir build + cd build + cmake -G Ninja ../llvm-project/llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$PWD/../install \ + -DLLVM_ENABLE_PROJECTS="${{ inputs.enable_projects }}" \ + -DLLVM_TARGETS_TO_BUILD="${{ inputs.targets_to_build }}" \ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${{ inputs.experimental_targets_to_build }}" \ + -DLLVM_ENABLE_ASSERTIONS=${{ inputs.with_asserts == 'true' && 'ON' || 'OFF' }} \ + ${{ inputs.extra_cmake_flags }} + ninja install + + # Windows: invoke CMake & ninja in MSVC env + - if: runner.os == 'Windows' + shell: cmd + run: | + call "%LDC_VSDIR%\Common7\Tools\VsDevCmd.bat" -arch=${{ inputs.arch }} || exit /b + echo on + cd .. || exit /b + cmake --version || exit /b + ninja --version || exit /b + mkdir build || exit /b + cd build || exit /b + cmake -G Ninja ..\llvm-project\llvm ^ + -DCMAKE_BUILD_TYPE=Release ^ + "-DCMAKE_INSTALL_PREFIX=%CD%\..\install" ^ + "-DLLVM_ENABLE_PROJECTS=${{ inputs.enable_projects }}" ^ + "-DLLVM_TARGETS_TO_BUILD=${{ inputs.targets_to_build }}" ^ + "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=${{ inputs.experimental_targets_to_build }}" ^ + -DLLVM_ENABLE_ASSERTIONS=${{ inputs.with_asserts == 'true' && 'ON' || 'OFF' }} ^ + ${{ inputs.extra_cmake_flags }} + if %errorlevel% neq 0 exit /b %errorlevel% + + ninja install || exit /b diff --git a/.github/actions/3-package/action.yml b/.github/actions/3-package/action.yml new file mode 100644 index 00000000000000..64c55f06787203 --- /dev/null +++ b/.github/actions/3-package/action.yml @@ -0,0 +1,93 @@ +name: Create package & upload artifact(s) +inputs: + arch: + required: true + os: + required: false + default: '' # native + with_asserts: + required: true +runs: + using: composite + steps: + + - name: Pack installation dir + shell: bash + run: | + set -euxo pipefail + cd .. + mkdir artifacts + + if [[ '${{ github.ref }}' = refs/tags/ldc-v* ]]; then + artifactID='${{ github.ref }}' + artifactID="${artifactID:15}" + else + artifactID='${{ github.sha }}' + artifactID="${artifactID:0:8}" + fi + + os='${{ inputs.os }}' + if [[ "$os" == '' ]]; then + if [[ '${{ runner.os }}' == Linux ]]; then + os=linux + elif [[ '${{ runner.os }}' == macOS ]]; then + os=osx + elif [[ '${{ runner.os }}' == Windows ]]; then + os=windows + else + echo "Error: unknown OS '${{ runner.os }}'" + exit 1 + fi + fi + + if [[ "$os" == windows ]]; then + # on Windows, the lld symlinks are copies + rm install/bin/{ld.lld,ld64.lld*,lld-link,wasm-ld}.exe + mv install/bin/lld.exe install/bin/lld-link.exe + fi + + assertsSuffix="${{ inputs.with_asserts == 'true' && '-withAsserts' || '' }}" + + artifactName="llvm-$artifactID-$os-${{ inputs.arch }}$assertsSuffix" + mv install $artifactName + if [[ '${{ runner.os }}' == Windows ]]; then + cd $artifactName + 7z a -mx=9 ../artifacts/$artifactName.7z * >/dev/null + cd .. + else + chmod -R go=rX $artifactName + if [[ '${{ runner.os }}' == macOS ]]; then + sudo chown -R root:wheel $artifactName + tar -cJf artifacts/$artifactName.tar.xz --options='compression-level=9' $artifactName + else + tar -cf - --owner=0 --group=0 $artifactName | 7za a artifacts/$artifactName.tar.xz -si -txz -mx9 + fi + fi + + # export ARTIFACT_{ID,NAME} + echo "ARTIFACT_ID=$artifactID" >> $GITHUB_ENV + echo "ARTIFACT_NAME=$os-${{ inputs.arch }}$assertsSuffix" >> $GITHUB_ENV + + - name: 'Linux: Pack source dir' + if: runner.os == 'Linux' && inputs.os == '' && inputs.with_asserts == 'false' + shell: bash + run: | + set -euxo pipefail + git clean -dffx + git submodule foreach git clean -dffx + artifactName="llvm-$ARTIFACT_ID.src" + # just the LLVM src dir + bolt + compiler-rt + lld + mlir + mv compiler-rt llvm/projects + mv bolt lld mlir llvm/tools + chmod -R go=rX llvm + tar -cf - --exclude-vcs --owner=0 --group=0 --transform="s,^llvm,$artifactName," llvm | 7za a ../artifacts/$artifactName.tar.xz -si -txz -mx9 + + - name: 'Move artifacts dir for uploading' + shell: bash + run: mv ../artifacts ./ + + - name: Upload artifact(s) + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: artifacts/ diff --git a/.github/actions/upload-to-github/action.yml b/.github/actions/upload-to-github/action.yml new file mode 100644 index 00000000000000..95f7c5b3e1bd34 --- /dev/null +++ b/.github/actions/upload-to-github/action.yml @@ -0,0 +1,72 @@ +name: Upload to GitHub +runs: + using: composite + steps: + + - name: Download all artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts/ + + - name: Set GITHUB_RELEASE_TAG & ARTIFACT_ID + shell: bash + run: | + set -eux + if [[ '${{ github.ref }}' = refs/tags/ldc-v* ]]; then + tag='${{ github.ref }}' + tag="${tag:10}" + artifactID="${tag:5}" + else + tag=CI + artifactID='${{ github.sha }}' + artifactID="${artifactID:0:8}" + fi + echo "GITHUB_RELEASE_TAG=$tag" >> $GITHUB_ENV + echo "ARTIFACT_ID=$artifactID" >> $GITHUB_ENV + + - name: Download existing artifacts from GitHub release + # only enabled for the upstream repo by default - (probably) needs an existing release + if: github.repository == 'ldc-developers/llvm-project' + # don't fail if there are no existing artifacts yet + continue-on-error: true + uses: dsaltares/fetch-gh-release-asset@1.0.0 + with: + version: tags/${{ env.GITHUB_RELEASE_TAG }} + regex: true + # only those with matching ARTIFACT_ID + file: ^llvm-${{ env.ARTIFACT_ID }}- + target: existing-artifacts/ + + - name: Move artifact files out of their subdirs & compute hashes + shell: bash + run: | + set -eux + + cd artifacts + mv */*.* ./ + find . -type d -empty -delete + ls -lh + + # Extend by existing release artifacts *missing* from GitHub workflow, + # e.g., artifacts published by Travis CI etc. + # (They will be re-uploaded in the next step.) + if [[ -d ../existing-artifacts ]]; then + mv -n ../existing-artifacts/*.* ./ + fi + + sha256sum * > "llvm-$ARTIFACT_ID.sha256sums.txt" + + - name: Upload to GitHub release + uses: ncipollo/release-action@v1 + with: + tag: ${{ env.GITHUB_RELEASE_TAG }} + artifacts: artifacts/* + allowUpdates: true + artifactErrorsFailBuild: true + prerelease: false + omitPrereleaseDuringUpdate: true + omitName: true + omitBody: true + omitDraftDuringUpdate: true + # remove existing artifacts for 'CI' release + #removeArtifacts: ${{ env.GITHUB_RELEASE_TAG == 'CI' }} diff --git a/.github/workflows/ldc-release.yml b/.github/workflows/ldc-release.yml new file mode 100644 index 00000000000000..aac4e20a750368 --- /dev/null +++ b/.github/workflows/ldc-release.yml @@ -0,0 +1,248 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions + +name: LDC-specific release +on: + - pull_request + - push + - workflow_dispatch + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CLANG_VERSION: 15.0.6 + # Prevent dependencies on some purely optional libraries, and a dependency on clang + # for compiler-rt tests. + BASE_CMAKE_FLAGS: >- + -DLLVM_ENABLE_UNWIND_TABLES=OFF + -DLLVM_ENABLE_TERMINFO=OFF + -DLLVM_ENABLE_LIBEDIT=OFF + -DCOMPILER_RT_INCLUDE_TESTS=OFF + -DLLVM_INCLUDE_TESTS=OFF + -DCOMPILER_RT_USE_LIBCXX=OFF + +jobs: + build-native: + strategy: + fail-fast: false + matrix: + include: + - job_name: Windows x64 + os: windows-2022 + arch: x64 + with_asserts: false + - job_name: Windows x64 withAsserts + os: windows-2022 + arch: x64 + with_asserts: true + - job_name: Windows x86 + os: windows-2022 + arch: x86 + with_asserts: false + - job_name: Windows x86 withAsserts + os: windows-2022 + arch: x86 + with_asserts: true + - job_name: Linux x86_64 + os: ubuntu-20.04 + arch: x86_64 + with_asserts: false + - job_name: Linux x86_64 withAsserts + os: ubuntu-20.04 + arch: x86_64 + with_asserts: true + - job_name: macOS x86_64 + os: macos-11 + arch: x86_64 + with_asserts: false + - job_name: macOS x86_64 withAsserts + os: macos-11 + arch: x86_64 + with_asserts: true + name: ${{ matrix.job_name }} + runs-on: ${{ matrix.os }} + timeout-minutes: 240 + env: + MACOSX_DEPLOYMENT_TARGET: 10.12 # min version for BOLT + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 50 + - name: Install prerequisites + uses: ./.github/actions/1-setup + with: + # on Windows, the MSVC headers require clang 16+ + clang_version: ${{ runner.os == 'Windows' && '17.0.6' || env.CLANG_VERSION }} + arch: ${{ matrix.arch }} + - name: Build & install LLVM incl. LLD, compiler-rt, MLIR, BOLT + uses: ./.github/actions/2-build + with: + arch: ${{ matrix.arch }} + # exclude MLIR and BOLT on Windows + enable_projects: ${{ runner.os == 'Windows' && 'compiler-rt;lld' || 'bolt;compiler-rt;lld;mlir' }} + targets_to_build: all + experimental_targets_to_build: SPIRV + with_asserts: ${{ matrix.with_asserts }} + # - link C++ standard library statically for improved portability on Windows and Linux + # - on Linux, need LLVM_BINUTILS_INCDIR to generate LTO linker plugin + # - on macOS, need to disable libzstd (not found for LDC CI job) + extra_cmake_flags: >- + ${{ env.BASE_CMAKE_FLAGS }} + ${{ runner.os == 'Windows' && '-DLLVM_USE_CRT_RELEASE=MT' || '' }} + ${{ runner.os == 'Linux' && '-DLLVM_BINUTILS_INCDIR=/usr/include -DLLVM_STATIC_LINK_CXX_STDLIB=ON' || '' }} + ${{ runner.os == 'macOS' && '-DLLVM_ENABLE_ZSTD=OFF' || '' }} + - name: Create package & upload artifact + uses: ./.github/actions/3-package + with: + arch: ${{ matrix.arch }} + with_asserts: ${{ matrix.with_asserts }} + + build-cross: + strategy: + fail-fast: false + matrix: + include: + - job_name: macOS arm64 + host_os: macos-11 + os: osx + arch: arm64 + targets_to_build: all + experimental_targets_to_build: SPIRV + - job_name: macOS arm64 withAsserts + host_os: macos-11 + os: osx + arch: arm64 + targets_to_build: all + experimental_targets_to_build: SPIRV + with_asserts: true + - job_name: Android armv7a + host_os: ubuntu-20.04 + os: android + arch: armv7a + targets_to_build: AArch64;ARM;WebAssembly;X86 + experimental_targets_to_build: SPIRV + - job_name: Android aarch64 + host_os: ubuntu-20.04 + os: android + arch: aarch64 + targets_to_build: AArch64;ARM;WebAssembly;X86 + experimental_targets_to_build: SPIRV + name: ${{ matrix.job_name }} + runs-on: ${{ matrix.host_os }} + timeout-minutes: 240 + env: + ANDROID_NDK_VERSION: r21e + MACOSX_DEPLOYMENT_TARGET: 11.0 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 50 + - name: Install prerequisites + uses: ./.github/actions/1-setup + with: + clang_version: ${{ env.CLANG_VERSION }} + arch: ${{ matrix.arch }} + - name: Build native llvm-tblgen + shell: bash + run: | + set -eux + cd .. + mkdir build-native + cd build-native + cmake -G Ninja ../llvm-project/llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_TARGETS_TO_BUILD="${{ matrix.targets_to_build }}" \ + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${{ matrix.experimental_targets_to_build }}" \ + ${{ env.BASE_CMAKE_FLAGS }} + ninja llvm-tblgen + - name: Set up cross-compilation + shell: bash + run: | + set -eux + os='${{ matrix.os }}' + arch='${{ matrix.arch }}' + if [[ "$os-$arch" == osx-arm64 ]]; then + flags=( + -DCMAKE_OSX_ARCHITECTURES=arm64 + -DLLVM_TARGET_ARCH=AArch64 + -DLLVM_DEFAULT_TARGET_TRIPLE=arm64-apple-macos + -DLLVM_ENABLE_PLUGINS=OFF + ) + elif [[ "$os" == android ]]; then + # download & extract Android NDK + cd .. + curl -fL --retry 3 --max-time 300 -o android-ndk.zip \ + https://dl.google.com/android/repository/android-ndk-$ANDROID_NDK_VERSION-linux-x86_64.zip + unzip android-ndk.zip >/dev/null + mv "android-ndk-$ANDROID_NDK_VERSION" android-ndk + rm android-ndk.zip + + # The NDK toolchain file enforces `-g` as base C[XX] flag - remove it to + # *significantly* reduce executable sizes + toolchainFile="$PWD/android-ndk/build/cmake/android.toolchain.cmake" + sed -i 's|^ -g$||' "$toolchainFile" + + flags=( + -DCMAKE_TOOLCHAIN_FILE="$toolchainFile" + -DANDROID_NATIVE_API_LEVEL=21 + -DANDROID_STL=c++_static + -DCMAKE_CROSSCOMPILING=True + -DLLVM_ENABLE_PLUGINS=OFF + ) + if [[ "$arch" == armv7a ]]; then + flags+=( + -DANDROID_ABI=armeabi-v7a + -DLLVM_TARGET_ARCH=ARM + -DLLVM_DEFAULT_TARGET_TRIPLE=armv7a--linux-androideabi + ) + elif [[ "$arch" == aarch64 ]]; then + flags+=( + -DANDROID_ABI=arm64-v8a + -DLLVM_TARGET_ARCH=AArch64 + -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64--linux-android + -DSANITIZER_CXX_ABI=libc++ + -DCMAKE_CXX_FLAGS=-U_FORTIFY_SOURCE + ) + fi + fi + echo "EXTRA_CMAKE_FLAGS_CROSS=${flags[*]}" >> $GITHUB_ENV + - name: Cross-build & install LLVM incl. LLD, compiler-rt, BOLT + uses: ./.github/actions/2-build + with: + # exclude MLIR - compile errors for ARM + enable_projects: bolt;compiler-rt;lld + targets_to_build: ${{ matrix.targets_to_build }} + experimental_targets_to_build: ${{ matrix.experimental_targets_to_build }} + with_asserts: ${{ matrix.with_asserts }} + extra_cmake_flags: >- + ${{ env.BASE_CMAKE_FLAGS }} + -DLLVM_TABLEGEN="${{ github.workspace }}/../build-native/bin/llvm-tblgen" + -DLLVM_CONFIG_PATH="${{ github.workspace }}/../build-native/bin/llvm-config" + ${{ env.EXTRA_CMAKE_FLAGS_CROSS }} + ${{ matrix.os == 'osx' && '-DLLVM_ENABLE_ZSTD=OFF' || '' }} + # ^^ the macOS arm64 CI jobs otherwise attempt to link against an x86_64 libzstd.dylib (and fail) + - name: Create package & upload artifact + uses: ./.github/actions/3-package + with: + arch: ${{ matrix.arch }} + os: ${{ matrix.os }} + with_asserts: ${{ matrix.with_asserts }} + + upload-to-github: + name: Upload to GitHub + # only run for branches and tags, no PRs + if: startsWith(github.ref, 'refs/tags/ldc-v') || startsWith(github.ref, 'refs/heads/') + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: + - build-native + - build-cross + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - name: Upload all artifacts to GitHub release + uses: ./.github/actions/upload-to-github diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000000..e69de29bb2d1d6