7080479 X binaries change too much on rebuilds
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Tue, 23 Aug 2011 14:00:30 -0700
changeset 1193 81e7bcbed056
parent 1192 60e4ec16e28d
child 1194 2596c47a24c6
7080479 X binaries change too much on rebuilds
open-src/Makefile
open-src/app/accessx/Makefile
open-src/app/rgb/Makefile
open-src/common/Makefile.init
open-src/lib/DPS/sun-src/libdps/Makefile
open-src/util/build-tools/Makefile
open-src/util/build-tools/sun-src/Makefile
open-src/util/build-tools/sun-src/time.c
open-src/xserver/xorg/Makefile
open-src/xserver/xorg/sun-src/tsol/Makefile.am
pkg/manifests/x11-x11-server-utilities.p5m
--- a/open-src/Makefile	Sun Aug 21 23:17:36 2011 -0700
+++ b/open-src/Makefile	Tue Aug 23 14:00:30 2011 -0700
@@ -43,7 +43,7 @@
 # - font depends on utils like mkfontdir from app
 
 # High level dependencies
-proto: util/util-macros util/lndir
+proto: util/util-macros util/lndir util/build-tools
 util/lndir: proto/x11proto
 lib: proto font/util util
 util: proto font/util
@@ -59,6 +59,7 @@
 
 OS_SUBDIRS_common = \
 	util/util-macros \
+	util/build-tools \
 	proto/x11proto \
 	util/lndir \
 	proto \
--- a/open-src/app/accessx/Makefile	Sun Aug 21 23:17:36 2011 -0700
+++ b/open-src/app/accessx/Makefile	Tue Aug 23 14:00:30 2011 -0700
@@ -54,9 +54,13 @@
 CONFIGURE_TARGETS=
 CONFIGURE_TARGETS_SET=yes
 
+# Override timestamps embedded in uil output files
+TIME_CONSTANT = 1272503297
+
 # Since we don't have a configure script, pass configure flags to make
-MODULE_BUILD_MAKEFLAGS=$(CONFIG_ENV) PREFIX=$(MODULE_PREFIX)
-MODULE_INSTALL_MAKEFLAGS=$(CONFIG_ENV) PREFIX=$(MODULE_PREFIX)
+MODULE_CONFIG_ENV = PREFIX=$(MODULE_PREFIX) $(CONSTANT_TIME)
+MODULE_BUILD_MAKEFLAGS	= $(CONFIG_ENV)
+MODULE_INSTALL_MAKEFLAGS= $(CONFIG_ENV)
 
 # Compatibility links from /usr/X11/bin to /usr/bin
 MODULE_X11_BINCOMPAT_LINKS = accessx
