-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<chrono>
: Implement fallback mechanism for chrono's [time.zone]
#1911
Comments
On Windows 7 with Visual Studio 16.11.3, I would get a |
Yes, this is definitely your problem. The current implementation needs Windows 10, and recent-ish Windows 10 at that. Failure on Windows 7 is expected until we implement some kind of fallback as the OP mentions. |
Thank you for the information! I will work around the issue for the time being. |
…dern OpenMPT and libopenmpt builds. Older versions of Windows 10 are still supported by legacy builds. Any of the removed Windows 10 versions are only supported for Windows 10 Enterprise by now, and not for consumer versions. Newer VS2022 functionality (like std::chrono timezone handling, see <microsoft/STL#1911> and <microsoft/STL#2163>) does not target these outdated Windows 10 versions any more. See <https://bugs.openmpt.org/view.php?id=1555>. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@17241 56274372-70c3-4bfc-bfc3-4c3a0b034d27
… to disable std::chrono date handling completely for MSVC when targeting Windows earlier than Windows 10 1903 due to <microsoft/STL#1911> and <microsoft/STL#2163>. [Ref] mpt/base/detect_quirks.hpp: Add MPT_LIBCXX_QUIRK_NO_CHRONO_DATE_PARSE tp disable std::chrono for date parsing in VS2022 due to <https://developercommunity.visualstudio.com/t/stdchronoget-tzdb-list-memory-leak/1644641> / <microsoft/STL#2504>. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@17377 56274372-70c3-4bfc-bfc3-4c3a0b034d27
…20 mode. [Ref] mptTime: Use std::chrono::system_clock for unix time instead of time_t in C++20 mode. This automatically makes date handling year2038-correct in C++20 mode. [Ref] mptTime: Add a custom gregorian date type mpt::Date::UTC to use instead of C struct tm. [Ref] UpdateCheck: Use mpt::Date::Unix instead of time_t. [Mod] UpdateCheck: Store last update timestamp as Unix seconds instead of YYYY-MM-DD HH:MM. On update, reset to 0. [Ref] mptTime: Disable std::chrono date handling completely for MSVC when targeting Windows earlier than Windows 10 1903 due to <microsoft/STL#1911> and <microsoft/STL#2163>. [Mod] OpenMPT: Version is now 1.31.00.12 git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@17383 56274372-70c3-4bfc-bfc3-4c3a0b034d27
Is there an advised work around for this issue? I would like to deploy an app build with Visual Studio 2022 17.3.0 on Windows Server 2016 but on this OS i get an error during the execution of the last line: Is it possible to deploy the ICU.DLL to this OS and how could this be achieved? Thanks I've got a workaround by deploying the icu.dll next to the app (loading this dll before the code above is invoked) and deploying the ICU data files to C:\Windows\Globalization\ICU. However I don't want to put this in production (obviously). |
Our customers have industrial grade PCs with preinstalled Windows 10 LTSC Build 17763 (Version 1809), where icu.dll is known to be missing. Unfortunately, it is not always possible to upgrade the existing Windows OS to a newer version, e.g. 1903. So we are limited by this circumstance in software development and unable to use the actually standardized C++ 20 features, especially std::chono functions. Is there any chance to provide the missing icu.dll at least via Visual C++ redistributable package? https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist The current available redistributable is explicitly marked to support Windows Vista, 7, 8.1, 10, 11 and Visual Studio 2015, 2017, 2019, 2022. It's a bit strange that support of even older OS versions is advertised but effectively not present. See also C++20’s Extensions to Chrono Available in Visual Studio 2019 version 16.10
|
In order to support older versions of Windows and also because of performance reasons (as explained in #2842), we were forced to write a few wrappers that handle old versions of Windows and improve performance. In short:
Using inheritance with types that don't have virtual functions (because they have not been made to inherit from) is a bad idea, however, due to the circumstances, we decided that this was the best solution. Also, caching as much as we could was critical for us, as all access to the ICU library is currently very slow for high-performance software. We even added the option of forcing legacy time handling (using localtime()/mktime()) even on modern versions of Windows whenever time zone handling is not needed, in order to further improve performance. This way we have time zones whenever we need them, and high performance otherwise. |
I almost forgot: there's also a related issue about |
wonder what is the preferred source for getting icu.dll and other required files? thank you |
also had to implement some custom classes even with Hinnant's date lib last year but not for performance reason but due to different set of problems such as say failed attempts to download tz database file, parse it, requirements to use in late stages of app finalization (after tzdb instance destruction), support of boost::serialization etc. funny that attempts to compile it with gcc revealed bug in 11.3 (something with type_traits and failing is_constructible though I did not report it, found some workaround) now that I adopted codebase to switch between date and chrono depending on c++ and libc version and rebuilt the project as c++20 I faced the problem with missing icu.dll on my win 7 so cannot test chrono [time.zone] support at the moment |
Interesting. I was under the impression that const HMODULE _Icu_module = LoadLibraryExW(L"icu.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); The documentation for
Maybe I might have misunderstood how this function actually loads DLLs? EDIT: For the case you also want to build workarounds with
|
hello! downloaded https://github.com/unicode-org/icu/releases/download/release-72-1/icu4c-72_1-Win64-MSVC2019.zip to no avail also tried to install icu from vcpkg, broke it during attempts (microsoft/vcpkg#29008) and my project (boostorg/filesystem#273), fixed but still cannot find also found unanswered https://stackoverflow.com/questions/71610601/how-to-build-icu-data-dll-in-windows |
@zlojvavan I have never checked it out until now, because we built our own solution like I explained above, since we thought that it would be a very bad idea to deploy to It seems that my Windows comes with ICU 68.2.0.10. Although Now, directly to your question: I'm not sure whether you would prefer to deploy to system32, but in that case, I guess it would work to simply copy the files from a newer version of Windows. (They won't get automatic updates like newer versions of Windows will, but that's beyond the point now.) I guess you could also build icu.dll yourself (how to build), but to my knowledge (see my comment above), you still have to deploy it to system32, in which case you could also simply copy it from a newer version of Windows. I'm currently not aware of any alternatives, although I would like to know if there are any. |
@doomlaur thanks for your answer. wanted to avoid building icu with "disable-renaming" option (to get rid of suffixes) and placed icu, ucuin, icuuc and few required dependence dlls from home win 10 to my win 7 system32 folder but ended up with error box about failed attempt to find kernel32.GetSystemTimePreciseAsFileTime in api-ms-win-core-sysinfo-l1-2-0.dll |
By the way, there's a documentation page from Microsoft about ICU. There they also explain that Beginning with Windows 10 1903 and Windows Server 2022, the two DLLs have been combined to a single |
Is there a workaround for this? I've recently encountered it while performing a clock_cast in code that needs to be able to run on Server 2019. Some way to tweak the clock being casted to avoid the need for a timezone lookup? Deploying |
I used the workaround for clock_casts explained here. Check out the last line - it avoids clock_casts by doing some manual calculations. |
That's useful as a stop-gap as long as we're not looking for extreme precision (luckily I don't care about time units much more precise than seconds in this case). The result of the subtraction is the type you need though so you can just do
unless I've missed something. I'm converting in the other direction ( |
Since Windows itself uses a precision of 100 nanoseconds, and because both the |
Yes please create a fallback for older Windows OSs. The workaround that worked for me, for Windows Server 2016 appears to be as @doomlaur explained:
I would love to see support from Microsoft so we don't have to workaround this issue. Windows Server 16 is supposed to be in long-term support until 2027, so their new compilers should also support that OS where possible. |
I have run into this bug as well recently. It's very difficult to troubleshoot because it's not obvious that the missing icu.dll is responsible for the problem, the only noticeable symptom is that std::chrono::current_zone throws an exception. And I need to deploy this software to computers running windows server 1806. |
Stumbling onto this while trying to figure out the best way to support date/time manipulation including timezones in C++ 20 for a new project. Add my vote for fixing this, IMHO it's a bug and not a feature enhancement, as this functionality is essentially useless in its current state for any real-world software that needs to ship to customers. |
We are using with software for a large number of customers and also got problems with windows versions not supporting timezones or leapseconds, because windows server 2016/2019 miss support for icu, but have long-term support by Microsoft and are common Customer OS. I wonder about, what would be the recommended way to get working on those machines/servers, because there is no redist on windows for those machines. It is also completely unexpected and feels like "bad-old-times", where you had no c++ standard and you always need to check for each function, if the shared lib and struct with that size is avail for each of your customers. Please provide redist packages of icu from Microsoft for all currently supported windows versions. Otherwise is just nice and we must turn back to Windows Legacy APIs (locked-in-effect), making the Standard Entities inaccessible for software development. Just a note, about what you may do to work around (but its really not good)
The solution is really a hack, because
|
I think Microsoft should just create a redist package for ICU which can be installed on older systems, but to also offer that package as Windows update. I don't think it would be much of a dramatic change, because as it seems the hard copied icu.dll works fine on older systems. Other approach would for the STL to support the standard zic compiled IANA database and let the user provide path to it via some kind of non-standard function as a fallback when the icu.dll is not found. |
@CaseyCarter @StephanTLavavej Sorry to bug you again regarding this issue, but I think it is very important if you really want to state a complete C++20 support. Throwing exceptions on older Windows versions is just not something which can be expected from a commercial product, Please consider the following:
Given that many Windows versions before Windows 10 1903 still have long life ahead of them(especially server editions) I think you have to really invest into long term valuable solution as we can't just tell to our clients "update to use our software" as other solutions might not need an update and still provide the needed functionality. Given the current state of the MS STL, I can't accept your claim of full production ready C++20 support as production ready would mean support for all Windows versions which are possible to target with Visual Studio. Also please in the future, when you are adding some new standard library feature, do not consider to omit older but still supported versions of Windows and just tell your customers that the software would run but will throw exceptions. |
@ingo-loehken one way to achieve your workaround would be to build a custom icu.dll from the sources at https://github.com/microsoft/icu that has a different load path for the data files. Unfortunately, the official ICU for Windows releases cannot be used, because they use multiple DLLs and not a single icu.dll. I have not tried this yet, but from a theoretical POV this should be an OK workaround that does not interfere too much with the system. Instead, as an even more hacky (but easier to achieve) workaround, I have copied icu*.dll and the ICU data files from a recent Windows installation to an old Windows LTSB installation, and this seems to be working reasonably OK. Nothing I can generally recommend, though. |
we did manage to support icu in older windows installations, but the import-address-table hooking technique used to redirect in older windows platforms to our own shared libs and ressources is really hacky and may fail in certain secured environments. |
Our implementation of a WG21-P0355 relies on information shipped with the Windows OS, which is only available in a form that we can use in more recent OS versions.
The affected pieces of WG21-P0355 are pieces of
[time.zone]
that need access to the IANA database, including[time.zone.leap]
. Our initial implementation had no alternate strategy for getting the time zone data or knowing when new leap seconds occur, but we should come back and include a fallback implementation that is usable on older OSes. We will need to do some investigation as to what these alternate strategies should exactly look like, perhaps relying ontimezoneapi.h
and some mapping between Windows and IANA time zone names (our initial plan before finding that we could use the ICU DLL) and a hard-coded table of leap seconds (both past and future) that will need to be maintained.Specifically, our limitations on Windows OS versions are:
FILETIME
struct only became leap-second-aware as of Server 2019 and Windows 10 October update.The text was updated successfully, but these errors were encountered: