gcc: add support for SOURCE_DATE_EPOCH environment

+ Create symlinks from gcc/patches/libcpp-source_date_epoch.patch to cross-*/files/
+ Make all the _apply_patch() functions the same
This commit is contained in:
Jürgen Buchmüller 2016-03-08 05:22:12 +01:00
parent f0affd9a3b
commit c459dade15
48 changed files with 257 additions and 99 deletions

View File

@ -1,6 +1,10 @@
# If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
# only run this, if SOURCE_DATE_EPOCH isn't set.
if [ -z "$XBPS_USE_BUILD_MTIME" -a -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
unset SOURCE_DATE_EPOCH
return 0
fi
if [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
if command -v chroot-git &>/dev/null; then
GIT_CMD=$(command -v chroot-git)
elif command -v git &>/dev/null; then

View File

@ -1,27 +0,0 @@
# Remove leaked CFLAGS and CXXFLAGS parts which were defined
# by common/hooks/pre-configure/03-timestamp-macros.sh
# from shell scripts, perl scripts, package config files etc.
hook() {
local f mimetype
local strip=" -Wno-builtin-macro-redefined -include${XBPS_BUILDDIR}/\.xbps-.*/timestamp-macros\.h"
[ -n "$XBPS_USE_BUILD_MTIME" ] && return 0
[ -z "$SOURCE_DATE_EPOCH" ] && return 0
# Clean up shell scripts, perl files, pkgconfig files etc.
for f in $(grep -r -l -e "$strip" "$PKGDESTDIR" ); do
mimetype=$(file --mime-type "$f" | awk '{ print $2 }')
if [ "$mimetype" == "text/plain" -o \
"$mimetype" == "text/x-makefile" -o \
"$mimetype" == "text/x-shellscript" -o \
"$mimetype" == "application/xml" ]; then
sed -i "$f" -e "s;$strip;;"
msg_warn "Cleaned up ${f#${PKGDESTDIR}} ...\n"
else
# Unhandled mime-type file contains the $strip string
# E.g. binaries containing the build environment as a string
msg_warn "Can't clean ${f#${PKGDESTDIR}} (mime-type: $mimetype) ...\n"
fi
done
}

View File

@ -1,18 +0,0 @@
# This hook overwrites timestamp macros.
#
hook() {
local i mcr val macros="$XBPS_STATEDIR/timestamp-macros.h"
[ -n "$XBPS_USE_BUILD_MTIME" ] && return 0
[ -z "$SOURCE_DATE_EPOCH" ] && return 0
msg_normal "Creating $macros\n"
CFLAGS+=" -Wno-builtin-macro-redefined -include$macros"
CXXFLAGS+=" -Wno-builtin-macro-redefined -include$macros"
rm -f "$macros"
for i in "DATE,%b %d %Y" "TIME,%H:%M:%S" "DATETIME,%b %d %Y %H:%M:%S"; do
mcr=${i%%,*}
val=$(LC_ALL=C date --date "@$SOURCE_DATE_EPOCH" +"${i#*,}")
echo "#undef __${mcr}__" >> "$macros"
echo "#define __${mcr}__ \"${val}\"" >> "$macros"
done
}

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -11,7 +11,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=2
revision=3
short_desc="GNU Cross toolchain for the ${_triplet} LE target (binutils/gcc/glibc)"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
homepage="http://www.voidlinux.eu"
@ -36,10 +36,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
only_for_archs="x86_64"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np0 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -80,10 +80,11 @@ _binutils_build() {
_gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}
msg_normal "Building cross gcc bootstrap\n"
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
cd gcc-${_gcc_version}
msg_normal "Building cross gcc bootstrap\n"
[ ! -d ../gcc-bootstrap ] && mkdir ../gcc-bootstrap
cd ../gcc-bootstrap

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -11,7 +11,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=1
revision=2
short_desc="Cross toolchain for ARM64 LE target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -37,10 +37,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
depends="${pkgname}-libc-${version}_${revision}"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np1 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -69,7 +69,9 @@ _gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -39,10 +39,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
only_for_archs="i686 x86_64"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np0 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -84,10 +84,11 @@ _binutils_build() {
_gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}
msg_normal "Building cross gcc bootstrap\n"
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
cd gcc-${_gcc_version}
msg_normal "Building cross gcc bootstrap\n"
[ ! -d ../gcc-bootstrap ] && mkdir ../gcc-bootstrap
cd ../gcc-bootstrap

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=3
revision=4
short_desc="GNU Cross toolchain for the ${_triplet} LE target (binutils/gcc/glibc)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -39,10 +39,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
only_for_archs="i686 x86_64"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np0 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -84,10 +84,11 @@ _binutils_build() {
_gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}
msg_normal "Building cross gcc bootstrap\n"
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
cd gcc-${_gcc_version}
msg_normal "Building cross gcc bootstrap\n"
[ ! -d ../gcc-bootstrap ] && mkdir ../gcc-bootstrap
cd ../gcc-bootstrap

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=1
revision=2
short_desc="Cross toolchain for ARMv5 TE target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -41,7 +41,7 @@ _apply_patch() {
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -N $args -i ${2}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -71,6 +71,8 @@ _gcc_bootstrap() {
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=1
revision=2
short_desc="Cross toolchain for ARMv6 LE Hard Float target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -41,7 +41,7 @@ _apply_patch() {
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -N $args -i ${2}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -71,6 +71,8 @@ _gcc_bootstrap() {
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=2
revision=3
short_desc="GNU Cross toolchain for the ${_triplet} LE target (binutils/gcc/glibc)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -39,10 +39,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
only_for_archs="i686 x86_64"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np0 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -84,10 +84,11 @@ _binutils_build() {
_gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}
msg_normal "Building cross gcc bootstrap\n"
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
cd gcc-${_gcc_version}
msg_normal "Building cross gcc bootstrap\n"
[ ! -d ../gcc-bootstrap ] && mkdir ../gcc-bootstrap
cd ../gcc-bootstrap

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=1
revision=2
short_desc="Cross toolchain for ARMv7 LE Hard Float target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -41,7 +41,7 @@ _apply_patch() {
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -N $args -i ${2}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -71,6 +71,8 @@ _gcc_bootstrap() {
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -11,7 +11,7 @@ _archflags="-march=i686"
pkgname=cross-${_triplet}
version=0.21
revision=1
revision=2
short_desc="Cross toolchain for i686 target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -40,7 +40,7 @@ _apply_patch() {
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -N $args -i ${2}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -71,6 +71,8 @@ _gcc_bootstrap() {
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -11,7 +11,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=2
revision=3
short_desc="GNU Cross toolchain for the ${_triplet} target (binutils/gcc/glibc)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -37,10 +37,10 @@ depends="${pkgname}-libc-${version}_${revision}"
nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np0 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -70,6 +70,8 @@ _gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=2
revision=3
short_desc="Cross toolchain for MIPS32r2 BE softfloat target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -38,10 +38,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
depends="${pkgname}-libc-${version}_${revision}"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np1 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -70,7 +70,9 @@ _gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=2
revision=3
short_desc="Cross toolchain for MIPS32r2 LE softfloat target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -38,10 +38,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
depends="${pkgname}-libc-${version}_${revision}"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np1 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -70,7 +70,9 @@ _gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -12,7 +12,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=2
revision=3
short_desc="Cross toolchain for MIPS32r2 LE hardfloat target (musl)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -38,10 +38,10 @@ nostrip_files="libgcc.a libgcov.a libgcc_eh.a"
depends="${pkgname}-libc-${version}_${revision}"
_apply_patch() {
local pname="$(basename $1)"
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -Np1 -i ${1}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -70,7 +70,9 @@ _gcc_bootstrap() {
[ -f ${wrksrc}/.gcc_bootstrap_done ] && return 0
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1 @@
../../gcc/patches/gcc-spec-env-r1.patch

View File

@ -0,0 +1 @@
../../gcc/patches/libcpp-source_date_epoch.patch

View File

@ -10,7 +10,7 @@ _sysroot="/usr/${_triplet}"
pkgname=cross-${_triplet}
version=0.21
revision=1
revision=2
short_desc="Cross toolchain for x86_64 with musl"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.voidlinux.eu"
@ -39,7 +39,7 @@ _apply_patch() {
local args="$1" pname="$(basename $2)"
if [ ! -f ".${pname}_done" ]; then
patch -N $args -i ${2}
patch -N $args -i $2
touch .${pname}_done
fi
}
@ -70,6 +70,8 @@ _gcc_bootstrap() {
cd ${wrksrc}/gcc-${_gcc_version}
_apply_patch -p1 ${FILESDIR}/gcc-4.9.2-musl.diff
_apply_patch -p0 ${FILESDIR}/libcpp-source_date_epoch.patch
_apply_patch -p0 ${FILESDIR}/gcc-spec-env-r1.patch
msg_normal "Building cross gcc bootstrap\n"

View File

@ -0,0 +1,87 @@
2013-08-22 Magnus Granberg <zorry@gentoo.org>
* gcc/gcc.c (main): Add support for external spec file via the GCC_SPECS env var
and move the process of the user specifed specs.
This allows us to easily control pie/ssp defaults with gcc-config profiles.
Original patch by Rob Holland
Extended to support multiple entries separated by ':' by Kevin F. Quinn
Modified to use getenv instead of poisoned GET_ENVIRONMENT by Ryan Hill
Modified to process the GCC_SPECS env var befor DRIVER_SELF_SPECS by Magnus Granberg
--- gcc/gcc.c 2013-02-05 16:55:31.000000000 +0100
+++ gcc/gcc.c 2013-07-26 02:32:14.625089864 +0200
@@ -6427,6 +6428,48 @@ main (int argc, char **argv)
do_option_spec (option_default_specs[i].name,
option_default_specs[i].spec);
+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS) || defined (WIN32))
+ /* Add specs listed in GCC_SPECS. Note; in the process of separating
+ * each spec listed, the string is overwritten at token boundaries
+ * (':') with '\0', an effect of strtok_r().
+ */
+ specs_file = getenv ("GCC_SPECS");
+ if (specs_file && (strlen(specs_file) > 0))
+ {
+ char *spec, *saveptr;
+ for (spec=strtok_r(specs_file,":",&saveptr);
+ spec!=NULL;
+ spec=strtok_r(NULL,":",&saveptr))
+ {
+ struct user_specs *user = (struct user_specs *)
+ xmalloc (sizeof (struct user_specs));
+ user->next = (struct user_specs *) 0;
+ user->filename = spec;
+ if (user_specs_tail)
+ user_specs_tail->next = user;
+ else
+ user_specs_head = user;
+ user_specs_tail = user;
+ }
+ }
+#endif
+ /* Process any user specified specs in the order given on the command
+ * line. */
+ for (uptr = user_specs_head; uptr; uptr = uptr->next)
+ {
+ char *filename = find_a_file (&startfile_prefixes, uptr->filename,
+ R_OK, true);
+ read_specs (filename ? filename : uptr->filename, false, true);
+ }
+ /* Process any user self specs. */
+ {
+ struct spec_list *sl;
+ for (sl = specs; sl; sl = sl->next)
+ if (sl->name_len == sizeof "self_spec" - 1
+ && !strcmp (sl->name, "self_spec"))
+ do_self_spec (*sl->ptr_spec);
+ }
+
/* Process DRIVER_SELF_SPECS, adding any new options to the end
of the command line. */
@@ -6535,24 +6578,6 @@ main (int argc, char **argv)
PREFIX_PRIORITY_LAST, 0, 1);
}
- /* Process any user specified specs in the order given on the command
- line. */
- for (uptr = user_specs_head; uptr; uptr = uptr->next)
- {
- char *filename = find_a_file (&startfile_prefixes, uptr->filename,
- R_OK, true);
- read_specs (filename ? filename : uptr->filename, false, true);
- }
-
- /* Process any user self specs. */
- {
- struct spec_list *sl;
- for (sl = specs; sl; sl = sl->next)
- if (sl->name_len == sizeof "self_spec" - 1
- && !strcmp (sl->name, "self_spec"))
- do_self_spec (*sl->ptr_spec);
- }
-
if (compare_debug)
{
enum save_temps save;

View File

@ -0,0 +1,60 @@
Based on https://gcc.gnu.org/ml/gcc-patches/2015-06/txtLtaPOCTgpq.txt
Support for deterministic builds with externally defined
values for the macros __DATE__, __TIME__ and __DATETIME__.
If the environment variable SOURCE_DATE_EPOCH is defined,
use its value instead of the time(2) return value as
seconds since the Epoch.
Use strtoll() to convert SOURCE_DATE_EPOCH just in case
time_t is some day promoted to a 64 bit value.
--- libcpp/macro.c
+++ libcpp/macro.c
@@ -349,14 +349,38 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
slow on some systems. */
time_t tt;
struct tm *tb = NULL;
+ char *source_date_epoch;
- /* (time_t) -1 is a legitimate value for "number of seconds
- since the Epoch", so we have to do a little dance to
- distinguish that from a genuine error. */
- errno = 0;
- tt = time(NULL);
- if (tt != (time_t)-1 || errno == 0)
- tb = localtime (&tt);
+ /* Allow the date and time to be set externally by an exported
+ environment variable to enable reproducible builds. */
+ source_date_epoch = getenv ("SOURCE_DATE_EPOCH");
+ if (source_date_epoch)
+ {
+ errno = 0;
+ tt = (time_t) strtoll (source_date_epoch, NULL, 10);
+ if (errno == 0)
+ {
+ tb = gmtime (&tt);
+ if (tb == NULL)
+ cpp_error (pfile, CPP_DL_ERROR,
+ "SOURCE_DATE_EPOCH=\"%s\" is not a valid date",
+ source_date_epoch);
+ }
+ else
+ cpp_error (pfile, CPP_DL_ERROR,
+ "SOURCE_DATE_EPOCH=\"%s\" is not a valid number",
+ source_date_epoch);
+ }
+ else
+ {
+ /* (time_t) -1 is a legitimate value for "number of seconds
+ since the Epoch", so we have to do a little dance to
+ distinguish that from a genuine error. */
+ errno = 0;
+ tt = time(NULL);
+ if (tt != (time_t)-1 || errno == 0)
+ tb = localtime (&tt);
+ }
if (tb)
{

View File

@ -2,7 +2,7 @@
pkgname=gcc
_majorver=4.9
version=${_majorver}.3
revision=3
revision=4
short_desc="The GNU C Compiler"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://gcc.gnu.org"