diff --git a/.github/workflows/be-ut-mac.yml b/.github/workflows/be-ut-mac.yml index 4f3db038dbab83..e7edafe3eb8a6c 100644 --- a/.github/workflows/be-ut-mac.yml +++ b/.github/workflows/be-ut-mac.yml @@ -29,7 +29,7 @@ concurrency: jobs: run-ut: name: BE UT (macOS) - runs-on: macos-13 + runs-on: macos-15-intel steps: - name: Checkout uses: actions/checkout@v3 @@ -44,6 +44,7 @@ jobs: with: filters: | be_changes: + - '.github/workflows/be-ut-mac.yml' - 'be/**' - 'gensrc/proto/**' - 'gensrc/thrift/**' @@ -80,21 +81,48 @@ jobs: 'openjdk@11' 'maven' 'node' - 'llvm@16' + 'llvm@18' + 'libomp' ) brew install "${cellars[@]}" || true + # The Intel runner exposes Homebrew's latest fmt from /usr/local/include, + # which can shadow the branch-pinned fmt shipped in the Doris thirdparty bundle. + brew unlink fmt || true pushd thirdparty branch="${{ github.base_ref }}" + case "$(uname -m)" in + arm64) asset="doris-thirdparty-prebuilt-darwin-arm64.tar.xz" ;; + x86_64) asset="doris-thirdparty-prebuilt-darwin-x86_64.tar.xz" ;; + *) echo "Unsupported macOS architecture: $(uname -m)" >&2; exit 1 ;; + esac + common_url="https://github.com/apache/doris-thirdparty/releases/download/automation/${asset}" if [[ -z "${branch}" ]] || [[ "${branch}" == 'master' ]]; then - curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz \ - -o doris-thirdparty-prebuilt-darwin-x86_64.tar.xz + curl -fL "${common_url}" -o "${asset}" else - curl -L "https://github.com/apache/doris-thirdparty/releases/download/automation-${branch/branch-/}/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz" \ - -o doris-thirdparty-prebuilt-darwin-x86_64.tar.xz + branch_url="https://github.com/apache/doris-thirdparty/releases/download/automation-${branch/branch-/}/${asset}" + if ! curl -fL "${branch_url}" -o "${asset}"; then + echo "::warning::No branch-specific macOS thirdparty asset for ${branch}; using automation" + curl -fL "${common_url}" -o "${asset}" + fi fi - tar -xvf doris-thirdparty-prebuilt-darwin-x86_64.tar.xz + tar -xvf "${asset}" popd - export JAVA_HOME="${JAVA_HOME_17_X64%\/}" + export JAVA_HOME + JAVA_HOME="$(/usr/libexec/java_home -v 17)" + + LLVM_PREFIX="$(brew --prefix llvm@18)" + export PATH="${LLVM_PREFIX}/bin:${PATH}" + export DORIS_CLANG_HOME="${LLVM_PREFIX}" + export CC="${LLVM_PREFIX}/bin/clang" + export CXX="${LLVM_PREFIX}/bin/clang++" + + LIBOMP_PREFIX="$(brew --prefix libomp)" + export CPPFLAGS="-I${LIBOMP_PREFIX}/include ${CPPFLAGS:-}" + export CFLAGS="-I${LIBOMP_PREFIX}/include ${CFLAGS:-}" + export CXXFLAGS="-I${LIBOMP_PREFIX}/include ${CXXFLAGS:-}" + export LDFLAGS="-L${LIBOMP_PREFIX}/lib ${LDFLAGS:-}" + export EXTRA_CXX_FLAGS="-I${LIBOMP_PREFIX}/include ${EXTRA_CXX_FLAGS:-}" + ./run-be-ut.sh --run -j "$(nproc)" --clean diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 3d6fb25f7f1101..48d0ab71fc66cd 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -843,8 +843,11 @@ if (ENABLE_PCH) find_package(OpenMP QUIET) if (OpenMP_CXX_FOUND OR OpenMP_FOUND) if (DEFINED OpenMP_CXX_FLAGS AND NOT OpenMP_CXX_FLAGS STREQUAL "") + separate_arguments(OPENMP_CXX_FLAG_LIST NATIVE_COMMAND "${OpenMP_CXX_FLAGS}") # Apply the OpenMP flags to all C++ compilations so PCH and all TUs match. - add_compile_options($<$:${OpenMP_CXX_FLAGS}>) + foreach(OPENMP_CXX_FLAG IN LISTS OPENMP_CXX_FLAG_LIST) + add_compile_options($<$:${OPENMP_CXX_FLAG}>) + endforeach() endif() # Ensure final link includes the OpenMP runtime when needed. if (TARGET OpenMP::OpenMP_CXX) @@ -864,7 +867,7 @@ if (ENABLE_PCH) target_link_libraries(pch PUBLIC OpenMP::OpenMP_CXX) # Also add flags explicitly to be robust if usage requirements don’t apply during PCH. if (DEFINED OpenMP_CXX_FLAGS AND NOT OpenMP_CXX_FLAGS STREQUAL "") - target_compile_options(pch PUBLIC ${OpenMP_CXX_FLAGS}) + target_compile_options(pch PUBLIC ${OPENMP_CXX_FLAG_LIST}) endif() # Copy usage requirements from the imported OpenMP target onto PCH. if (TARGET OpenMP::OpenMP_CXX) @@ -883,7 +886,7 @@ if (ENABLE_PCH) endif() endif() if (COMPILER_CLANG) - target_compile_options(pch PRIVATE -Xclang -fno-pch-timestamp) + target_compile_options(pch PRIVATE "SHELL:-Xclang -fno-pch-timestamp") endif() endif()