#5115 _USE_32BIT_TIME_T wrong for 32bit __MINGW32__

current: 8.5.14
closed-invalid
Jan Nijtmans
5
2014-08-14
2012-09-24
Earnie Boyd
No

The use of _USE_32BIT_TIME_T requires libmsvcr80.a and the MSVCR80.DLL. The MinGW.org team requires that distributions for software only require MSVCRT.DLL since this is the known system default. To resolve the issue I removed the define for this macro in win/tclWinPort.h to build the software.

Discussion

<< < 1 2 3 (Page 3 of 3)
  • Jan Nijtmans
    Jan Nijtmans
    2013-05-19

    My patch was sofar tested with the 8.4.20-rc2 only. If
    you want, I can post a new patch later, when I'm done
    testing with other Tcl versions. But I hope from the
    current patch, you get the idea what's wrong.

    I also created a special version of Tcl 9.0 (still highly
    experimental), which makes the switch from 32-bit
    time_t to to 64-bit time_t:
    <http://core.tcl.tk/tcl/info/807f110dd7>
    This compiles fine with VS2005+ and with your
    w32api-4.0-rc1, but it's binary incompatible
    with Tcl 8.x, that's why this switch can
    only be done in a new major Tcl version.

    Thanks!

     
  • Earnie Boyd
    Earnie Boyd
    2013-05-19

    The issue is the version of MSVCRT.DLL on the users system.

    The _USE_32BIT_TIME_T should be set based on the version of MSVCRT.DLL. In other words on XP OS version the time structures for time_t and the stat structures do not work with _USE_32BIT_TIME_T is defined.

    I'm working to develop some means of an autoconf m4 macro that can be used to determined which MSVCRT.DLL version we have so we know the supporting structures at build time. It will set something like MSVCRT_VERSION to the value of the MSVCRT.DLL version based on MajorLinkerVersion and MinorLinkerVersion obtained from $WINDIR/system32/msvcrt.dll via objdump. The _USE_32BIT_TIME_T will then be obsoleted and replaced by MSVCRT_VERSION. I will default to XP OS for MSVCRT_VERSION when it is not defined.

    I sent a query to the mingw-users list to find the values represented by the OSes available. The following is the list of values for (MajorLinkerVersion * 100) + MinorLinkerVersion:

    ME - 600
    XP - 710
    Vista - ???
    Win7 - 900
    Win8 - 1010

    I'm guessing Vista has the 32bit time_t structures but I don't know yet. I hope to get a VM built soon to find out.

    Note, that this will cause a backward incompatibility of a binary built on those OS supporting 32bit time_t versus those who do not. The work around for those who do not would be to find the MSVCR##.DLL where ## is >= 80 and copy it to MSVCRT.DLL in a non-standard location and add the non-standard location to the PATH before the Windows directories or copy it into the directories with the TCL binaries.

    Blame MS for this PITA we feel but they have every right to update the MSVCRT.DLL for each new OS.

     
  • Jan Nijtmans
    Jan Nijtmans
    2013-05-19

    > The _USE_32BIT_TIME_T should be set based on the version of MSVCRT.DLL. In
    > other words on XP OS version the time structures for time_t and the stat
    > structures do not work with _USE_32BIT_TIME_T is defined.

    If you replace _USE_32BIT_TIME_T to _HAVE_32BIT_TIME_T in
    your description, then I quite agree: _HAVE_32BIT_TIME_T can
    be eliminated using MSVCRT_VERSION. If functions are missing
    from some dll version, appropriate inline wrapper functions can be
    defined which do the same in terms existing functions, this way it
    should be made to work in all situations.

    _USE_32BIT_TIME_T should be used to switch back time_t to
    32-bit, when the default is 64-bit. That's the switch that
    Microsoft made in VC2005, and that's how Microsoft is
    using it in it's own header files. I think that mingw
    should do the same.

     
  • Earnie Boyd
    Earnie Boyd
    2013-05-20

    > _USE_32BIT_TIME_T should be used to switch back time_t to
    32-bit, when the default is 64-bit.

    I cannot do that, there are 64bit versions of XP; just not widely used.

    > If functions are missing
    from some dll version, appropriate inline wrapper functions can be
    defined which do the same in terms existing functions, this way it
    should be made to work in all situations.

    I've thought of that, but it will not happen for the 4.0 release.

    > _USE_32BIT_TIME_T should be used to switch back time_t to
    32-bit, when the default is 64-bit.

    I'll do some further research on that. It was confusing to me in the original MinGW headers why _USE_32BIT_TIME_T meant use 64bit.

     
  • Earnie Boyd
    Earnie Boyd
    2013-05-21

    > and that's how Microsoft is using it in it's own header files. I think that mingw should do the same.

    We simply cannot. We support legacy while newer versions of MSVC are supporting cutting-edge. It's a nightmare either for the compilation, the link or the execution depending on what we do. MinGW builds to -lmsvcrt by default since it is guaranteed to be on the system as the system C library; while MSVC builds to -lmsvcr## by default (where ## is the version used by the compiler) since it is part of the product.

    Now the MinGW user can specify -lmsvcr80 to get the appropriate functions but that runs into known collision issues since msvcrt.dll and mscvr80.dll will both be used and they both control memory independently so it is discouraged.

    Now I have a dilemma in that I need to support at least Windows 2000 and its version of MSVCRT.DLL which will not contain the needed functions for _USE_32BIT_TIME_T and even if the OS does such as Vista and above the MinGW libmsvcrt.a import library doesn't define them since we cannot ensure that they are contained in it. The MinGW user has a choice to use the MSVCRT.DLL directly to link against and that works when the functions exist in it.

    I need to think about what we want to do and query the users to determine best course of action for MinGW but since you've included the _USE_32BIT_TIME_T macro by default you'll need to be aware of the options for the user and document it.

    I've attached the patch I'm contemplating. It adds a warning when MSVCRT_VERSION is not >= 800 and _USE_32BIT_TIME_T is defined. It currently defines _USE_32BIT_TIME_T if MSVCRT_VERSION is >= 800 but I don't think that will stay since libmsvcrt.a doesn't contain the import of the functions. It will depend on the users desires after I ask them about it.

     
  • Jan Nijtmans
    Jan Nijtmans
    2013-05-22

    • status: open-invalid --> closed-invalid
     
  • Jan Nijtmans
    Jan Nijtmans
    2013-05-22

    Closing this, because it is not a Tcl bug.

    See:
    <https://sourceforge.net/p/mingw/bugs/1973/>

     
<< < 1 2 3 (Page 3 of 3)