mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-18 21:28:02 +00:00
build: add test for 64-bit time support
Several GNU tools such as tar, coreutils, and findutils now build with support for 64-bit time by default and otherwise require reconfiguring with a flag --disable-year2038 in order to build without 64-bit time. Some standard C libraries, for example, certain older versions of glibc such as 2.31 have large file support but not long time bits support: checking for ... option to enable large file support... -D_FILE_OFFSET_BITS=64 checking for ... option for timestamps after 2038... support not detected This test using C code taken from largefile.m4 in gnulib uses math and casting to check for overflow with a macro and array pair that can only be defined when 64-bit time support is present, and otherwise errors. It is the exact same code used to test for 64-bit time during the configure stage of building these tools, so the results of this test before configure takes place will always be in concordance with the results of the test that takes place during the configure script. Based on the test, the configure flag --disable-year2038 is added to every host tool build depending on the host system. When the year 2038 problem finally comes around, the effect of the test can be converted from the toggling of a configure option into a build prerequisite, requiring it to pass in order to continue building. Signed-off-by: Michael Pratt <mcpratt@pm.me> Link: https://github.com/openwrt/openwrt/pull/15799 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
f637cf5ef7
commit
39e8ef33bf
@ -67,6 +67,10 @@ HOST_CONFIGURE_ARGS = \
|
||||
--localstatedir=$(HOST_BUILD_PREFIX)/var \
|
||||
--sbindir=$(HOST_BUILD_PREFIX)/bin
|
||||
|
||||
ifneq ($(YEAR_2038),y)
|
||||
HOST_CONFIGURE_ARGS += --disable-year2038
|
||||
endif
|
||||
|
||||
HOST_MAKE_VARS = \
|
||||
CFLAGS="$(HOST_CFLAGS)" \
|
||||
CPPFLAGS="$(HOST_CPPFLAGS)" \
|
||||
|
14
rules.mk
14
rules.mk
@ -26,6 +26,7 @@ qstrip=$(strip $(subst ",,$(1)))
|
||||
empty:=
|
||||
space:= $(empty) $(empty)
|
||||
comma:=,
|
||||
pound:=\#
|
||||
merge=$(subst $(space),,$(1))
|
||||
confvar=$(shell echo '$(foreach v,$(1),$(v)=$(subst ','\'',$($(v))))' | $(MKHASH) md5)
|
||||
strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1))
|
||||
@ -378,6 +379,19 @@ define shexport
|
||||
export $(call shvar,$(1))=$$(call $(1))
|
||||
endef
|
||||
|
||||
# Test support for 64-bit time with C code from largefile.m4 provided by GNU Gnulib
|
||||
# the value is 'y' when successful and '' otherwise
|
||||
define YEAR_2038
|
||||
$(shell \
|
||||
mkdir -p $(TMP_DIR); \
|
||||
echo '$(pound) include <time.h>' > $(TMP_DIR)/year2038.c; \
|
||||
echo '$(pound) define LARGE_TIME_T ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))' >> $(TMP_DIR)/year2038.c; \
|
||||
echo 'int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535 && LARGE_TIME_T % 65537 == 0) ? 1 : -1];' >> $(TMP_DIR)/year2038.c; \
|
||||
echo 'int main (void) {return 0;}' >> $(TMP_DIR)/year2038.c; \
|
||||
$(HOSTCC) $(TMP_DIR)/year2038.c -o /dev/null 2>/dev/null && echo y && rm -f $(TMP_DIR)/year2038.c || rm -f $(TMP_DIR)/year2038.c; \
|
||||
)
|
||||
endef
|
||||
|
||||
# Execute commands under flock
|
||||
# $(1) => The shell expression.
|
||||
# $(2) => The lock name. If not given, the global lock will be used.
|
||||
|
Loading…
Reference in New Issue
Block a user