On Wednesday 24 April 2024 23:41:24 Martin Storsjö wrote: > On Mon, 22 Apr 2024, Pali Rohár wrote: > > > Add 4 new macros FIXED_SIZE_SYMBOLS, NO_I64_FIXED_SIZE, > > NO_FIXED_SIZE_64_ALIAS and NO_TIME_ALIAS to distinguish > > between different crt versions. > > --- > > .../def-include/msvcrt-common.def.in | 154 ++++++++++++++++++ > > mingw-w64-crt/lib-common/msvcr120_app.def.in | 33 +--- > > mingw-w64-crt/lib-common/msvcrt.def.in | 23 +-- > > mingw-w64-crt/lib-common/ucrtbase.def.in | 12 -- > > mingw-w64-crt/lib32/crtdll.def.in | 12 +- > > mingw-w64-crt/lib32/msvcr100.def.in | 18 -- > > mingw-w64-crt/lib32/msvcr110.def.in | 18 -- > > mingw-w64-crt/lib32/msvcr120.def.in | 14 -- > > mingw-w64-crt/lib32/msvcr120d.def.in | 14 -- > > mingw-w64-crt/lib32/msvcr70.def.in | 12 +- > > mingw-w64-crt/lib32/msvcr71.def.in | 12 +- > > mingw-w64-crt/lib32/msvcr80.def.in | 22 --- > > mingw-w64-crt/lib32/msvcr90.def.in | 18 -- > > mingw-w64-crt/lib32/msvcr90d.def.in | 17 -- > > mingw-w64-crt/lib32/msvcrt10.def.in | 12 +- > > mingw-w64-crt/lib32/msvcrt20.def.in | 13 +- > > mingw-w64-crt/lib32/msvcrt40.def.in | 12 +- > > mingw-w64-crt/lib64/msvcr100.def.in | 18 -- > > mingw-w64-crt/lib64/msvcr110.def.in | 18 -- > > mingw-w64-crt/lib64/msvcr120.def.in | 14 -- > > mingw-w64-crt/lib64/msvcr120d.def.in | 13 -- > > mingw-w64-crt/lib64/msvcr80.def.in | 22 --- > > mingw-w64-crt/lib64/msvcr90.def.in | 18 -- > > mingw-w64-crt/lib64/msvcr90d.def.in | 18 -- > > 24 files changed, 169 insertions(+), 368 deletions(-) > > > > diff --git a/mingw-w64-crt/def-include/msvcrt-common.def.in > > b/mingw-w64-crt/def-include/msvcrt-common.def.in > > index 3e2c674d3699..abca29686531 100644 > > --- a/mingw-w64-crt/def-include/msvcrt-common.def.in > > +++ b/mingw-w64-crt/def-include/msvcrt-common.def.in > > @@ -197,6 +197,160 @@ _strtoimax_l == _strtoi64_l > > _strtoumax_l == _strtoui64_l > > #endif > > > > +; This is list of find symbol aliases, every CRT library has either find > > symbols with SIZE suffix or without them > > +#ifdef FIXED_SIZE_SYMBOLS > > +F32(_findfirst32 == _findfirst) > > +F64(_findfirst64i32 == _findfirst) > > +#ifndef NO_I64_FIXED_SIZE > > +F32(_findfirst32i64 == _findfirsti64) > > +#ifndef NO_FIXED_SIZE_64_ALIAS > > +F64(_findfirst64 == _findfirsti64) > > +#endif > > +#endif > > +F32(_findnext32 == _findnext) > > +F64(_findnext64i32 == _findnext) > > +#ifndef NO_I64_FIXED_SIZE > > +F32(_findnext32i64 == _findnexti64) > > +#ifndef NO_FIXED_SIZE_64_ALIAS > > +F64(_findnext64 == _findnexti64) > > +#endif > > +#endif > > +#ifndef NO_WIDE_FIXED_SIZE > > +F32(_wfindfirst32 == _wfindfirst) > > +F64(_wfindfirst64i32 == _wfindfirst) > > +#ifndef NO_I64_FIXED_SIZE > > +F32(_wfindfirst32i64 == _wfindfirsti64) > > +#ifndef NO_FIXED_SIZE_64_ALIAS > > +F64(_wfindfirst64 == _wfindfirsti64) > > +#endif > > +#endif > > +F32(_wfindnext32 == _wfindnext) > > +F64(_wfindnext64i32 == _wfindnext) > > +#ifndef NO_I64_FIXED_SIZE > > +F32(_wfindnext32i64 == _wfindnexti64) > > +#ifndef NO_FIXED_SIZE_64_ALIAS > > +F64(_wfindnext64 == _wfindnexti64) > > +#endif > > +#endif > > +#endif > > +#else > > +F32(_findfirst == _findfirst32) > > +F64(_findfirst == _findfirst64i32) > > This is the case that gets used by ucrtbase.def.in, right?
Yes, it should be. > > diff --git a/mingw-w64-crt/lib-common/ucrtbase.def.in > > b/mingw-w64-crt/lib-common/ucrtbase.def.in > > index 2d0552f277ef..c8fb1e33b1d7 100644 > > --- a/mingw-w64-crt/lib-common/ucrtbase.def.in > > +++ b/mingw-w64-crt/lib-common/ucrtbase.def.in > > @@ -327,12 +327,10 @@ _filelength > > _filelengthi64 > > _fileno > > _findclose > > -_findfirst == _findfirst64 > > Note how we unconditionally had these macros pointing at _findfirst64 in > ucrt, regardless of architecture. I must admit that this is an interesting issue. I looked at the mingw-w64-headers/crt/io.h file now and it is not set unconditionally as you wrote. There is: #ifdef _USE_32BIT_TIME_T ... #define _findfirst _findfirst32 ... #else ... #define _findfirst _findfirst64i32 ... #endif /* _USE_32BIT_TIME_T */ And then in mingw-w64-headers/crt/_mingw.h.in is defined: #if defined (_WIN32) && !defined (_WIN64) && !defined (__MINGW_USE_VC2005_COMPAT) && !defined (_UCRT) #ifndef _USE_32BIT_TIME_T #define _USE_32BIT_TIME_T #endif #endif And then in mingw-w64-headers/crt/corecrt.h is defined: #ifdef _USE_32BIT_TIME_T #ifdef _WIN64 #error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64 #undef _USE_32BIT_TIME_T #endif #endif /* _USE_32BIT_TIME_T */ So it means that 32-bit UCRT application can define _USE_32BIT_TIME_T before including header files and it will use 32-bit time_t. Anyway, this def file defines symbol alias "_findfirst" for linking. And every c/c++ source file which includes headers files would result in object file which will use either "_findfirst32" or "_findfirst64i32". Not "_findfirst" symbol. So in my opinion, this change should be safe. I think that meaning of the symbols should be same independently of the used CRT library. And for me this looks like a bug that UCRT was resolving _findfirst to different ABI function than msvcrt, at link time. I guess that it was rare to hit this issue as it required to either not include mingw-w64 header files and declare functions manually. Or write application in other language which does not use mingw-w64 C header files (e.g. in assembly or something similar) but uses mingw-w64 CRT libraries for linking. > Now I'm not positively sure that this is all strictly correct, but if it's > wrong, I would prefer to fix it in a separate commit, not in a refactoring > commit like this one. (Overall, on UCRT we default to 64 bit time_t even on > 32 bit architectures.) Please check what I wrote above. If you agree that this is a bug, I can prepare a separate fix for the UCRT (and then rebase 10/10 on top of it). > However, if we do change the aliases in ucrtbase.def.in, we also need to > update api-ms-win-crt-*.def.in as well, as we have similar declarations > there, scattered over a dozen of smaller files. > > // Martin Ou, and another files for which I forget api-ms-win-crt-*.def.in. And this is because they do not include that common .def.in file. I can look at them, but I would prefer to do it after all existing stuff is resolved as basically api-ms-win-crt-*.def.in does not use any common aliases. In my opinion, it would be better to change *crt*.def.in and api-ms-win-crt-*.def.in files to use common alias (would need refactor). _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public