--- a/open-src/app/rgb/Makefile	Sun Aug 21 23:17:36 2011 -0700
+++ b/open-src/app/rgb/Makefile	Tue Aug 23 14:00:30 2011 -0700
@@ -43,10 +43,16 @@
 SUNTOUCHED_MANPAGES=man/*.man
 MODULE_STABILITY=Committed
 
-MODULE_CONFIG_OPTS = --with-rgb-db-dir=$(X11_DIR)/lib/X11/rgb \
-	--with-rgb-db-type=ndbm
-
 # Compatibility links from /usr/X11/bin to /usr/bin
-MODULE_X11_BINCOMPAT_LINKS = rgb showrgb
+MODULE_X11_BINCOMPAT_LINKS = showrgb
 
 include ../Makefile.inc
+
+# Additional compatibility links for the well-known rgb.txt data file
+X11_RGBCOMPAT_LINKS = $(PROTODIR)/usr/X11/lib/X11/rgb.txt
+
+install_X11_compat_links: $(X11_RGBCOMPAT_LINKS)
+
+$(X11_RGBCOMPAT_LINKS):
+	mkdir -p $(@D)
+	ln -s ../../../share/X11/rgb.txt $@
--- a/open-src/common/Makefile.init	Sun Aug 21 23:17:36 2011 -0700
+++ b/open-src/common/Makefile.init	Tue Aug 23 14:00:30 2011 -0700
@@ -87,24 +87,24 @@
 # Our default compiler is Sun Studio, but if you want to default to GNU 
 # compilers, you can change this here - some modules with specific 
 # requirements override this in their makefiles with MODULE_COMPILER.
-DEFAULT_COMPILER		= suncc
+DEFAULT_COMPILER	 = suncc
 
 # Flags used by either compiler in debug builds
-DEBUG_FLAGS_common	= -g $(MODTYPE_DEBUG_FLAGS) $(MODULE_DEBUG_FLAGS)
+DEBUG_FLAGS_common	 = -g $(MODTYPE_DEBUG_FLAGS) $(MODULE_DEBUG_FLAGS)
 
 ## Sun Studio
-CC_suncc		= cc
-CXX_suncc		= CC
-OPT_FLAGS_suncc		= -xO4 -W2,-Rext_tail_dup -xbuiltin=%none -xlibmil -xprefetch \
-			  -xdepend -xspace
-DEBUG_FLAGS_suncc	= $(DEBUG_FLAGS_common)
+CC_suncc		 = cc
+CXX_suncc		 = CC
+OPT_FLAGS_suncc		 = -xO4 -xbuiltin=%none -xlibmil -xprefetch -xdepend
+OPT_FLAGS_suncc		+= -xspace -W0,-xglobalstatic -W2,-Rext_tail_dup
+DEBUG_FLAGS_suncc	 = $(DEBUG_FLAGS_common)
 $(BUILD_DEBUG:yes=) DEBUG_OR_OPT_FLAGS_suncc = $(DEBUG_FLAGS_suncc)
 $(BUILD_DEBUG:yes=$(POUND_SIGN)) DEBUG_OR_OPT_FLAGS_suncc = $(OPT_FLAGS_suncc)
 
-CFLAGS_suncc 		= $(DEBUG_OR_OPT_FLAGS_suncc) -v -xstrconst \
-			  -features=extensions
-CXXFLAGS_suncc		= $(DEBUG_OR_OPT_FLAGS_suncc) +w2 -norunpath \
-			  -features=extensions
+CFLAGS_suncc 		 = $(DEBUG_OR_OPT_FLAGS_suncc)
+CFLAGS_suncc		+= -v -xstrconst -features=extensions
+CXXFLAGS_suncc		 = $(DEBUG_OR_OPT_FLAGS_suncc)
+CXXFLAGS_suncc		+= +w2 -norunpath -features=extensions
 
 # -D__<arch>__ flags are to match gcc definitions that are used in much
 # of the upstream open source code base
@@ -194,6 +194,9 @@
 # Common flags for all binaries
 LDFLAGS_common 		= -z combreloc -z lazyload $(MAPFILES_FOR_ALL)
 
+# Strip debug info out of non-debug builds
+$(BUILD_DEBUG:yes=$(POUND_SIGN))  LDFLAGS_common += -z strip-class=debug
+
 # LIB_REQUIRED_LDFLAGS are forced on via LD_OPTIONS to override libtool when
 # building libraries.
 LIB_REQUIRED_LDFLAGS	= -z text -z defs
@@ -280,6 +283,12 @@
 TOOLS_DIR=$(PROTOTOP)/tools_$(MACH)
 TOOLS_ACLOCAL_DIR=$(TOOLS_DIR)/share/aclocal
 
+# 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 MODULE_CONFIG_ENV/MODULE_BUILD_ENV/MODULE_INSTALL_ENV
+CONSTANT_TIME  = LD_PRELOAD_32=$(TOOLS_DIR)/time-$(MACH32).so
+CONSTANT_TIME += LD_PRELOAD_64=$(TOOLS_DIR)/time-$(MACH64).so
+CONSTANT_TIME += TIME_CONSTANT=$(TIME_CONSTANT)
 
 ### Other tools needed to build
 
--- a/open-src/lib/DPS/sun-src/libdps/Makefile	Sun Aug 21 23:17:36 2011 -0700
+++ b/open-src/lib/DPS/sun-src/libdps/Makefile	Tue Aug 23 14:00:30 2011 -0700
@@ -2,7 +2,7 @@
 #
 # libdps Makefile
 #
-# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -214,7 +214,8 @@
 
 includes:: $(DPSOPSCFILES) $(PSOPSCFILES) $(HEADERS)
 
-$(DPSOPSCFILES) $(PSOPSCFILES): $(PSWRAP)
+# Causes unnecessary rebuilds after set-elf-comments touches pswrap
+# $(DPSOPSCFILES) $(PSOPSCFILES): $(PSWRAP)
 
 SRCS = \
 	${COMMONSOURCEFILES} \
@@ -249,7 +250,7 @@
 .SUFFIXES: .psw
 
 .psw.c : 
-	$(V_PSWRAP)$(PSWRAP) -a -o $*.c -h $*.h $<
+	$(V_PSWRAP)$(PSWRAP) -a -o $*.c $<
 
 .psw.h : 
 	$(V_PSWRAP)$(PSWRAP) -a -h $*.h $< > /dev/null
@@ -306,4 +307,4 @@
 	$(INSTALL) libdps.so.5 $(DESTDIR)$(libdir)/libdps.so.5
 
 clean ::
-	${RM} $(DERIVED_FILES) .sort .ttt .att psops.h dpsops.h *%
+	${RM} $(DERIVED_FILES) .sort .ttt .att psops.h dpsops.h *% *.o
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/util/build-tools/Makefile	Tue Aug 23 14:00:30 2011 -0700
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+# No upstream sources, only local sources
+MODULE_NAME		= build-tools
+MODULE_VERSION 		= src
+SOURCE_TARBALL_NAME	= NONE
+SOURCE_TARBALL_NAME_SET	= yes
+ADDITIONAL_SOURCE_DIR	= sun-src
+
+# No configure script to run
+CONFIGURE_TARGETS	=
+CONFIGURE_TARGETS_SET	= yes
+
+# Build both 32-bit & 64-bit versions
+BUILD_TYPES		= 32 64
+BUILD_TYPES_SET		= yes
+
+# Since we don't have a configure script, pass configure flags to make
+MODULE_CONFIG_ENV	= MACH="$(MACH$(BUILD_TYPE))" DESTDIR="$(TOOLS_DIR)"
+MODULE_BUILD_MAKEFLAGS	= $(CONFIG_ENV)
+MODULE_INSTALL_MAKEFLAGS= $(CONFIG_ENV)
+
+include ../Makefile.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/util/build-tools/sun-src/Makefile	Tue Aug 23 14:00:30 2011 -0700
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+# LD_PRELOADable shared objects to interpose on time calls to make builds
+# more reproducible.
+
+all: time-$(MACH).so
+
+install: $(DESTDIR)/time-$(MACH).so
+
+time-%.o:	time.c
+	$(CC) -Kpic $(CFLAGS) -c -o $@ $<
+
+time-%.so: time-%.o
+	$(CC) -G $(CFLAGS) -o $@ $<
+
+clean:
+	$(RM) time-*.o time-*.so
+
+$(DESTDIR)/time-%.so: time-%.so
+	$(INSTALL) $< $@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/util/build-tools/sun-src/time.c	Tue Aug 23 14:00:30 2011 -0700
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This compiles to a module that can be preloaded during a build.  If this
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <ucontext.h>
+#include <dlfcn.h>
+#include <strings.h>
+#include <time.h>
+
+/* The list of programs that we want to use a constant time. */
+static char *programs[] = { "autogen", "bash", "cpp", "cc1", "date", "doxygen",
+	"erl", "javadoc", "ksh", "ksh93", "ld", "perl", "perl5.8.4", "perl5.10",
+	"ruby", "sh", "uil", NULL };
+
+static int
+stack_info(uintptr_t pc, int signo, void *arg)
+{
+	Dl_info info;
+	void *sym;
+
+	if (dladdr1((void *)pc, &info, &sym, RTLD_DL_SYMENT) != NULL) {
+		if (strstr(info.dli_fname, ".so") == NULL)
+			*(char **)arg = (char *)info.dli_fname;
+	}
+
+	return (0);
+}
+
+static char *
+my_execname()
+{
+	static char *execname;
+
+	if (execname == NULL) {
+		ucontext_t ctx;
+
+		if (getcontext(&ctx) == 0)
+			walkcontext(&ctx, stack_info, &execname);
+
+		if (execname != NULL) {
+			char *s = strrchr(execname, '/');
+
+			if (s != NULL)
+				execname = ++s;
+		}
+	}
+
+	return (execname);
+}
+
+static time_t
+time_constant()
+{
+	char *execname = my_execname();
+	time_t result = -1;
+
+	if (execname != NULL) {
+		int i;
+
+		for (i = 0; programs[i] != NULL; i++)
+			if (strcmp(execname, programs[i]) == 0) {
+				static char *time_string;
+
+				if (time_string == NULL)
+					time_string = getenv("TIME_CONSTANT");
+
+				if (time_string != NULL)
+					result = atoll(time_string);
+
+				break;
+			}
+	}
+
+	return (result);
+}
+
+time_t
+time(time_t *ptr)
+{
+	time_t result = time_constant();
+
+	if (result == (time_t)-1) {
+		static time_t (*fptr)(time_t *);
+
+		if (fptr == NULL)
+			fptr = (time_t (*)(time_t *))dlsym(RTLD_NEXT, "time");
+
+		result = (fptr)(ptr);
+	} else if (ptr != NULL)
+			*ptr = result;
+
+	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);
+}
--- a/open-src/xserver/xorg/Makefile	Sun Aug 21 23:17:36 2011 -0700
+++ b/open-src/xserver/xorg/Makefile	Tue Aug 23 14:00:30 2011 -0700
@@ -132,6 +132,9 @@
 MODULE_MAKE=$(GNUMAKE)
 MODULE_MAKE_SET=yes
 
