From cc44e5da9c76f213582123bfa41a9574ad3428dc Mon Sep 17 00:00:00 2001 From: Alcaro Date: Sat, 8 Feb 2020 11:28:01 +0100 Subject: [PATCH] Don't strip by default, allow custom flags in make.sh, fix some win64 warnings --- Makefile | 3 ++- flips.cpp | 8 ++++++-- make-maintainer.sh | 4 ++-- make.sh | 17 ++++++++--------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 47e9e75..1a73a94 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ FNAME_windows := flips.exe FNAME_cli := flips CXX ?= g++ +CFLAGS ?= -g XFILES := @@ -98,4 +99,4 @@ ifeq ($(TARGET),gtk) endif $(FNAME_$(TARGET)): $(SOURCES) $(XFILES) - $(CXX) $^ -std=c++98 $(CFLAGS_G) $(MOREFLAGS) $(OPTFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o$@ + $(CXX) $^ -std=c++98 $(CFLAGS_G) $(MOREFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o$@ diff --git a/flips.cpp b/flips.cpp index 7cfe21a..f871fa0 100644 --- a/flips.cpp +++ b/flips.cpp @@ -803,10 +803,14 @@ struct errorinfo ApplyPatchMem2(file* patch, struct mem inrom, bool verifyinput, //http://msdn.microsoft.com/en-us/library/vstudio/tcxf1dw6.aspx says %zX is not supported //this is true up to and including Windows Vista; 7 adds support for it //I could define it to "I", but my GCC does not acknowledge its legitimacy and throws bogus warnings -//instead, let's just define it to size_t's underlying type: unsigned int / long long unsigned int +//nor does my GCC accept any supported alternative, so let's just nuke the entire warning. +//it's a poor solution, but it's the best I can find #ifdef _WIN32 # ifdef _WIN64 -# define z "ll" +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wformat" +# endif +# define z "I64" # else # define z "" # endif diff --git a/make-maintainer.sh b/make-maintainer.sh index f838fbe..1c35b9b 100755 --- a/make-maintainer.sh +++ b/make-maintainer.sh @@ -27,13 +27,13 @@ mingwver 64 || true # this is a script that sets the Wine PATH #FLAGS=$FLAGS' Z:/home/alcaro/tools/mingw64-8.1.0/x86_64-w64-mingw32/lib/libwinpthread.a' echo 'Windows (1/3)' -rm obj/* flips.exe; wine mingw32-make TARGET=windows OPTFLAGS="$FLAGS -fprofile-generate -lgcov" +rm obj/* flips.exe; wine mingw32-make TARGET=windows CFLAGS="$FLAGS -fprofile-generate -lgcov" [ -e flips.exe ] || exit echo 'Windows (2/3)' /usr/bin/time --verbose wine flips.exe --create --bps-delta profile/firefox-10.0esr.tar profile/firefox-17.0esr.tar /dev/null /usr/bin/time --verbose wine flips.exe --create --bps-delta-moremem profile/firefox-10.0esr.tar profile/firefox-17.0esr.tar /dev/null echo 'Windows (3/3)' -rm flips.exe; wine mingw32-make TARGET=windows OPTFLAGS="$FLAGS -fprofile-use" +rm flips.exe; wine mingw32-make TARGET=windows CFLAGS="$FLAGS -fprofile-use -s" #verify that there are no unexpected dependencies objdump -p flips.exe | grep 'DLL Name' | \ diff --git a/make.sh b/make.sh index 390617f..b815d44 100755 --- a/make.sh +++ b/make.sh @@ -6,11 +6,10 @@ FLAGS='-Wall -Werror -O3 -flto -fuse-linker-plugin -fomit-frame-pointer -fmerge- FLAGS=$FLAGS' -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables' FLAGS=$FLAGS' -ffunction-sections -fdata-sections -Wl,--gc-sections -fprofile-dir=obj/' #Linux flags, they don't make sense on Windows -#make-release.sh uses this +#make-maintainer.sh uses this LINFLAGS=' -Wl,-z,relro,-z,now,--as-needed,--hash-style=gnu,--relax' PROFILE=yes -STRIP="-s" for i in "$@"; do case "$i" in @@ -24,14 +23,14 @@ case "$i" in # Without PGO, it takes 2.5 seconds and 75MB RAM. However, the resulting binary is about 2% slower. PROFILE=no ;; - --strip=no) - STRIP="-g" + --cflags=*|--lflags=*) + FLAGS=$FLAGS" ${i#*=}" ;; - --harden=no|--strip=yes|--profile=yes) + --harden=no|--profile=yes) ;; *) echo "Unknown argument $1; valid arguments are:" - echo "--harden=no --harden=yes --profile=no --profile=no-once --profile=yes" + echo "--harden=yes --profile=no --cflags=(...) --lflags=(...)" exit 1 ;; esac @@ -40,7 +39,7 @@ done if [ $PROFILE = yes ]; then echo 'GTK+ (1/3)' -rm obj/* flips; TARGET=gtk make OPTFLAGS="$FLAGS$LINFLAGS -fprofile-generate -lgcov" || exit $? +rm obj/* flips; TARGET=gtk make CFLAGS="$FLAGS$LINFLAGS -fprofile-generate -lgcov" || exit $? [ -e flips ] || exit 1 echo 'GTK+ (2/3)' @@ -51,7 +50,7 @@ echo 'GTK+ (2/3)' /usr/bin/time --verbose ./flips --create --bps-delta-moremem profile/firefox-10.0esr.tar profile/firefox-17.0esr.tar /dev/null echo 'GTK+ (3/3)' -rm flips; TARGET=gtk make OPTFLAGS="$FLAGS$LINFLAGS -fprofile-use" || exit $? +rm flips; TARGET=gtk make CFLAGS="$FLAGS$LINFLAGS -fprofile-use" || exit $? else -rm flips; TARGET=gtk make OPTFLAGS="$FLAGS$LINFLAGS" || exit $? +rm flips; TARGET=gtk make CFLAGS="$FLAGS$LINFLAGS" || exit $? fi