Skip to content

Commit f31fa3b

Browse files
Use Ninja in Windows CI and explicitly set the VS toolset version. (#4759)
[SC-41556] Since the GHA `windows-2022` runners [updated their version of Visual Studio yesterday](https://github.com/actions/runner-images/releases/tag/win22%2F20240218.2), we have been seeing errors of the form `error LNK2019: unresolved external symbol _Thrd_sleep_for`. After some investigation, the cause of the errors was found to be that the vcpkg dependencies were built with the new MSVC toolset (14.39), while the main CMake project was built with the old one (14.38)[^1]. After efforts to make the main project build with the 14.39 toolset (by passing `-T v143,version=14.39` or `-DCMAKE_VS_PLATFORM_TOOLSET_VERSION=14.39`) were unsuccessful, this PR switches to using the Ninja generator instead of Visual Studio. With Ninja the toolset version is specified by [a GitHub action](https://github.com/marketplace/actions/setup-msvc-developer-command-prompt) that sets the necessary environment variables. [^1]: If the opposite were to happen, it would be supported. Objects built with varying versions of MSVC toolsets [are binary-compatible](https://learn.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=msvc-170) with each other, but the final linking must be done with the newest version. --- TYPE: BUILD DESC: Fix linker errors when building with MSVC
1 parent d6f8bfb commit f31fa3b

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

.github/workflows/build-windows.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,22 @@ jobs:
6060
TILEDB_ARROW_TESTS: ${{ matrix.TILEDB_ARROW_TESTS }}
6161
TILEDB_WEBP: ${{ matrix.TILEDB_WEBP }}
6262
TILEDB_CMAKE_BUILD_TYPE: 'Release'
63+
# On windows-2019 we are using the Visual Studio generator, which is multi-config and places the build artifacts in a subdirectory
64+
CONFIG_PATH_FIXUP: ${{ matrix.os == 'windows-2019' && 'Release' || '' }}
6365
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
6466
steps:
67+
# By default Visual Studio chooses the earliest installed toolset version
68+
# for the main build and vcpkg chooses the latest. Force it to use the
69+
# latest (14.39 currently).
70+
- name: Setup MSVC toolset (VS 2022)
71+
uses: TheMrMilchmann/setup-msvc-dev@v3
72+
if: matrix.os == 'windows-2022'
73+
with:
74+
arch: x64
75+
toolset: 14.39
76+
- name: Install Ninja (VS 2022)
77+
uses: seanmiddleditch/gha-setup-ninja@v4
78+
if: matrix.os == 'windows-2022'
6579
- name: 'tiledb env prep'
6680
run: |
6781
$env:BUILD_BUILDDIRECTORY = $env:GITHUB_WORKSPACE.replace("TileDB\TileDB","tdbbd") # 't'ile'db' 'b'uild 'd'ir
@@ -141,7 +155,7 @@ jobs:
141155
# allow double-checking path
142156
cmd /c "echo $PATH"
143157
144-
$bootstrapOptions = $env:TILEDB_BASE_BOOTSTRAP_OPTIONS
158+
$bootstrapOptions = $env:TILEDB_BASE_BOOTSTRAP_OPTIONS + " -CMakeGenerator ${{ matrix.os == 'windows-2022' && 'Ninja' || '`"Visual Studio 16 2019`"' }}"
145159
if ($env:TILEDB_S3 -eq "ON") {
146160
$bootstrapOptions = "-EnableS3 " + $bootstrapOptions
147161
}
@@ -239,10 +253,7 @@ jobs:
239253
}
240254
241255
# CMake exits with non-0 status if there are any warnings during the build, so
242-
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j --target tiledb_unit --config $CMakeBuildType -- /verbosity:minimal
243-
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j --target unit_vfs --config $CMakeBuildType -- /verbosity:minimal
244-
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j --target tiledb_regression --config $CMakeBuildType -- /verbosity:minimal
245-
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j --target all_link_complete --config $CMakeBuildType -- /verbosity:minimal
256+
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j --target tiledb_unit unit_vfs tiledb_regression all_link_complete --config $CMakeBuildType
246257
247258
if ($env:TILEDB_AZURE -eq "ON") {
248259
if($env.TILEDB_USE_CUSTOM_NODE_JS) {
@@ -273,23 +284,23 @@ jobs:
273284
274285
# Actually run tests
275286
276-
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\$CMakeBuildType\tiledb_unit.exe -d=yes"
287+
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\$env:CONFIG_PATH_FIXUP\tiledb_unit.exe -d=yes"
277288
Write-Host "cmds: '$cmds'"
278289
Invoke-Expression $cmds
279290
if ($LastExitCode -ne 0) {
280291
Write-Host "Tests failed. tiledb_unit exit status: " $LastExitCocde
281292
$host.SetShouldExit($LastExitCode)
282293
}
283294
284-
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\tiledb\sm\filesystem\test\$CMakeBuildType\unit_vfs -d=yes"
295+
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\tiledb\sm\filesystem\test\$env:CONFIG_PATH_FIXUP\unit_vfs -d=yes"
285296
Write-Host "cmds: '$cmds'"
286297
Invoke-Expression $cmds
287298
if ($LastExitCode -ne 0) {
288299
Write-Host "Tests failed. tiledb_vfs exit status: " $LastExitCocde
289300
$host.SetShouldExit($LastExitCode)
290301
}
291302
292-
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\ci\$CMakeBuildType\test_assert.exe -d=yes"
303+
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\ci\$env:CONFIG_PATH_FIXUP\test_assert.exe -d=yes"
293304
Invoke-Expression $cmds
294305
if ($LastExitCode -ne 0) {
295306
Write-Host "Tests failed. test_assert exit status: " $LastExitCocde
@@ -311,7 +322,7 @@ jobs:
311322
312323
$TestAppDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api")
313324
$TestAppDataDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api\test_app_data")
314-
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api\$CMakeBuildType") -Filter *.exe |
325+
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api\$env:CONFIG_PATH_FIXUP\") -Filter *.exe |
315326
Foreach-Object {
316327
try {
317328
Set-Location -path $TestAppDir
@@ -344,7 +355,7 @@ jobs:
344355
345356
$TestAppDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api")
346357
$TestAppDataDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api\test_app_data")
347-
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api\$CMakeBuildType") -Filter *.exe |
358+
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api\$env:CONFIG_PATH_FIXUP\") -Filter *.exe |
348359
Foreach-Object {
349360
try {
350361
Set-Location -path $TestAppDir
@@ -389,12 +400,12 @@ jobs:
389400
cd build
390401
391402
# Build zip artifact
392-
cmake -A X64 -DCMAKE_PREFIX_PATH="$env:BUILD_BUILDDIRECTORY\dist;$env:BUILD_BUILDDIRECTORY\vcpkg_installed\x64-windows" ..
403+
cmake ${{ matrix.os != 'windows-2019' && '-G Ninja' || '' }} -DCMAKE_BUILD_TYPE="$CMakeBuildType" -DCMAKE_PREFIX_PATH="$env:BUILD_BUILDDIRECTORY\dist;$env:BUILD_BUILDDIRECTORY\vcpkg_installed\x64-windows" ..
393404
394405
cmake --build . --config $CMakeBuildType -v
395406
396-
#.\$CMakeBuildType\ExampleExe.exe
397-
$cmd = ".\$CMakeBuildType\ExampleExe.exe"
407+
#.\$env:CONFIG_PATH_FIXUP\ExampleExe.exe
408+
$cmd = ".\$env:CONFIG_PATH_FIXUP\ExampleExe.exe"
398409
Write-Host "cmd: '$cmd'"
399410
Invoke-Expression $cmd
400411

bootstrap.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Specify the linkage type to build TileDB with. Valid values are
2727
.PARAMETER RemoveDeprecations
2828
Build TileDB without any deprecated APIs.
2929
30+
.PARAMETER Architecture
31+
Specify the architecture to configure for.
32+
3033
.PARAMETER CMakeGenerator
3134
Optionally specify the CMake generator string, e.g. "Visual Studio 15
3235
2017". Check 'cmake --help' for a list of supported generators.
@@ -128,6 +131,7 @@ Param(
128131
[string]$Dependency,
129132
[string]$Linkage = "shared",
130133
[switch]$RemoveDeprecations,
134+
[string]$Architecture,
131135
[string]$CMakeGenerator,
132136
[switch]$EnableAssert,
133137
[switch]$EnableDebug,
@@ -327,6 +331,11 @@ if (![string]::IsNullOrEmpty($Dependency)) {
327331
$DependencyDir = $Dependency
328332
}
329333

334+
$ArchFlag = ""
335+
if ($PSBoundParameters.ContainsKey("Architecture")) {
336+
$ArchFlag = "-A $Architecture"
337+
}
338+
330339
# Set CMake generator type.
331340
$GeneratorFlag = ""
332341
if ($PSBoundParameters.ContainsKey("CMakeGenerator")) {
@@ -348,7 +357,7 @@ if ($CMakeGenerator -eq $null) {
348357

349358
# Run CMake.
350359
# We use Invoke-Expression so we can echo the command to the user.
351-
$CommandString = "cmake -A X64 -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" $VcpkgBaseTriplet -DCMAKE_PREFIX_PATH=""$DependencyDir"" -DMSVC_MP_FLAG=""/MP$BuildProcesses"" -DTILEDB_ASSERTIONS=$AssertionMode -DTILEDB_VERBOSE=$Verbosity -DTILEDB_AZURE=$UseAzure -DTILEDB_S3=$UseS3 -DTILEDB_GCS=$UseGcs -DTILEDB_SERIALIZATION=$UseSerialization -DTILEDB_WERROR=$Werror -DTILEDB_CPP_API=$CppApi -DTILEDB_TESTS=$Tests -DTILEDB_STATS=$Stats -DBUILD_SHARED_LIBS=$BuildSharedLibs -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$_RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory"""
360+
$CommandString = "cmake $ArchFlag -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" $VcpkgBaseTriplet -DCMAKE_PREFIX_PATH=""$DependencyDir"" -DMSVC_MP_FLAG=""/MP$BuildProcesses"" -DTILEDB_ASSERTIONS=$AssertionMode -DTILEDB_VERBOSE=$Verbosity -DTILEDB_AZURE=$UseAzure -DTILEDB_S3=$UseS3 -DTILEDB_GCS=$UseGcs -DTILEDB_SERIALIZATION=$UseSerialization -DTILEDB_WERROR=$Werror -DTILEDB_CPP_API=$CppApi -DTILEDB_TESTS=$Tests -DTILEDB_STATS=$Stats -DBUILD_SHARED_LIBS=$BuildSharedLibs -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$_RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory"""
352361
Write-Host $CommandString
353362
Write-Host
354363
Invoke-Expression "$CommandString"

0 commit comments

Comments
 (0)