Compile OpenSSL differently for each config.
MSAN, TSAN, ASAN need to see all the code. Valgrind, MSAN want -DPURIFY.
diff --git a/Makefile b/Makefile
index 388e5f3..95780f8 100644
--- a/Makefile
+++ b/Makefile
@@ -22,12 +22,23 @@
LDFLAGS_dbg =
DEFINES_dbg = _DEBUG DEBUG
+VALID_CONFIG_valgrind = 1
+CC_valgrind = gcc
+CXX_valgrind = g++
+LD_valgrind = gcc
+LDXX_valgrind = g++
+CPPFLAGS_valgrind = -O0
+OPENSSL_CFLAGS_valgrind = -DPURIFY
+LDFLAGS_valgrind =
+DEFINES_valgrind = _DEBUG DEBUG
+
VALID_CONFIG_tsan = 1
CC_tsan = clang
CXX_tsan = clang++
LD_tsan = clang
LDXX_tsan = clang++
CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer
+OPENSSL_CONFIG_tsan = no-asm
LDFLAGS_tsan = -fsanitize=thread
DEFINES_tsan = NDEBUG
@@ -37,6 +48,7 @@
LD_asan = clang
LDXX_asan = clang++
CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer
+OPENSSL_CONFIG_asan = no-asm
LDFLAGS_asan = -fsanitize=address
DEFINES_asan = NDEBUG
@@ -46,6 +58,8 @@
LD_msan = clang
LDXX_msan = clang++
CPPFLAGS_msan = -O1 -fsanitize=memory -fno-omit-frame-pointer
+OPENSSL_CFLAGS_msan = -DPURIFY
+OPENSSL_CONFIG_msan = no-asm
LDFLAGS_msan = -fsanitize=memory
DEFINES_msan = NDEBUG
@@ -182,10 +196,10 @@
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false)
ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
-OPENSSL_DEP = third_party/openssl/libssl.a
-OPENSSL_MERGE_LIBS += third_party/openssl/libssl.a third_party/openssl/libcrypto.a
+OPENSSL_DEP = libs/$(CONFIG)/openssl/libssl.a
+OPENSSL_MERGE_LIBS += libs/$(CONFIG)/openssl/libssl.a libs/$(CONFIG)/openssl/libcrypto.a
CPPFLAGS += -Ithird_party/openssl/include
-LDFLAGS += -Lthird_party/openssl
+LDFLAGS += -Llibs/$(CONFIG)/openssl
LIBS_SECURE = dl
else
NO_SECURE = true
@@ -477,9 +491,12 @@
(cd third_party/zlib ; CFLAGS="-fPIC -fvisibility=hidden" ./configure --static)
$(MAKE) -C third_party/zlib
-third_party/openssl/libssl.a:
- (cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden" ./config)
+libs/$(CONFIG)/openssl/libssl.a:
+ (cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config $(OPENSSL_CONFIG_$(CONFIG)))
+ $(MAKE) -C third_party/openssl clean
$(MAKE) -C third_party/openssl build_crypto build_ssl
+ mkdir -p libs/$(CONFIG)/openssl
+ cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a libs/$(CONFIG)/openssl
static: static_c static_cxx
diff --git a/templates/Makefile.template b/templates/Makefile.template
index 256380c..ef76f5c 100644
--- a/templates/Makefile.template
+++ b/templates/Makefile.template
@@ -39,12 +39,23 @@
LDFLAGS_dbg =
DEFINES_dbg = _DEBUG DEBUG
+VALID_CONFIG_valgrind = 1
+CC_valgrind = gcc
+CXX_valgrind = g++
+LD_valgrind = gcc
+LDXX_valgrind = g++
+CPPFLAGS_valgrind = -O0
+OPENSSL_CFLAGS_valgrind = -DPURIFY
+LDFLAGS_valgrind =
+DEFINES_valgrind = _DEBUG DEBUG
+
VALID_CONFIG_tsan = 1
CC_tsan = clang
CXX_tsan = clang++
LD_tsan = clang
LDXX_tsan = clang++
CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer
+OPENSSL_CONFIG_tsan = no-asm
LDFLAGS_tsan = -fsanitize=thread
DEFINES_tsan = NDEBUG
@@ -54,6 +65,7 @@
LD_asan = clang
LDXX_asan = clang++
CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer
+OPENSSL_CONFIG_asan = no-asm
LDFLAGS_asan = -fsanitize=address
DEFINES_asan = NDEBUG
@@ -63,6 +75,8 @@
LD_msan = clang
LDXX_msan = clang++
CPPFLAGS_msan = -O1 -fsanitize=memory -fno-omit-frame-pointer
+OPENSSL_CFLAGS_msan = -DPURIFY
+OPENSSL_CONFIG_msan = no-asm
LDFLAGS_msan = -fsanitize=memory
DEFINES_msan = NDEBUG
@@ -199,10 +213,10 @@
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false)
ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
-OPENSSL_DEP = third_party/openssl/libssl.a
-OPENSSL_MERGE_LIBS += third_party/openssl/libssl.a third_party/openssl/libcrypto.a
+OPENSSL_DEP = libs/$(CONFIG)/openssl/libssl.a
+OPENSSL_MERGE_LIBS += libs/$(CONFIG)/openssl/libssl.a libs/$(CONFIG)/openssl/libcrypto.a
CPPFLAGS += -Ithird_party/openssl/include
-LDFLAGS += -Lthird_party/openssl
+LDFLAGS += -Llibs/$(CONFIG)/openssl
LIBS_SECURE = dl
else
NO_SECURE = true
@@ -294,9 +308,12 @@
(cd third_party/zlib ; CFLAGS="-fPIC -fvisibility=hidden" ./configure --static)
$(MAKE) -C third_party/zlib
-third_party/openssl/libssl.a:
- (cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden" ./config)
+libs/$(CONFIG)/openssl/libssl.a:
+ (cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config $(OPENSSL_CONFIG_$(CONFIG)))
+ $(MAKE) -C third_party/openssl clean
$(MAKE) -C third_party/openssl build_crypto build_ssl
+ mkdir -p libs/$(CONFIG)/openssl
+ cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a libs/$(CONFIG)/openssl
static: static_c static_cxx
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 0536ed6..7737b94 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -40,7 +40,7 @@
'msan': SimpleConfig('msan'),
'asan': SimpleConfig('asan'),
'gcov': SimpleConfig('gcov'),
- 'memcheck': ValgrindConfig('dbg', 'memcheck'),
+ 'memcheck': ValgrindConfig('valgrind', 'memcheck'),
'helgrind': ValgrindConfig('dbg', 'helgrind')
}