Copilot commented on code in PR #61591:
URL: https://github.com/apache/doris/pull/61591#discussion_r2969667018


##########
env.sh:
##########
@@ -146,12 +153,24 @@ if [[ "${DORIS_TOOLCHAIN}" == "gcc" ]]; then
 elif [[ "${DORIS_TOOLCHAIN}" == "clang" ]]; then
     # set CLANG HOME
     if [[ -z "${DORIS_CLANG_HOME}" ]]; then
-        DORIS_CLANG_HOME="$(dirname "$(command -v clang)")"/..
+        BREW_LLVM_PREFIX="$(brew --prefix llvm 2>/dev/null || true)"
+        if [[ -n "${BREW_LLVM_PREFIX}" && -x "${BREW_LLVM_PREFIX}/bin/clang++" 
]]; then
+            DORIS_CLANG_HOME="${BREW_LLVM_PREFIX}"
+        else
+            DORIS_CLANG_HOME="$(dirname "$(command -v clang)")"/..
+        fi
         export DORIS_CLANG_HOME
     fi
 
     export CC="${DORIS_CLANG_HOME}/bin/clang"
     export CXX="${DORIS_CLANG_HOME}/bin/clang++"
+    LIBOMP_PREFIX="$(brew --prefix libomp 2>/dev/null || true)"
+    if [[ -n "${LIBOMP_PREFIX}" ]]; then
+        export OpenMP_ROOT="${LIBOMP_PREFIX}"
+        export CPPFLAGS="-I${LIBOMP_PREFIX}/include ${CPPFLAGS}"
+        export LDFLAGS="-L${LIBOMP_PREFIX}/lib ${LDFLAGS}"

Review Comment:
   This silently no-ops when `libomp` is not installed, but parts of the BE 
build use `find_package(OpenMP REQUIRED)` and will fail later with a less 
actionable CMake error on macOS (where OpenMP typically requires Homebrew 
`libomp`). Consider making missing `libomp` a clear early error on Darwin, 
and/or ensure it is included in the Homebrew tool list generated for macOS so 
the OpenMP runtime is consistently available.
   ```suggestion
           export LDFLAGS="-L${LIBOMP_PREFIX}/lib ${LDFLAGS}"
       elif [[ "${TARGET_SYSTEM}" == "Darwin" ]]; then
           echo "Error: Homebrew 'libomp' is required for OpenMP when using the 
clang toolchain on macOS."
           echo "Please install it with: brew install libomp"
           exit 1
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to