+# Additional configure time targets beyond the defaults
+MODULE_ADD_CONFIGURE_TARGETS=clear_build_date
+
 # Additional install targets beyond the defaults
 MODULE_ADD_INSTALL_TARGETS=install_extras install_mdb install_pc_common \
 	install_fix_paths
@@ -163,6 +166,17 @@
 $(BUILD_DEBUG:yes=$(POUND_SIGN))	DEBUG_CONFIG_OPTS =
 MODULE_CONFIG_OPTS += $(DEBUG_CONFIG_OPTS)
 
+# Don't include build date & time in delivered binaries as it just causes
+# unnecessary binary differences to be pulled into package updates, but
+# leave it in debug builds for developer convenience
+$(BUILD_DEBUG:yes=$(POUND_SIGN)) CBD_TARGET = actually_clear_build_date
+
+clear_build_date: $(CBD_TARGET)
+
+actually_clear_build_date: $(AUTOCONF_TARGET)
+	printf '#undef BUILD_DATE\n#undef BUILD_TIME\n' > \
+		$(SOURCE_DIR)/hw/xfree86/common/xf86Build.h
+
 $(XORGSERVER_BIN): default_build
 
 SDK_INCLUDES_DIR=$(PROTODIR)$(X11_INCLUDES_DIR)/xorg/
