>From 48a0bf1b93fd6e411b7f11b179f0aa6102bd9ed6 Mon Sep 17 00:00:00 2001 From: Frank Dittrich Date: Tue, 16 Apr 2013 10:47:52 +0200 Subject: [PATCH] Makefile changes to make building *-clang-debug targets easier Depending on clang version and distribution, you have to use -faddress-sanitizer or -fsanitize=address. Some distributions broke clang's ASAN feature, so this option cannot be used. This patch introduces a variable named CFLAG_SANITIZE_ADDRESS. Default is the new option -fsanitize=address, instead of the deprecated -faddress-sanitizer --- src/Makefile | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Makefile b/src/Makefile index 5facb6e..8a1fa8f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -95,6 +95,20 @@ OPT_NORMAL = -funroll-loops # Remove the "-Os" if you're using an ancient version of gcc OPT_INLINE = -Os -funroll-loops -finline-functions +# clang's -fsanitize=address option, used for *-clang-debug targets +# +# This is the old option name (deprecated, but might be required for +# older clang versions): +# CFLAG_SANITIZE_ADDRESS = -faddress-sanitizer +# +# This is the preferred new name: +CFLAG_SANITIZE_ADDRESS = -fsanitize=address +# +# Disabling this option might be required for distributions +# where clang's ASAN feature is broken, see +# https://bugzilla.redhat.com/show_bug.cgi?id=949489 +# CFLAG_SANITIZE_ADDRESS = + # Works with Solaris make, and GNU make PLUGFORMATS_SRCS: sh =echo *_plug.c PLUGFORMATS_SRCS += $(wildcard *_plug.c) @@ -492,17 +506,17 @@ linux-x86-64-clang-debug: @echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h $(MAKE) $(PROJ) \ JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o sse-intrinsics.o" \ - CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(JOHN_CFLAGS)" \ - LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl -faddress-sanitizer $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ + CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 $(CFLAG_SANITIZE_ADDRESS) -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(JOHN_CFLAGS)" \ + LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl $(CFLAG_SANITIZE_ADDRESS) $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" @echo "Failing after this point just means some helper tools did not build:" $(MAKE) $(PROJ_CXX) \ - CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(JOHN_CFLAGS)" \ - LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl -faddress-sanitizer $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ + CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 $(CFLAG_SANITIZE_ADDRESS) -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(JOHN_CFLAGS)" \ + LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl $(CFLAG_SANITIZE_ADDRESS) $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" $(MAKE) $(PROJ_PCAP) \ - CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(JOHN_CFLAGS)" \ - LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl -faddress-sanitizer $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ + CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 $(CFLAG_SANITIZE_ADDRESS) -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(JOHN_CFLAGS)" \ + LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl $(CFLAG_SANITIZE_ADDRESS) $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" @echo "All done" @@ -749,17 +763,17 @@ linux-x86-clang-debug: @echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h $(MAKE) $(PROJ) \ JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o sha1-mmx.o md4-mmx.o md5-mmx.o sse-intrinsics.o" \ - CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(OMPFLAGS) $(JOHN_CFLAGS)" \ - LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl -faddress-sanitizer $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ + CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 $(CFLAG_SANITIZE_ADDRESS) -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(OMPFLAGS) $(JOHN_CFLAGS)" \ + LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl $(CFLAG_SANITIZE_ADDRESS) $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" @echo "Failing after this point just means some helper tools did not build:" $(MAKE) $(PROJ_CXX) \ - CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(OMPFLAGS) $(JOHN_CFLAGS)" \ - LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl -faddress-sanitizer $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ + CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 $(CFLAG_SANITIZE_ADDRESS) -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(OMPFLAGS) $(JOHN_CFLAGS)" \ + LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl $(CFLAG_SANITIZE_ADDRESS) $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" $(MAKE) $(PROJ_PCAP) \ - CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(OMPFLAGS) $(JOHN_CFLAGS)" \ - LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl -faddress-sanitizer $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ + CFLAGS="-Wall -Wdeclaration-after-statement -c -g -O1 $(CFLAG_SANITIZE_ADDRESS) -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_DL $(HAVE_NSS) $(HAVE_GMP) $(HAVE_KRB5) $(OMPFLAGS) $(JOHN_CFLAGS)" \ + LDFLAGS="-L/usr/local/lib -L/usr/local/ssl/lib -lssl -lcrypto -lm -lz -lcrypt -ldl $(CFLAG_SANITIZE_ADDRESS) $(NSS_LDFLAGS) $(GMP_LDFLAGS) $(KRB5_LDFLAGS) $(JOHN_LDFLAGS)" \ CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" @echo "All done" -- 1.8.1.4