From a65b45965360bc183854434dfafdbf2363151fea Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Fri, 18 Sep 2026 15:04:56 +0200 Subject: [PATCH 1/2] Fix PCH visibility settings. --- test/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d828dc251994..b0ebfaedee90 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,6 +8,15 @@ include(CheckCXXCompilerFlag) add_executable(_test_internal EXCLUDE_FROM_ALL pch_helper.cpp) target_link_libraries(_test_internal PRIVATE Halide::Test Halide::TerminateHandler) target_precompile_headers(_test_internal PRIVATE ) +# The PCH must be compiled with the same visibility settings as the targets +# that reuse it (via REUSE_FROM, applied in add_halide_test()) -- otherwise +# Clang rejects the PCH with "default visibility for functions and variables +# differs in PCH file vs. current file". +set_target_properties(_test_internal + PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN TRUE +) if (NOT Halide_TARGET MATCHES "wasm") # The PCH must be compiled with the same warning flags as the targets that # reuse it (via REUSE_FROM) -- MSVC in particular treats a mismatched From c0abf352bf781ee4ec5f711675d258d60dc3f702 Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Fri, 18 Sep 2026 19:54:34 +0200 Subject: [PATCH 2/2] Set PCH visibility settings directory-wide instead of per-target. Move the visibility settings needed for PCH reuse to directory-scoped variables in test/CMakeLists.txt, matching how the autoscheduler build sets them, and drop the now-redundant per-target visibility settings in add_halide_test(). Also normalize CMAKE_VISIBILITY_INLINES_HIDDEN to TRUE for consistency. Co-Authored-By: Alex Reinking Co-Authored-By: Claude Sonnet 5 --- cmake/HalideTestHelpers.cmake | 7 ------- src/autoschedulers/CMakeLists.txt | 2 +- test/CMakeLists.txt | 18 +++++++++--------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/cmake/HalideTestHelpers.cmake b/cmake/HalideTestHelpers.cmake index 898ac399110a..808d4f675d55 100644 --- a/cmake/HalideTestHelpers.cmake +++ b/cmake/HalideTestHelpers.cmake @@ -102,13 +102,6 @@ function(add_halide_test TARGET) set_tests_properties(${TARGET} PROPERTIES PASS_REGULAR_EXPRESSION "Success!") endif () - set_target_properties(${TARGET} - PROPERTIES - CXX_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN TRUE - ) - - if (WITH_SERIALIZATION AND WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING) if (NOT Halide_TARGET MATCHES "wasm") target_compile_definitions(${TARGET} PRIVATE WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING) diff --git a/src/autoschedulers/CMakeLists.txt b/src/autoschedulers/CMakeLists.txt index 631c1898b18c..1d70b3c29f00 100644 --- a/src/autoschedulers/CMakeLists.txt +++ b/src/autoschedulers/CMakeLists.txt @@ -2,7 +2,7 @@ # Everything else should be omitted to keep binary size low. set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) +set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE) function(add_autoscheduler) set(options) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b0ebfaedee90..ce2fedf56bba 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,15 @@ include(HalideTestHelpers) include(CheckCXXCompilerFlag) +# All test targets in this directory (and its subdirectories) must be built +# with the same visibility settings, since they reuse a common precompiled +# header via target_precompile_headers(REUSE_FROM) -- otherwise +# Clang rejects the PCH with "default visibility for functions and variables +# differs in PCH file vs. current file". +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE) + # _test_internal is not itself a test; it exists purely so that the other # test executables below can reuse its precompiled header via # target_precompile_headers(REUSE_FROM). HalideTestHelpers depends on this @@ -8,15 +17,6 @@ include(CheckCXXCompilerFlag) add_executable(_test_internal EXCLUDE_FROM_ALL pch_helper.cpp) target_link_libraries(_test_internal PRIVATE Halide::Test Halide::TerminateHandler) target_precompile_headers(_test_internal PRIVATE ) -# The PCH must be compiled with the same visibility settings as the targets -# that reuse it (via REUSE_FROM, applied in add_halide_test()) -- otherwise -# Clang rejects the PCH with "default visibility for functions and variables -# differs in PCH file vs. current file". -set_target_properties(_test_internal - PROPERTIES - CXX_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN TRUE -) if (NOT Halide_TARGET MATCHES "wasm") # The PCH must be compiled with the same warning flags as the targets that # reuse it (via REUSE_FROM) -- MSVC in particular treats a mismatched