--- a/open-src/xserver/xorg/sun-src/tsol/Makefile.am	Sun Aug 21 23:17:36 2011 -0700
+++ b/open-src/xserver/xorg/sun-src/tsol/Makefile.am	Tue Aug 23 14:00:30 2011 -0700
@@ -39,4 +39,4 @@
 
 AM_CFLAGS = $(DIX_CFLAGS) $(TSOLPOLICYFILEDEF)
 
-libxtsol_la_LIBADD = -ltsol -ltsnet -lbsm $(top_builddir)/randr/librandr.la
+libxtsol_la_LIBADD = -ltsol -ltsnet -lbsm
--- a/pkg/manifests/x11-x11-server-utilities.p5m	Sun Aug 21 23:17:36 2011 -0700
+++ b/pkg/manifests/x11-x11-server-utilities.p5m	Tue Aug 23 14:00:30 2011 -0700
@@ -27,7 +27,6 @@
 dir path=etc/xdg/autostart
 file path=etc/xdg/autostart/gnome-dispswitch.desktop
 file path=usr/bin/dispswitch
-file path=usr/bin/rgb
 file path=usr/bin/showrgb
 file path=usr/bin/xcmsdb
 file path=usr/bin/xgamma
@@ -41,12 +40,9 @@
 file path=usr/bin/xrefresh
 file path=usr/bin/xset
 file path=usr/bin/xsetroot
-file path=usr/lib/X11/rgb.dir
-file path=usr/lib/X11/rgb.pag
-file path=usr/lib/X11/rgb.txt
+file path=usr/share/X11/rgb.txt
 file path=usr/share/locale/C/LC_MESSAGES/xhost.po
 file path=usr/share/man/man1/dispswitch.1
-file path=usr/share/man/man1/rgb.1
 file path=usr/share/man/man1/showrgb.1
 file path=usr/share/man/man1/xcmsdb.1
 file path=usr/share/man/man1/xgamma.1
@@ -61,7 +57,6 @@
 file path=usr/share/man/man1/xset.1
 file path=usr/share/man/man1/xsetroot.1
 link path=usr/X11/bin/dispswitch target=../../bin/dispswitch
-link path=usr/X11/bin/rgb target=../../bin/rgb
 link path=usr/X11/bin/showrgb target=../../bin/showrgb
 link path=usr/X11/bin/xcmsdb target=../../bin/xcmsdb
 link path=usr/X11/bin/xgamma target=../../bin/xgamma
@@ -75,5 +70,6 @@
 link path=usr/X11/bin/xrefresh target=../../bin/xrefresh
 link path=usr/X11/bin/xset target=../../bin/xset
 link path=usr/X11/bin/xsetroot target=../../bin/xsetroot
+link path=usr/X11/lib/X11/rgb.txt target=../../../share/X11/rgb.txt
 # xrdb requires cpp
 depend fmri=pkg:/developer/macro/cpp type=require