build-libssp: Stop building the real libssp from GCC
As mingw-w64 now provides these routines, we no longer need to build the original library from GCC. As building with -fstack-protector-strong still links with -lssp (and -lssp_nonshared), we still need to provide libraries with these names, but they can be empty dummy libraries.
This commit is contained in:
1 parent
ef9806fc0a
commit
4ee7cc97de
7 files changed
+12
-98
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
.git
|
.git
|
||||||
llvm-project
|
llvm-project
|
||||||
mingw-w64
|
mingw-w64
|
||||||
libssp
|
|
||||||
lldb-mi
|
lldb-mi
|
||||||
make-*
|
make-*
|
||||||
libffi
|
libffi
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/llvm-project
|
/llvm-project
|
||||||
/mingw-w64
|
/mingw-w64
|
||||||
/libssp
|
|
||||||
/lldb-mi
|
/lldb-mi
|
||||||
/make-*
|
/make-*
|
||||||
/libffi
|
/libffi
|
||||||
|
|||||||
+2
-2
@@ -63,8 +63,8 @@ RUN ./build-llvm.sh $TOOLCHAIN_PREFIX && \
|
|||||||
rm -rf /build/*
|
rm -rf /build/*
|
||||||
|
|
||||||
# Build libssp
|
# Build libssp
|
||||||
COPY build-libssp.sh libssp-Makefile ./
|
COPY build-libssp.sh ./
|
||||||
RUN ./build-libssp.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS && \
|
RUN ./build-libssp.sh $TOOLCHAIN_PREFIX && \
|
||||||
rm -rf /build/*
|
rm -rf /build/*
|
||||||
|
|
||||||
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
|
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
|
||||||
+2
-2
@@ -154,8 +154,8 @@ RUN cd test && \
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Build libssp
|
# Build libssp
|
||||||
COPY build-libssp.sh libssp-Makefile ./
|
COPY build-libssp.sh ./
|
||||||
RUN ./build-libssp.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
|
RUN ./build-libssp.sh $TOOLCHAIN_PREFIX
|
||||||
|
|
||||||
RUN cd test && \
|
RUN cd test && \
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
for arch in $TOOLCHAIN_ARCHS; do \
|
||||||
|
|||||||
+1
-1
@@ -96,5 +96,5 @@ fi
|
|||||||
./build-libcxx.sh $PREFIX $CFGUARD_ARGS
|
./build-libcxx.sh $PREFIX $CFGUARD_ARGS
|
||||||
./build-mingw-w64-libraries.sh $PREFIX $CFGUARD_ARGS
|
./build-mingw-w64-libraries.sh $PREFIX $CFGUARD_ARGS
|
||||||
./build-compiler-rt.sh $PREFIX --build-sanitizers # CFGUARD_ARGS intentionally omitted
|
./build-compiler-rt.sh $PREFIX --build-sanitizers # CFGUARD_ARGS intentionally omitted
|
||||||
./build-libssp.sh $PREFIX $CFGUARD_ARGS
|
./build-libssp.sh $PREFIX # CFGUARD_ARGS not used
|
||||||
./build-openmp.sh $PREFIX $CFGUARD_ARGS
|
./build-openmp.sh $PREFIX $CFGUARD_ARGS
|
||||||
+7
-67
@@ -16,16 +16,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
CFGUARD_CFLAGS="-mguard=cf"
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--enable-cfguard)
|
|
||||||
CFGUARD_CFLAGS="-mguard=cf"
|
|
||||||
;;
|
|
||||||
--disable-cfguard)
|
|
||||||
CFGUARD_CFLAGS=
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
PREFIX="$1"
|
PREFIX="$1"
|
||||||
;;
|
;;
|
||||||
@@ -33,73 +25,21 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
if [ -z "$PREFIX" ]; then
|
if [ -z "$PREFIX" ]; then
|
||||||
echo "$0 [--enable-cfguard|--disable-cfguard] dest"
|
echo "$0 dest"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MAKE=make
|
|
||||||
if command -v gmake >/dev/null; then
|
|
||||||
MAKE=gmake
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$PREFIX"
|
mkdir -p "$PREFIX"
|
||||||
PREFIX="$(cd "$PREFIX" && pwd)"
|
PREFIX="$(cd "$PREFIX" && pwd)"
|
||||||
export PATH="$PREFIX/bin:$PATH"
|
export PATH="$PREFIX/bin:$PATH"
|
||||||
|
|
||||||
: ${CORES:=$(nproc 2>/dev/null)}
|
|
||||||
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
|
|
||||||
: ${CORES:=4}
|
|
||||||
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
|
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
|
||||||
|
|
||||||
download() {
|
|
||||||
if command -v wget >/dev/null; then
|
|
||||||
if [ -n "$2" ]; then
|
|
||||||
wget -O "$2" "$1"
|
|
||||||
else
|
|
||||||
wget "$1"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -n "$2" ]; then
|
|
||||||
curl -L -o "$2" "$1"
|
|
||||||
else
|
|
||||||
curl -LO "$1"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -d libssp ]; then
|
|
||||||
download 'https://gitlab.com/watched/gcc-mirror/gcc/-/archive/releases/gcc-7.3.0/gcc-releases-gcc-7.3.0.tar.bz2?path=libssp' libssp.tar.bz2
|
|
||||||
tar xf libssp.tar.bz2 --strip-components=1
|
|
||||||
rm -f libssp.tar.bz2
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp libssp-Makefile libssp/Makefile
|
|
||||||
|
|
||||||
cd libssp
|
|
||||||
|
|
||||||
# gcc/libssp's configure script runs checks for flags that clang doesn't
|
|
||||||
# implement. We actually just need to set a few HAVE defines and compile
|
|
||||||
# the .c sources.
|
|
||||||
cp config.h.in config.h
|
|
||||||
for i in HAVE_FCNTL_H HAVE_INTTYPES_H HAVE_LIMITS_H HAVE_MALLOC_H \
|
|
||||||
HAVE_MEMMOVE HAVE_MEMORY_H HAVE_MEMPCPY HAVE_STDINT_H HAVE_STDIO_H \
|
|
||||||
HAVE_STDLIB_H HAVE_STRINGS_H HAVE_STRING_H HAVE_STRNCAT HAVE_STRNCPY \
|
|
||||||
HAVE_SYS_STAT_H HAVE_SYS_TYPES_H HAVE_UNISTD_H HAVE_USABLE_VSNPRINTF \
|
|
||||||
HAVE_HIDDEN_VISIBILITY; do
|
|
||||||
cat config.h | sed 's/^#undef '$i'$/#define '$i' 1/' > tmp
|
|
||||||
mv tmp config.h
|
|
||||||
done
|
|
||||||
cat ssp/ssp.h.in | sed 's/@ssp_have_usable_vsnprintf@/define/' > ssp/ssp.h
|
|
||||||
|
|
||||||
for arch in $ARCHS; do
|
for arch in $ARCHS; do
|
||||||
[ -z "$CLEAN" ] || rm -rf build-$arch
|
if [ ! -f $PREFIX/$arch-w64-mingw32/lib/libssp.a ]; then
|
||||||
mkdir -p build-$arch
|
# Create empty dummy archives, to avoid failing when the compiler
|
||||||
cd build-$arch
|
# driver adds "-lssp -lssh_nonshared" when linking.
|
||||||
$MAKE -f ../Makefile -j$CORES CROSS=$arch-w64-mingw32- CFGUARD_CFLAGS="$CFGUARD_CFLAGS"
|
llvm-ar rcs $PREFIX/$arch-w64-mingw32/lib/libssp.a
|
||||||
mkdir -p "$PREFIX/$arch-w64-mingw32/bin"
|
llvm-ar rcs $PREFIX/$arch-w64-mingw32/lib/libssp_nonshared.a
|
||||||
cp libssp.a "$PREFIX/$arch-w64-mingw32/lib"
|
fi
|
||||||
cp libssp_nonshared.a "$PREFIX/$arch-w64-mingw32/lib"
|
|
||||||
cp libssp.dll.a "$PREFIX/$arch-w64-mingw32/lib"
|
|
||||||
cp libssp-0.dll "$PREFIX/$arch-w64-mingw32/bin"
|
|
||||||
cd ..
|
|
||||||
done
|
done
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
SRC_PATH=$(word 1, $(dir $(MAKEFILE_LIST)))
|
|
||||||
vpath %.c $(SRC_PATH)
|
|
||||||
|
|
||||||
CC = $(CROSS)gcc
|
|
||||||
AR = $(CROSS)ar
|
|
||||||
|
|
||||||
CFLAGS = $(CFGUARD_CFLAGS) -O2 -Wall -Wundef -I$(SRC_PATH) -D_FORTIFY_SOURCE=0 -D__SSP_FORTIFY_LEVEL=0
|
|
||||||
|
|
||||||
SOURCES = $(filter-out ssp-local.c, $(patsubst $(SRC_PATH)%,%,$(wildcard $(SRC_PATH)*.c)))
|
|
||||||
OBJS = $(SOURCES:%.c=%.o)
|
|
||||||
|
|
||||||
all: libssp.a libssp_nonshared.a libssp-0.dll
|
|
||||||
|
|
||||||
libssp.a: $(OBJS)
|
|
||||||
$(AR) rcs $@ $+
|
|
||||||
|
|
||||||
libssp-0.dll: $(OBJS)
|
|
||||||
$(CC) -shared -o $@ $+ -Wl,--out-implib,libssp.dll.a
|
|
||||||
|
|
||||||
libssp_nonshared.a: ssp-local.o
|
|
||||||
$(AR) rcs $@ $+
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.a *.o *.dll
|
|
||||||
Reference in new issue
Block a user