Skip to content

Commit 385774a

Browse files
mvanhorncopybara-github
authored andcommitted
PR #2104: fix: export absl::time_zone name on MinGW DLL builds
Imported from GitHub PR #2104 ## Summary Building the monolithic shared library (`-DABSL_BUILD_MONOLITHIC_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=ON`) with MinGW on Windows fails at link time with an undefined reference to `absl::time_internal::cctz::GetWindowsLocalTimeZone()`. That symbol lives in `time/internal/cctz/src/time_zone_name_win.cc`, which `CMake/AbseilDll.cmake` only appends to `ABSL_INTERNAL_DLL_FILES` under `if(MSVC)` - so MinGW DLL builds never compile it, even though `time_zone_lookup.cc` calls it on all Windows toolchains. This splits the single `if(MSVC) ... else() ... endif()` block into two independent conditions: the `time_zone_name_win.cc`/`.h` sources are appended under `if(WIN32)` (covering MSVC, clang-cl, and MinGW), and the `flags/*` source group stays under `if(NOT MSVC)` so MinGW keeps receiving exactly the flags sources it gets today. ## Why this matters The per-target (non-DLL) build in `absl/time/CMakeLists.txt` already gates this file on `$<$<PLATFORM_ID:Windows>:...>` - i.e. any Windows platform - so the DLL list's `MSVC`-only gate is the inconsistency. `WIN32` is the correct CMake variable here; the patch sketched in the issue comments used `if(Windows)`, which is not a variable CMake defines, so this supersedes it. A carry-along fix was merged downstream into microsoft/vcpkg (#50887), but upstream remains broken. ## Testing No C++ sources change and there is no test file for the DLL file list, so verification is a CMake configure/build matrix: the monolithic shared-library build now links under MinGW (the previously-undefined `GetWindowsLocalTimeZone()` is compiled into the DLL), and the MSVC and non-MSVC builds are unchanged (MSVC still gets the Windows time-zone source via `WIN32`; MinGW still gets the `flags/*` sources via `NOT MSVC`). Fixes #2025 Merge 2efcf3d into 0784689 Merging this change closes #2104 COPYBARA_INTEGRATE_REVIEW=#2104 from mvanhorn:fix/2025-mingw-dll-time-zone-name-win 2efcf3d PiperOrigin-RevId: 946043634 Change-Id: I02ca46f3d8b928ebe62d546799b0b960a1639c6c
1 parent 8e9069f commit 385774a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

CMake/AbseilDll.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,14 @@ set(ABSL_INTERNAL_DLL_FILES
470470
"strings/string_view.h"
471471
)
472472

473-
if(MSVC)
473+
if(WIN32)
474474
list(APPEND ABSL_INTERNAL_DLL_FILES
475475
"time/internal/cctz/src/time_zone_name_win.cc"
476476
"time/internal/cctz/src/time_zone_name_win.h"
477477
)
478-
else()
478+
endif()
479+
480+
if(NOT MSVC)
479481
list(APPEND ABSL_INTERNAL_DLL_FILES
480482
"flags/commandlineflag.cc"
481483
"flags/commandlineflag.h"

0 commit comments

Comments
 (0)