diff --git a/.github/workflows/release-binaries-all.yml b/.github/workflows/release-binaries-all.yml index 0b52a08202f1a..7e408497d1819 100644 --- a/.github/workflows/release-binaries-all.yml +++ b/.github/workflows/release-binaries-all.yml @@ -88,9 +88,6 @@ jobs: # We use ubuntu-22.04 rather than the latest version to make the built # binaries more portable (eg functional aginast older glibc). runs-on: - - ubuntu-22.04 - - ubuntu-22.04-arm - - macos-13 - macos-14 uses: ./.github/workflows/release-binaries.yml diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 83969b5490685..4e697ce011c1e 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -1,5 +1,5 @@ name: Release Binaries - +# TEST on: workflow_dispatch: inputs: @@ -121,6 +121,47 @@ jobs: release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH" echo "release-binary-basename=$release_binary_basename" >> $GITHUB_OUTPUT echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT + enable_pgo=1 + + case "${{ inputs.runs-on }}" in + ubuntu-22.04*) + build_runs_on="depot-${{ inputs.runs-on }}-16" + test_runs_on=$build_runs_on + ;; + macos-13) + if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then + build_runs_on="${{ inputs.runs-on }}" + else + build_runs_on="macos-13-large" + fi + test_runs_on="${{ inputs.runs-on }}" + ;; + macos-14) + if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then + build_runs_on="${{ inputs.runs-on }}" + else + build_runs_on="depot-macos-14" + fi + test_runs_on="${{ inputs.runs-on }}" + ;; + *) + test_runs_on="${{ inputs.runs-on }}" + build_runs_on=$test_runs_on + ;; + esac + + case "$build_runs_on" in + # These runners cannot build the full release package faster than + # the 6 hours timeout limit, so we need to use a configuration + # that builds more quickly. + macos-13 | macos-14) + bootstrap_prefix="BOOTSTRAP" + target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF -DLLVM_RELEASE_ENABLE_PGO=OFF -D${bootstrap_prefix}-LLVM_TARGETS_TO_BUILD=Native" + ;; + *) + bootstrap_prefix="BOOTSTRAP_BOOTSTRAP" + ;; + esac target="$RUNNER_OS-$RUNNER_ARCH" # The hendrikmuhs/ccache-action action does not support installing sccache @@ -135,7 +176,7 @@ jobs: # add extra CMake args to disable them. # See https://github.com/llvm/llvm-project/issues/99767 if [ "$RUNNER_OS" = "macOS" ]; then - target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_COMPILER_RT_ENABLE_IOS=OFF" + target_cmake_flags="$target_cmake_flags -D${bootstrap_prefix}_COMPILER_RT_ENABLE_IOS=OFF" if [ "$RUNNER_ARCH" = "ARM64" ]; then arches=arm64 else @@ -146,7 +187,7 @@ jobs: # so we need to disable flang there. target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS='clang;lld;lldb;clang-tools-extra;polly;mlir'" fi - target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_BOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches" + target_cmake_flags="$target_cmake_flags -D${bootstrap_prefix}_DARWIN_osx_ARCHS=$arches -D${bootstrap_prefix}_DARWIN_osx_BUILTIN_ARCHS=$arches" fi build_flang="true" @@ -155,35 +196,11 @@ jobs: # The build times out on Windows, so we need to disable LTO. target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF" fi + + target_cmake_flags="$target_cmake_flags -D${bootstrap_prefix}_CPACK_PACKAGE_FILE_NAME=$release_binary_basename" echo "target-cmake-flags=$target_cmake_flags" >> $GITHUB_OUTPUT echo "build-flang=$build_flang" >> $GITHUB_OUTPUT - case "${{ inputs.runs-on }}" in - ubuntu-22.04*) - build_runs_on="depot-${{ inputs.runs-on }}-16" - test_runs_on=$build_runs_on - ;; - macos-13) - if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then - build_runs_on="${{ inputs.runs-on }}" - else - build_runs_on="macos-13-large" - fi - test_runs_on="${{ inputs.runs-on }}" - ;; - macos-14) - if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then - build_runs_on="${{ inputs.runs-on }}" - else - build_runs_on="depot-macos-14" - fi - test_runs_on="${{ inputs.runs-on }}" - ;; - *) - test_runs_on="${{ inputs.runs-on }}" - build_runs_on=$test_runs_on - ;; - esac echo "build-runs-on=$build_runs_on" >> $GITHUB_OUTPUT echo "test-runs-on=$test_runs_on" >> $GITHUB_OUTPUT @@ -229,9 +246,7 @@ jobs: # so we need to set some extra cmake flags to disable this. cmake -G Ninja -S llvm -B ${{ steps.setup-stage.outputs.build-prefix }}/build \ ${{ needs.prepare.outputs.target-cmake-flags }} \ - -C clang/cmake/caches/Release.cmake \ - -DBOOTSTRAP_LLVM_PARALLEL_LINK_JOBS=1 \ - -DBOOTSTRAP_BOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}" + -C clang/cmake/caches/Release.cmake - name: Build shell: bash @@ -239,7 +254,7 @@ jobs: ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-package release_dir=`find ${{ steps.setup-stage.outputs.build-prefix }}/build -iname 'stage2-bins'` mv $release_dir/${{ needs.prepare.outputs.release-binary-filename }} . - + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ runner.os }}-${{ runner.arch }}-release-binary @@ -254,6 +269,38 @@ jobs: run: | ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-check-all + test-release-package-mac-flang: + name: "Test Release Package Mac OS (flang)" + needs: + - prepare + # Flang is currently disabled on Mac due to + # https://github.com/llvm/llvm-project/issues/160546 + # so we don't need to test it. + if: >- + false && + github.event_name == 'pull_request' && + (needs.prepare.outputs.build-runs-on == 'macos-13' || + needs.prepare.outputs.build-runs-on == 'macos-14') + runs-on: ${{ needs.prepare.outputs.build-runs-on }} + steps: + - name: Checkout LLVM + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + ref: ${{ needs.prepare.outputs.ref }} + - name: Install Ninja + uses: llvm/actions/install-ninja@a1ea791b03c8e61f53a0e66f2f73db283aa0f01e # main + - name: Configure + run: | + cmake -G Ninja -S llvm -B build \ + ${{ needs.prepare.outputs.target-cmake-flags }} \ + -DLLVM_RELEASE_ENABLE_PROJECTS="clang;mlir;flang" \ + -DLLVM_RELEASE_FINAL_STAGE_TARGETS="check-flang;check-mlir" \ + -C clang/cmake/caches/Release.cmake + - name: Build and Test + run: | + ninja -C build stage2-check-flang stage2-check-mlir + + upload-release-binaries: name: "Upload Release Binaries" needs: diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index a523cc561b3f9..9e9e4aa358137 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -30,12 +30,18 @@ endfunction() # # cmake -D LLVM_RELEASE_ENABLE_PGO=ON -C Release.cmake -set (DEFAULT_PROJECTS "clang;lld;lldb;clang-tools-extra;polly;mlir;flang") +set (DEFAULT_PROJECTS "clang;lld;lldb;clang-tools-extra;polly;mlir") # bolt only supports ELF, so only enable it for Linux. if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux") list(APPEND DEFAULT_PROJECTS "bolt") endif() +# Disable flang on Darwin due to: +# https://github.com/llvm/llvm-project/issues/160546 +if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") + list(APPEND DEFAULT_PROJECT "flang") +endif() + set (DEFAULT_RUNTIMES "compiler-rt;libcxx") if (NOT WIN32) list(APPEND DEFAULT_RUNTIMES "libcxxabi" "libunwind") @@ -44,6 +50,16 @@ set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "") set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "") set(LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "") set(LLVM_RELEASE_ENABLE_PROJECTS ${DEFAULT_PROJECTS} CACHE STRING "") + +if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") + # Don't link against the just built runtimes due to: + # https://github.com/llvm/llvm-project/issues/77653 + set(DEFAULT_LINK_LOCAL_RUNTIMES OFF) +else() + set(DEFAULT_LINK_LOCAL_RUNTIMES ON) +endif() +set(LLVM_RELEASE_LINK_LOCAL_RUNTIMES ${DEFAULT_LINK_LOCAL_RUNTIMES} CACHE BOOL "") + # Note we don't need to add install here, since it is one of the pre-defined # steps. set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "") @@ -55,8 +71,12 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") set(STAGE1_PROJECTS "clang") +# Need to build compiler-rt in order to use PGO for later stages. +set(STAGE1_RUNTIMES "compiler-rt") # Build all runtimes so we can statically link them into the stage2 compiler. -set(STAGE1_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind") +if(DEFAULT_LINK_LOCAL_RUNTIMES) + list(APPEND STAGE1_RUNTIMES "libcxx;libcxxabi;libunwind") +endif() if (LLVM_RELEASE_ENABLE_PGO) list(APPEND STAGE1_PROJECTS "lld") @@ -118,11 +138,13 @@ set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}" if (LLVM_RELEASE_ENABLE_LTO) set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL) endif() -set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL) -set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL) -set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind") -if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") - set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc") +if(DEFAULT_LINK_LOCAL_RUNTIMES) + set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL) + set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL) + set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind") + if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") + set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc") + endif() endif() # Set flags for bolt @@ -130,9 +152,11 @@ if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux") set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -Wl,--emit-relocs,-znow") endif() -set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING) -set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING) -set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING) +if (RELEASE_LINKER_FLAGS) + set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING) + set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING) + set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING) +endif() # Final Stage Config (stage2) set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)