# HG changeset patch # User Norm Jacobs # Date 1276200388 18000 # Node ID 33aaaec599914f67420e8b0fb763a5054d666728 # Parent 21f7a7ab78ba7f9c9caca444833537a770cecd7b update _DATE/_TIME compiler chatter reduction bits. make env a macro diff -r 21f7a7ab78ba -r 33aaaec59991 make-rules/configure.mk --- a/make-rules/configure.mk Thu May 20 13:21:58 2010 -0500 +++ b/make-rules/configure.mk Thu Jun 10 15:06:28 2010 -0500 @@ -70,7 +70,7 @@ $(COMPONENT_SRC)/build-%/.configured: $(COMPONENT_SRC)/.prep ($(RM) -rf $(@D) ; $(MKDIR) $(@D)) $(COMPONENT_PRE_CONFIGURE_ACTION) - (cd $(@D) ; env - $(CONFIGURE_ENV) $(CONFIG_SHELL) \ + (cd $(@D) ; $(ENV) $(CONFIGURE_ENV) $(CONFIG_SHELL) \ ../configure $(CONFIGURE_OPTIONS) $(CONFIGURE_OPTIONS.$(BITS))) $(COMPONENT_POST_CONFIGURE_ACTION) $(TOUCH) $@ @@ -78,14 +78,15 @@ # build the configured source $(COMPONENT_SRC)/build-%/.built: $(COMPONENT_SRC)/build-%/.configured $(COMPONENT_PRE_BUILD_ACTION) - (cd $(@D) ; $(COMPONENT_BUILD_ENV) $(GMAKE) $(COMPONENT_BUILD_TARGETS)) + (cd $(@D) ; $(ENV) $(COMPONENT_BUILD_ENV) \ + $(GMAKE) $(COMPONENT_BUILD_TARGETS)) $(COMPONENT_POST_BUILD_ACTION) $(TOUCH) $@ # install the built source into a prototype area $(COMPONENT_SRC)/build-%/.installed: $(COMPONENT_SRC)/build-%/.built $(COMPONENT_PRE_INSTALL_ACTION) - (cd $(@D) ; $(COMPONENT_INSTALL_ENV) $(GMAKE) \ + (cd $(@D) ; $(ENV) $(COMPONENT_INSTALL_ENV) $(GMAKE) \ DESTDIR=$(PROTO_DIR) $(COMPONENT_INSTALL_TARGETS)) $(COMPONENT_POST_INSTALL_ACTION) $(TOUCH) $@ diff -r 21f7a7ab78ba -r 33aaaec59991 make-rules/setup.py.mk --- a/make-rules/setup.py.mk Thu May 20 13:21:58 2010 -0500 +++ b/make-rules/setup.py.mk Thu Jun 10 15:06:28 2010 -0500 @@ -31,13 +31,15 @@ $(COMPONENT_SRC)/build-%/.built: $(COMPONENT_SRC)/.prep $(RM) -r $(@D) ; $(MKDIR) $(@D) $(COMPONENT_PRE_BUILD_ACTION) - (cd $(COMPONENT_SRC) ; env - $(PYTHON_ENV) $(PYTHON.$(BITS)) ./setup.py build --build-temp $(@D:$(COMPONENT_SRC)/%=%)) + (cd $(COMPONENT_SRC) ; $(ENV) $(PYTHON_ENV) \ + $(PYTHON.$(BITS)) ./setup.py build --build-temp $(@D:$(COMPONENT_SRC)/%=%)) $(COMPONENT_POST_BUILD_ACTION) $(TOUCH) $@ # install the built source into a prototype area $(COMPONENT_SRC)/build-%/.installed: $(COMPONENT_SRC)/build-%/.built $(COMPONENT_PRE_INSTALL_ACTION) - (cd $(COMPONENT_SRC) ; env - $(PYTHON_ENV) $(PYTHON.$(BITS)) ./setup.py install --root $(PROTO_DIR)) + (cd $(COMPONENT_SRC) ; $(ENV) $(PYTHON_ENV) \ + $(PYTHON.$(BITS)) ./setup.py install --root $(PROTO_DIR)) $(COMPONENT_POST_INSTALL_ACTION) $(TOUCH) $@ diff -r 21f7a7ab78ba -r 33aaaec59991 make-rules/shared-macros.mk --- a/make-rules/shared-macros.mk Thu May 20 13:21:58 2010 -0500 +++ b/make-rules/shared-macros.mk Thu Jun 10 15:06:28 2010 -0500 @@ -36,7 +36,12 @@ PKG_REPO = file://$(WS_TOP)/repo PROTO_DIR = $(shell pwd)/$(COMPONENT_SRC)/installed-prototype-$(MACH) -CONSTANT_TIME = LD_PRELOAD=$(TOOLS)/time.o +# work around _TIME, _DATE, embedded date chatter in component builds +# to use, set TIME_CONSTANT in the component Makefile and add $(CONSTANT_TIME) +# to the appropriate {CONFIGURE|BUILD|INSTALL}_ENV +CONSTANT_TIME = LD_PRELOAD_32=$(TOOLS)/time-$(MACH32).so +CONSTANT_TIME += LD_PRELOAD_64=$(TOOLS)/time-$(MACH64).so +CONSTANT_TIME += TIME_CONSTANT=$(TIME_CONSTANT) # set MACH from uname -p to either sparc or i386 MACH = $(shell uname -p) @@ -75,6 +80,8 @@ CC = $(CC.$(COMPILER).$(BITS)) CCC = $(CCC.$(COMPILER).$(BITS)) +LD = /usr/bin/ld + PYTHON.2.4.32 = /usr/bin/python2.4 PYTHON.2.4.64 = /usr/bin/amd64/python2.4 @@ -94,3 +101,4 @@ MKDIR = /bin/mkdir -p RM = /bin/rm -f CP = /bin/cp -f +ENV = /usr/bin/env diff -r 21f7a7ab78ba -r 33aaaec59991 tools/Makefile --- a/tools/Makefile Thu May 20 13:21:58 2010 -0500 +++ b/tools/Makefile Thu Jun 10 15:06:28 2010 -0500 @@ -23,7 +23,20 @@ include ../make-rules/shared-macros.mk -download setup prep build install publish validate: time.o +download setup prep build install publish validate: time-$(MACH32).so \ + time-$(MACH64).so + +time-$(MACH64).o: BITS=64 +time-$(MACH32).o time-$(MACH64).o: CFLAGS += -Kpic + +time-$(MACH32).o time-$(MACH64).o: time.c + $(CC) $(CFLAGS) -c -o $@ $< -clean clobber: - $(RM) time.o +time-%.so: time-%.o + $(LD) -G -o $@ $< + +clean: + $(RM) time-*.o + +clobber: clean + $(RM) time-*.so diff -r 21f7a7ab78ba -r 33aaaec59991 tools/time.c --- a/tools/time.c Thu May 20 13:21:58 2010 -0500 +++ b/tools/time.c Thu Jun 10 15:06:28 2010 -0500 @@ -23,8 +23,9 @@ /* * This compiles to a module that can be preloaded during a build. If this - * is preloaded, it interposes on time(2) and returns a constant value when - * the execname matches one of the desired "programs" and TIME_CONSTANT + * is preloaded, it interposes on time(2), gettimeofday(3C), and + * clock_gethrtime(3C) and returns a constant number of seconds since epoch + * when the execname matches one of the desired "programs" and TIME_CONSTANT * contains an integer value to be returned. */ @@ -32,9 +33,12 @@ #include #include #include +#include /* The list of programs that we want to use a constant time. */ -static char *programs[] = { "date", "cpp", "cc1", "perl", NULL }; +static char *programs[] = { "autogen", "bash", "cpp", "cc1", "date", "doxygen", + "erl", "javadoc", "ksh", "ksh93", "ld", "perl", "perl5.8.4", "perl5.10", + "ruby", "sh", NULL }; static int stack_info(uintptr_t pc, int signo, void *arg) @@ -43,7 +47,8 @@ void *sym; if (dladdr1((void *)pc, &info, &sym, RTLD_DL_SYMENT) != NULL) { - *(char **)arg = (char *)info.dli_fname; + if (strstr(info.dli_fname, ".so") == NULL) + *(char **)arg = (char *)info.dli_fname; } return (0); @@ -72,7 +77,7 @@ } static time_t -intercept() +time_constant() { char *execname = my_execname(); time_t result = -1; @@ -82,13 +87,13 @@ for (i = 0; programs[i] != NULL; i++) if (strcmp(execname, programs[i]) == 0) { - static char *time_constant; + static char *time_string; - if (time_constant == NULL) - time_constant = getenv("TIME_CONSTANT"); + if (time_string == NULL) + time_string = getenv("TIME_CONSTANT"); - if (time_constant != NULL) - result = atoll(time_constant); + if (time_string != NULL) + result = atoll(time_string); break; } @@ -100,7 +105,7 @@ time_t time(time_t *ptr) { - time_t result = intercept(); + time_t result = time_constant(); if (result == (time_t)-1) { static time_t (*fptr)(time_t *); @@ -114,3 +119,43 @@ return (result); } + +int +gettimeofday(struct timeval *tp, void *tzp) +{ + static int (*fptr)(struct timeval *, void *); + int result = -1; + + if (fptr == NULL) + fptr = (int (*)(struct timeval *, void *))dlsym(RTLD_NEXT, + "gettimeofday"); + + if ((result = (fptr)(tp, tzp)) == 0) { + time_t curtime = time_constant(); + + if (curtime != (time_t)-1) + tp->tv_sec = curtime; + } + + return (result); +} + +int +clock_gettime(clockid_t clock_id, struct timespec *tp) +{ + static int (*fptr)(clockid_t, struct timespec *); + int result = -1; + + if (fptr == NULL) + fptr = (int (*)(clockid_t, struct timespec *))dlsym(RTLD_NEXT, + "clock_gettime"); + + if ((result = (fptr)(clock_id, tp)) == 0) { + time_t curtime = time_constant(); + + if (curtime != (time_t)-1) + tp->tv_sec = curtime; + } + + return (result); +}