diff --git a/ci/scripts/build_example.sh b/ci/scripts/build_example.sh index 41714cf32c..fde163321a 100755 --- a/ci/scripts/build_example.sh +++ b/ci/scripts/build_example.sh @@ -38,19 +38,19 @@ CMAKE_ARGS=( if is_windows; then CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake") - CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") -else - CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Debug") fi +build_type="${ICEBERG_BUILD_TYPE:-Debug}" +CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=${build_type}") + cmake "${CMAKE_ARGS[@]}" ${source_dir} if is_windows; then - cmake --build . --config Release + cmake --build . --config "${build_type}" if [[ "${run_example}" == "ON" ]]; then if [[ -x ./demo_example.exe ]]; then ./demo_example.exe else - ./Release/demo_example.exe + ./"${build_type}"/demo_example.exe fi fi else diff --git a/ci/scripts/build_iceberg.sh b/ci/scripts/build_iceberg.sh index 6af0802f6b..e3bbc908a9 100755 --- a/ci/scripts/build_iceberg.sh +++ b/ci/scripts/build_iceberg.sh @@ -41,7 +41,7 @@ CMAKE_ARGS=( "-G Ninja" "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ICEBERG_HOME}}" "-DICEBERG_BUILD_STATIC=ON" - "-DICEBERG_BUILD_SHARED=ON" + "-DICEBERG_BUILD_SHARED=OFF" "-DICEBERG_BUILD_REST_INTEGRATION_TESTS=${build_rest_integration_test}" ) @@ -65,15 +65,15 @@ fi if is_windows; then CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake") - CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") -else - # Pass an externally provided toolchain (e.g. vcpkg for the SigV4 job) - if [[ -n "${CMAKE_TOOLCHAIN_FILE:-}" ]]; then - CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") - fi - CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Debug") fi +# Pass an externally provided toolchain (e.g. vcpkg for the SigV4 job) +if [[ -n "${CMAKE_TOOLCHAIN_FILE:-}" ]]; then + CMAKE_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") +fi + +CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=${ICEBERG_BUILD_TYPE:-Debug}") + if [[ "${build_enable_sccache}" == "ON" ]]; then CMAKE_ARGS+=("-DCMAKE_CXX_COMPILER_LAUNCHER=sccache") CMAKE_ARGS+=("-DCMAKE_C_COMPILER_LAUNCHER=sccache") @@ -85,10 +85,12 @@ if [[ -n "${ICEBERG_EXTRA_CMAKE_ARGS:-}" ]]; then fi cmake "${CMAKE_ARGS[@]}" ${source_dir} + +build_type="${ICEBERG_BUILD_TYPE:-Debug}" if is_windows; then - cmake --build . --config Release --target install + cmake --build . --config "${build_type}" --target install if [[ "${run_tests}" == "ON" ]]; then - ctest --output-on-failure -C Release + ctest --output-on-failure -C "${build_type}" fi else cmake --build . --target install diff --git a/cmake_modules/IcebergSccache.cmake b/cmake_modules/IcebergSccache.cmake index d02e65df53..dbe459a7ae 100644 --- a/cmake_modules/IcebergSccache.cmake +++ b/cmake_modules/IcebergSccache.cmake @@ -15,22 +15,19 @@ # specific language governing permissions and limitations # under the License. -if(MSVC_TOOLCHAIN AND "${CMAKE_CXX_COMPILER_LAUNCHER}" STREQUAL "sccache") - message(STATUS "Configuring sccache for MSVC") +if(MSVC_TOOLCHAIN) + message(STATUS "Embedding debug info (/Z7) on MSVC to avoid PDB lock contention with Ninja") - # Remove /Zi or /ZI - string(REGEX REPLACE "/Z[iI]" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REGEX REPLACE "/Z[iI]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + # CMake 3.25+ policy: force /Z7 (Embedded) for ALL targets including FetchContent deps. + # Without this, vendored Boost uses /Zi which races on the shared .pdb under Ninja. + cmake_policy(SET CMP0141 NEW) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) - string(REGEX REPLACE "/Z[iI]" "" CMAKE_C_FLAGS_RELWITHDEBINFO + # Belt-and-suspenders: also patch the default flag strings for older CMake code paths. + string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - string(REGEX REPLACE "/Z[iI]" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO + string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - - # Add /Z7 - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7") - - set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Z7") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Z7") endif() diff --git a/src/iceberg/test/CMakeLists.txt b/src/iceberg/test/CMakeLists.txt index fcbc22126f..22602f8f23 100644 --- a/src/iceberg/test/CMakeLists.txt +++ b/src/iceberg/test/CMakeLists.txt @@ -264,7 +264,7 @@ if(ICEBERG_BUILD_SQL_CATALOG target_include_directories(sql_catalog_test PRIVATE "${CMAKE_BINARY_DIR}/iceberg/test/") target_sources(sql_catalog_test PRIVATE sql_catalog_test.cc) target_link_libraries(sql_catalog_test - PRIVATE iceberg_sql_catalog_static + PRIVATE "$,iceberg_sql_catalog_static,iceberg_sql_catalog_shared>" "$,iceberg_bundle_static,iceberg_bundle_shared>" GTest::gmock_main) if(MSVC_TOOLCHAIN) @@ -287,7 +287,8 @@ if(ICEBERG_BUILD_REST) add_executable(${test_name}) target_include_directories(${test_name} PRIVATE "${CMAKE_BINARY_DIR}/iceberg/test/") target_sources(${test_name} PRIVATE ${ARG_SOURCES}) - target_link_libraries(${test_name} PRIVATE GTest::gmock_main iceberg_rest_static) + target_link_libraries(${test_name} PRIVATE GTest::gmock_main + "$,iceberg_rest_static,iceberg_rest_shared>") if(MSVC_TOOLCHAIN) target_compile_options(${test_name} PRIVATE /bigobj) endif() diff --git a/src/iceberg/test/scan_test_base.h b/src/iceberg/test/scan_test_base.h index 5bd1222e02..ec57ef8f4b 100644 --- a/src/iceberg/test/scan_test_base.h +++ b/src/iceberg/test/scan_test_base.h @@ -350,7 +350,7 @@ class ScanTestBase : public testing::TestWithParam { private: int manifest_counter_ = 0; int manifest_list_counter_ = 0; - constexpr static PartitionValues kEmptyPartition{}; + inline static const PartitionValues kEmptyPartition{}; }; } // namespace iceberg diff --git a/src/iceberg/util/string_util.h b/src/iceberg/util/string_util.h index 01b6087b8c..3689605445 100644 --- a/src/iceberg/util/string_util.h +++ b/src/iceberg/util/string_util.h @@ -20,6 +20,7 @@ #pragma once #include +#include #include #include #include