Skip to content

Instantly share code, notes, and snippets.

@dgryski
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgryski/28d40d8b52aff29a4533 to your computer and use it in GitHub Desktop.
Save dgryski/28d40d8b52aff29a4533 to your computer and use it in GitHub Desktop.
keyless Makefile sanitize-thread
diff --git a/Makefile b/Makefile
index faf89aa..d64a93e 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,8 @@
NAME := keyless
+CC=clang
+
# This Makefile makes use of the GNU Make Standard Library project
# which can be found at http://gmsl.sf.net/
@@ -41,7 +43,7 @@ OPENSSL_LOG := $(TMP)openssl.log
# Turn on absolutely all warnings and turn them into errors
-CFLAGS += -g -Wall -Wextra -Wno-unused-parameter -Werror
+CFLAGS += -g -Wall -Wextra -Wno-unused-parameter -Werror -fsanitize=thread -fPIC
CFLAGS += -I. -I$(LIBUV_INCLUDE) -I$(OPENSSL_INCLUDE)
CFLAGS += -DKSSL_VERSION=\"$(VERSION)-$(REVISION)\"
@@ -50,7 +52,7 @@ CFLAGS += -DKSSL_VERSION=\"$(VERSION)-$(REVISION)\"
#
# Note that -ldl must appear after OPENSSL_A otherwise the link will fail
-LDLIBS += -L. $(OPENSSL_A) $(LIBUV_A) -ldl -lpthread
+LDLIBS += -L. $(OPENSSL_A) $(LIBUV_A) -ldl -lpthread -fsanitize=thread -pie
ifeq ($(OS),Linux)
LDLIBS += -lrt
@@ -80,7 +82,7 @@ LIBUV_DIR := $(call marker,$(LIBUV_ROOT)/)
.PHONY: libuv
libuv: $(LIBUV_A)
$(LIBUV_A): $(call marker,$(TMP)) $(LIBUV_DIR)
- @cd $(LIBUV_ROOT) && ./autogen.sh && ./configure --enable-static && make
+ @cd $(LIBUV_ROOT) && ./autogen.sh && ./configure --enable-static && make CFLAGS+="-fPIC" CC=clang
$(LIBUV_DIR): $(call marker,$(TMP))
@rm -rf $(LIBUV_ROOT)
@@ -100,7 +102,7 @@ endif
openssl: $(firstword $(OPENSSL_A))
$(firstword $(OPENSSL_A)): $(OPENSSL_DIR)
- @cd $(OPENSSL_ROOT) && ./$(OPENSSL_CONFIG) no-shared && make
+ @cd $(OPENSSL_ROOT) && ./$(OPENSSL_CONFIG) -fPIC && make CC=clang
$(OPENSSL_DIR): $(call marker,$(TMP))
@rm -rf $(OPENSSL_ROOT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment