Skip to content

Commit b2b47a7

Browse files
Document 32-bit time_t problem on minw-w64 toolchain and how to avoid it
1 parent 9d75e5e commit b2b47a7

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

README.windows

+21-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ cross compilers on Windows.
1212
To configure and build LibreSSL for a 32-bit system, use the following
1313
build steps:
1414

15-
CC=i686-w64-mingw32-gcc ./configure --host=i686-w64-mingw32
15+
CC=i686-w64-mingw32-gcc CPPFLAGS=-D__MINGW_USE_VC2005_COMPAT \
16+
./configure --host=i686-w64-mingw32
1617
make
1718
make check
1819

@@ -22,6 +23,25 @@ For 64-bit builds, use these instead:
2223
make
2324
make check
2425

26+
# Why the -D__MINGW_USE_VC2005_COMPAT flag on 32-bit systems?
27+
28+
An ABI change introduced with Microsoft Visual C++ 2005 (also known as
29+
Visual C++ 8.0) switched time_t from 32-bit to 64-bit. It is important to
30+
build LibreSSL with 64-bit time_t whenever possible, because 32-bit time_t
31+
is unable to represent times past 2038 (this is commonly known as the
32+
Y2K38 problem).
33+
34+
If LibreSSL is built with 32-bit time_t, when verifying a certificate whose
35+
expiry date is set past 19 January 2038, it will be unable to tell if the
36+
certificate has expired or not, and thus take the safe stance and reject it.
37+
38+
In order to avoid this, you need to build LibreSSL (and everything that links
39+
with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This tells mingw-w64 to
40+
use the new ABI.
41+
42+
64-bit systems always have a 64-bit time_t and are not affected by this
43+
problem.
44+
2545
# Using Libressl with Visual Studio
2646

2747
A script for generating ready-to-use .DLL and static .LIB files is included in

configure.ac

+8
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ AM_CONDITIONAL([SMALL_TIME_T], [test "$ac_cv_sizeof_time_t" = "4"])
142142
if test "$ac_cv_sizeof_time_t" = "4"; then
143143
echo " ** Warning, this system is unable to represent times past 2038"
144144
echo " ** It will behave incorrectly when handling valid RFC5280 dates"
145+
146+
if test "$host_os" = "mingw32" ; then
147+
echo " **"
148+
echo " ** You can solve this by adjusting the build flags in your"
149+
echo " ** mingw-w64 toolchain. Refer to README.windows for details."
150+
fi
151+
152+
exit 1
145153
fi
146154

147155
AC_REQUIRE_AUX_FILE([tap-driver.sh])

0 commit comments

Comments
 (0)