@ -136,52 +136,78 @@ case "$gitstatus_cpu" in
*) archflag="-march";;
*) archflag="-march";;
esac
esac
cflags="$archflag=$gitstatus_cpu -fno-plt"
cflags="$archflag=$gitstatus_cpu -fno-plt -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fpie"
ldflags=
command touch "$workdir"/file-prefix-map-test.c
static_pie=
if 2>/dev/null "${CC:-/bin/cc}" \
-ffile-prefix-map=x=y \
printf 'int main() {}\n' >"$workdir"/cc-test.c
-c "$workdir"/file-prefix-map-test.c \
if 2>/dev/null "${CC:-cc}" \
-o "$workdir"/file-prefix-map-test.o; then
-ffile-prefix-map=x=y \
-Werror \
-c "$workdir"/cc-test.c \
-o "$workdir"/cc-test.o; then
cflags="$cflags -ffile-prefix-map=$workdir/="
cflags="$cflags -ffile-prefix-map=$workdir/="
fi
fi
command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o
if 2>/dev/null "${CC:-cc}" \
-fstack-clash-protection -fcf-protection \
-Werror \
-c "$workdir"/cc-test.c \
-o "$workdir"/cc-test.o; then
cflags="$cflags -fstack-clash-protection -fcf-protection"
fi
command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o
if 2>/dev/null "${CC:-cc}" \
-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now \
-Werror \
"$workdir"/cc-test.c \
-o "$workdir"/cc-test; then
ldflags="$ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
fi
command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o
if 2>/dev/null "${CC:-cc}" \
-fpie -static-pie \
-Werror \
"$workdir"/cc-test.c \
-o "$workdir"/cc-test; then
static_pie='-static-pie'
fi
if [ "$gitstatus_cpu" = x86-64 ]; then
if [ "$gitstatus_cpu" = x86-64 ]; then
cflags="$cflags -mtune=generic"
cflags="$cflags -mtune=generic"
fi
fi
libgit2_cmake_flags=
libgit2_cmake_flags=
libgit2_cflags="$cflags"
libgit2_cflags="${CFLAGS-} $ cflags -O3 -DNDEBUG "
gitstatus_cxx=g++
gitstatus_cxx=g++
gitstatus_cxxflags="$cflags -I${workdir}/libgit2/include -DGITSTATUS_ZERO_NSEC -D_GNU_SOURCE"
gitstatus_cxxflags="${CXXFLAGS-} $ cflags -I${workdir}/libgit2/include -DGITSTATUS_ZERO_NSEC -D_GNU_SOURCE -D_GLIBCXX_ASSERTIONS "
gitstatus_ldflags="-L${workdir}/libgit2/build"
gitstatus_ldflags="${LDFLAGS-} $ldflags -L${workdir}/libgit2/build"
gitstatus_ldlibs=
gitstatus_ldlibs=
gitstatus_make=make
gitstatus_make=make
case "$gitstatus_kernel" in
case "$gitstatus_kernel" in
linux)
linux)
gitstatus_ldflags="$gitstatus_ldflags -static"
gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
gitstatus_ldflags="$gitstatus_ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
;;
freebsd)
freebsd)
gitstatus_make=gmake
gitstatus_make=gmake
gitstatus_ldflags="$gitstatus_ldflags -static"
gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
gitstatus_ldflags="$gitstatus_ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
;;
openbsd)
openbsd)
gitstatus_cxx=eg++
gitstatus_cxx=eg++
gitstatus_make=gmake
gitstatus_make=gmake
gitstatus_ldflags="$gitstatus_ldflags -static"
gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
gitstatus_ldflags="$gitstatus_ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
;;
netbsd)
netbsd)
gitstatus_make=gmake
gitstatus_make=gmake
gitstatus_ldflags="$gitstatus_ldflags -static"
gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
gitstatus_ldflags="$gitstatus_ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
;;
darwin)
darwin)
@ -202,11 +228,11 @@ case "$gitstatus_kernel" in
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF"
;;
;;
msys*|mingw*)
msys*|mingw*)
gitstatus_ldflags="$gitstatus_ldflags -static"
gitstatus_ldflags="$gitstatus_ldflags ${static_pie:- -static} "
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
;;
cygwin*)
cygwin*)
gitstatus_ldflags="$gitstatus_ldflags -static"
gitstatus_ldflags="$gitstatus_ldflags ${static_pie:- -static} "
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
;;
*)
*)
@ -295,7 +321,7 @@ command mkdir libgit2/build
cd libgit2/build
cd libgit2/build
CFLAGS="$libgit2_cflags" command cmake \
CFLAGS="$libgit2_cflags" command cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_TYPE=None \
-DZERO_NSEC=ON \
-DZERO_NSEC=ON \
-DTHREADSAFE=ON \
-DTHREADSAFE=ON \
-DUSE_BUNDLED_ZLIB=ON \
-DUSE_BUNDLED_ZLIB=ON \