Commit 385774a
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: I02ca46f3d8b928ebe62d546799b0b960a1639c6c1 parent 8e9069f commit 385774a
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
473 | | - | |
| 473 | + | |
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
| |||
0 commit comments