Skip to content

build: correct MSVC and Windows mixup for CLANG_BUILD_STATIC#183609

Merged
compnerd merged 1 commit intollvm:mainfrom
compnerd:static
Feb 26, 2026
Merged

build: correct MSVC and Windows mixup for CLANG_BUILD_STATIC#183609
compnerd merged 1 commit intollvm:mainfrom
compnerd:static

Conversation

@compnerd
Copy link
Member

The build incorrectly used MSVC to determine that we were building for Windows (MS ABI). This prevents the use of the GNU driver for building LLVM for Windows. Adjust the condition to WIN32 AND NOT MINGW to correctly identify that we are building for Windows MS ABI.

The build incorrectly used `MSVC` to determine that we were building for
Windows (MS ABI). This prevents the use of the GNU driver for building
LLVM for Windows. Adjust the condition to `WIN32 AND NOT MINGW` to
correctly identify that we are building for Windows MS ABI.
@compnerd compnerd requested a review from mstorsjo February 26, 2026 19:48
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Feb 26, 2026
@llvmbot
Copy link
Member

llvmbot commented Feb 26, 2026

@llvm/pr-subscribers-clang

Author: Saleem Abdulrasool (compnerd)

Changes

The build incorrectly used MSVC to determine that we were building for Windows (MS ABI). This prevents the use of the GNU driver for building LLVM for Windows. Adjust the condition to WIN32 AND NOT MINGW to correctly identify that we are building for Windows MS ABI.


Full diff: https://github.com/llvm/llvm-project/pull/183609.diff

1 Files Affected:

  • (modified) clang/cmake/modules/AddClang.cmake (+1-1)
diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
index 4059fc3e986c7..c811b7f459126 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -108,7 +108,7 @@ macro(add_clang_library name)
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
-  if(MSVC AND NOT CLANG_LINK_CLANG_DYLIB)
+  if((WIN32 AND NOT MINGW) AND NOT CLANG_LINK_CLANG_DYLIB)
     # Make sure all consumers also turn off visibility macros so they're not
     # trying to dllimport symbols.
     target_compile_definitions(${name} PUBLIC CLANG_BUILD_STATIC)

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@compnerd compnerd merged commit 20ec9a9 into llvm:main Feb 26, 2026
12 checks passed
@compnerd compnerd deleted the static branch February 26, 2026 23:35
compnerd added a commit to compnerd/llvm-project that referenced this pull request Feb 26, 2026
…m#183609)

The build incorrectly used `MSVC` to determine that we were building for
Windows (MS ABI). This prevents the use of the GNU driver for building
LLVM for Windows. Adjust the condition to `WIN32 AND NOT MINGW` to
correctly identify that we are building for Windows MS ABI.

(cherry picked from commit 20ec9a9)
@llvm-ci
Copy link

llvm-ci commented Feb 27, 2026

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building clang at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/44859

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: 1200 seconds without output running [b'ninja', b'check-flang'], attempting to kill
...
PASS: Flang :: Lower/debug-use-stmt.f90 (4220 of 4230)
PASS: Flang :: Lower/submodule.f90 (4221 of 4230)
PASS: Flang :: Lower/derived-types.f90 (4222 of 4230)
PASS: Flang :: Lower/module_definition.f90 (4223 of 4230)
PASS: Flang :: Lower/module_use_in_same_file.f90 (4224 of 4230)
PASS: Flang :: Lower/OpenMP/rtl-flags.f90 (4225 of 4230)
PASS: Flang :: Lower/module-generic-with-specific-mangling.f90 (4226 of 4230)
PASS: Flang :: Lower/module-single-point-of-def.f90 (4227 of 4230)
PASS: Flang :: Lower/zero_init.f90 (4228 of 4230)
PASS: Flang :: Intrinsics/math-codegen.fir (4229 of 4230)
command timed out: 1200 seconds without output running [b'ninja', b'check-flang'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1913.167275

@llvm-ci
Copy link

llvm-ci commented Feb 27, 2026

LLVM Buildbot has detected a new failure on builder clang-ppc64le-linux-test-suite running on ppc64le-clang-test-suite while building clang at step 3 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/20206

Here is the relevant piece of the build log for the reference
Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'SanitizerCommon-asan-powerpc64le-Linux :: Linux/getpwnam_r_invalid_user.cpp' FAILED ********************
Exit Code: -6

Command Output (stdout):
--
# RUN: at line 2
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/./bin/clang  --driver-mode=g++ -gline-tables-only -fsanitize=address  -m64 -fno-function-sections -funwind-tables  -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test -ldl -O0 -g /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/getpwnam_r_invalid_user.cpp -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/asan-powerpc64le-Linux/Linux/Output/getpwnam_r_invalid_user.cpp.tmp &&  /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/asan-powerpc64le-Linux/Linux/Output/getpwnam_r_invalid_user.cpp.tmp
# executed command: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=address -m64 -fno-function-sections -funwind-tables -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test -ldl -O0 -g /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/getpwnam_r_invalid_user.cpp -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/asan-powerpc64le-Linux/Linux/Output/getpwnam_r_invalid_user.cpp.tmp
# executed command: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/asan-powerpc64le-Linux/Linux/Output/getpwnam_r_invalid_user.cpp.tmp
# .---command stderr------------
# | Result: 110
# | getpwnam_r_invalid_user.cpp.tmp: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/getpwnam_r_invalid_user.cpp:19: int main(): Assertion `res == 0 || res == ENOENT' failed.
# `-----------------------------
# error: command failed with exit status: -6

--

********************


sujianIBM pushed a commit to sujianIBM/llvm-project that referenced this pull request Mar 5, 2026
…m#183609)

The build incorrectly used `MSVC` to determine that we were building for
Windows (MS ABI). This prevents the use of the GNU driver for building
LLVM for Windows. Adjust the condition to `WIN32 AND NOT MINGW` to
correctly identify that we are building for Windows MS ABI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants