From bc06866b209293e7bdf5d89a588cb70a22b29b49 Mon Sep 17 00:00:00 2001 From: Haren S <12570877+harens@users.noreply.github.com> Date: Wed, 31 Aug 2022 08:03:25 +0000 Subject: [PATCH] make: add clock_gettime on macOS < 10.12 (fix #6605) (#15611) --- GNUmakefile | 38 ++++++++++++++++++++++++++++++++++++-- vlib/time/time_nix.c.v | 1 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index b407c1feb..6254364e3 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -7,9 +7,12 @@ VC ?= ./vc VEXE ?= ./v VCREPO ?= https://github.com/vlang/vc TCCREPO ?= https://github.com/vlang/tccbin +LEGACYREPO ?= https://github.com/macports/macports-legacy-support VCFILE := v.c TMPTCC := $(VROOT)/thirdparty/tcc +LEGACYLIBS := $(VROOT)/thirdparty/legacy +TMPLEGACY := $(LEGACYLIBS)/source TCCOS := unknown TCCARCH := unknown GITCLEANPULL := git clean -xf && git pull --quiet @@ -36,6 +39,9 @@ endif ifeq ($(_SYS),Darwin) MAC := 1 TCCOS := macos +ifeq ($(shell expr $(shell uname -r | cut -d. -f1) \<= 15), 1) +LEGACY := 1 +endif endif ifeq ($(_SYS),FreeBSD) @@ -79,13 +85,13 @@ endif endif endif -.PHONY: all clean check fresh_vc fresh_tcc check_for_working_tcc +.PHONY: all clean check fresh_vc fresh_tcc fresh_legacy check_for_working_tcc ifdef prod VFLAGS+=-prod endif -all: latest_vc latest_tcc +all: latest_vc latest_tcc latest_legacy ifdef WIN32 $(CC) $(CFLAGS) -std=c99 -municode -w -o v1.exe $(VC)/$(VCFILE) $(LDFLAGS) v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v @@ -93,6 +99,12 @@ ifdef WIN32 del v1.exe del v2.exe else +ifdef LEGACY + $(MAKE) -C $(TMPLEGACY) + $(MAKE) -C $(TMPLEGACY) PREFIX=$(realpath $(LEGACYLIBS)) CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) install + rm -rf $(TMPLEGACY) + $(eval override LDFLAGS+=-L$(realpath $(LEGACYLIBS))/lib -lMacportsLegacySupport) +endif $(CC) $(CFLAGS) -std=gnu99 -w -o v1.exe $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS) ./v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v ./v2.exe -o $(VEXE) $(VFLAGS) cmd/v @@ -104,6 +116,7 @@ endif clean: rm -rf $(TMPTCC) + rm -rf $(LEGACYLIBS) rm -rf $(VC) ifndef local @@ -148,12 +161,33 @@ else @$(MAKE) --quiet check_for_working_tcc 2> /dev/null endif +ifndef local +latest_legacy: $(TMPLEGACY)/.git/config +ifdef LEGACY + cd $(TMPLEGACY) && $(GITCLEANPULL) +endif +else +latest_legacy: +ifdef LEGACY + @echo "Using local legacysupport" +endif +endif + +fresh_legacy: + rm -rf $(LEGACYLIBS) + $(GITFASTCLONE) $(LEGACYREPO) $(TMPLEGACY) + $(TMPTCC)/.git/config: $(MAKE) fresh_tcc $(VC)/.git/config: $(MAKE) fresh_vc +$(TMPLEGACY)/.git/config: +ifdef LEGACY + $(MAKE) fresh_legacy +endif + asan: $(MAKE) all CFLAGS='-fsanitize=address,undefined' diff --git a/vlib/time/time_nix.c.v b/vlib/time/time_nix.c.v index 7bf12f322..8909bb5cb 100644 --- a/vlib/time/time_nix.c.v +++ b/vlib/time/time_nix.c.v @@ -3,6 +3,7 @@ // that can be found in the LICENSE file. module time +#flag darwin -I@VEXEROOT/thirdparty/legacy/include/LegacySupport #include #include -- 2.30.2