From 7f3ef2780c1825fbc2270f49c6834502cc8c26e1 Mon Sep 17 00:00:00 2001 From: TabascoEye Date: Fri, 27 Apr 2018 13:14:59 +0200 Subject: [PATCH 1/9] silence "no symbols" warnings on apple clang fixes #1252 --- library/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 6177ca2b4..cd1857c3d 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -96,6 +96,13 @@ if(WIN32) set(libs ${libs} ws2_32) endif(WIN32) +if(APPLE) + SET(CMAKE_C_ARCHIVE_CREATE " Scr ") + SET(CMAKE_CXX_ARCHIVE_CREATE " Scr ") + SET(CMAKE_C_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") + SET(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") +endif(APPLE) + if(USE_PKCS11_HELPER_LIBRARY) set(libs ${libs} pkcs11-helper) endif(USE_PKCS11_HELPER_LIBRARY) From 0e98e88a223214952e7e75e2a1a38a875fbc13ed Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Wed, 23 May 2018 09:19:54 +0100 Subject: [PATCH 2/9] Silence no symbols warn on apple & Makefile --- library/Makefile | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/library/Makefile b/library/Makefile index b155c720e..60e9cbcc4 100644 --- a/library/Makefile +++ b/library/Makefile @@ -35,16 +35,26 @@ SOEXT_TLS=so.10 SOEXT_X509=so.0 SOEXT_CRYPTO=so.2 -# Set DLEXT=dylib to compile as a shared library for Mac OS X DLEXT ?= so # Set AR_DASH= (empty string) to use an ar implentation that does not accept # the - prefix for command line options (e.g. llvm-ar) AR_DASH ?= - -# Windows shared library extension: +ifdef APPLE_BUILD +ARFLAGS = $(AR_DASH)Src +RLFLAGS = -no_warning_for_no_symbols -c +RL ?= ranlib +else +ARFLAGS = $(AR_DASH)src +endif + ifdef WINDOWS_BUILD -DLEXT=dll +# Windows shared library extension: +DLEXT = dll +else ifdef APPLE_BUILD +# Mac OS X shared library extension: +DLEXT = dylib endif OBJS_CRYPTO= aes.o aesni.o arc4.o \ @@ -95,9 +105,11 @@ shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT) # tls libmbedtls.a: $(OBJS_TLS) echo " AR $@" - $(AR) $(AR_DASH)rc $@ $(OBJS_TLS) + $(AR) $(ARFLAGS) $@ $(OBJS_TLS) +ifdef APPLE_BUILD echo " RL $@" - $(AR) $(AR_DASH)s $@ + $(RL) $(RLFLAGS) $@ +endif libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so echo " LD $@" @@ -118,9 +130,11 @@ libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll # x509 libmbedx509.a: $(OBJS_X509) echo " AR $@" - $(AR) $(AR_DASH)rc $@ $(OBJS_X509) + $(AR) $(ARFLAGS) $@ $(OBJS_X509) +ifdef APPLE_BUILD echo " RL $@" - $(AR) $(AR_DASH)s $@ + $(RL) $(RLFLAGS) $@ +endif libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so echo " LD $@" @@ -141,9 +155,11 @@ libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll # crypto libmbedcrypto.a: $(OBJS_CRYPTO) echo " AR $@" - $(AR) $(AR_DASH)rc $@ $(OBJS_CRYPTO) + $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO) +ifdef APPLE_BUILD echo " RL $@" - $(AR) $(AR_DASH)s $@ + $(RL) $(RLFLAGS) $@ +endif libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) echo " LD $@" From 8c754218c5d97aa55ee534063767279a2354732c Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Wed, 23 May 2018 09:26:08 +0100 Subject: [PATCH 3/9] Add no symbols warning fix to ChangeLog --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 348864c0e..d86f1e8c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,10 @@ API Changes Therefore, mbedtls_platform_zeroize() is moved to the platform module to facilitate testing and maintenance. +Bugfix + * Fix "no symbols" warning issued by ranlib when building on Mac OS X. Fix + contributed by tabascoeye in pull request #1600. + = mbed TLS 2.9.0 branch released 2018-04-30 Security From c06c9ae0885d170b416b860e4a2371a867dcb6d2 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Tue, 12 Jun 2018 18:29:28 +0100 Subject: [PATCH 4/9] Add alias APPLE make var of APPLE_BUILD --- library/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Makefile b/library/Makefile index 60e9cbcc4..9affde417 100644 --- a/library/Makefile +++ b/library/Makefile @@ -21,6 +21,8 @@ endif # if were running on Windows build for Windows ifdef WINDOWS WINDOWS_BUILD=1 +else ifdef APPLE +APPLE_BUILD=1 endif # To compile as a shared library: From c471cd7e0a68de83f4132fb48e9497f96ff8d43a Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Wed, 13 Jun 2018 09:28:04 +0100 Subject: [PATCH 5/9] Autodetect if running on OS X in makefile --- library/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Makefile b/library/Makefile index 9affde417..89bc84f11 100644 --- a/library/Makefile +++ b/library/Makefile @@ -21,7 +21,7 @@ endif # if were running on Windows build for Windows ifdef WINDOWS WINDOWS_BUILD=1 -else ifdef APPLE +else ifeq ($(shell uname -s),Darwin) APPLE_BUILD=1 endif From 1d9375919a5d78d07611379784f9a9edbeb918fa Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Wed, 13 Jun 2018 10:04:58 +0100 Subject: [PATCH 6/9] Conditionally assign APPLE_BUILD var in makefile --- library/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Makefile b/library/Makefile index 89bc84f11..b1ef8d3f6 100644 --- a/library/Makefile +++ b/library/Makefile @@ -22,7 +22,7 @@ endif ifdef WINDOWS WINDOWS_BUILD=1 else ifeq ($(shell uname -s),Darwin) -APPLE_BUILD=1 +APPLE_BUILD ?= 1 endif # To compile as a shared library: From c51d613eac600a9c80d2a97aaf6ccf651f8c820e Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Tue, 19 Jun 2018 17:25:34 +0100 Subject: [PATCH 7/9] Ensure crosscompiling with make works in Mac OS X --- library/Makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/library/Makefile b/library/Makefile index b1ef8d3f6..857e977e9 100644 --- a/library/Makefile +++ b/library/Makefile @@ -37,27 +37,29 @@ SOEXT_TLS=so.10 SOEXT_X509=so.0 SOEXT_CRYPTO=so.2 -DLEXT ?= so - # Set AR_DASH= (empty string) to use an ar implentation that does not accept # the - prefix for command line options (e.g. llvm-ar) AR_DASH ?= - +ARFLAGS = $(AR_DASH)src ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) ARFLAGS = $(AR_DASH)Src RLFLAGS = -no_warning_for_no_symbols -c RL ?= ranlib -else -ARFLAGS = $(AR_DASH)src +endif endif +DLEXT ?= so ifdef WINDOWS_BUILD # Windows shared library extension: DLEXT = dll else ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) # Mac OS X shared library extension: DLEXT = dylib endif +endif OBJS_CRYPTO= aes.o aesni.o arc4.o \ asn1parse.o asn1write.o base64.o \ @@ -109,9 +111,11 @@ libmbedtls.a: $(OBJS_TLS) echo " AR $@" $(AR) $(ARFLAGS) $@ $(OBJS_TLS) ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) echo " RL $@" $(RL) $(RLFLAGS) $@ endif +endif libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so echo " LD $@" @@ -134,9 +138,11 @@ libmbedx509.a: $(OBJS_X509) echo " AR $@" $(AR) $(ARFLAGS) $@ $(OBJS_X509) ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) echo " RL $@" $(RL) $(RLFLAGS) $@ endif +endif libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so echo " LD $@" @@ -159,9 +165,11 @@ libmbedcrypto.a: $(OBJS_CRYPTO) echo " AR $@" $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO) ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) echo " RL $@" $(RL) $(RLFLAGS) $@ endif +endif libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) echo " LD $@" From e3402ce44f6286fc07962740b061962d270ed554 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Wed, 20 Jun 2018 10:43:21 +0100 Subject: [PATCH 8/9] Enable APPLE_BUILD in makefile if using system ar --- library/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Makefile b/library/Makefile index 857e977e9..353bd8bec 100644 --- a/library/Makefile +++ b/library/Makefile @@ -22,8 +22,10 @@ endif ifdef WINDOWS WINDOWS_BUILD=1 else ifeq ($(shell uname -s),Darwin) +ifeq ($(AR),ar) APPLE_BUILD ?= 1 endif +endif # To compile as a shared library: ifdef SHARED From bf7fe4f3f00ed905cbeb207f171735621d1e0a40 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Thu, 21 Jun 2018 20:21:38 +0100 Subject: [PATCH 9/9] Replace check with APPLE with CMAKE_SYSTEM_NAME --- library/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index cd1857c3d..063a269c4 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -96,12 +96,12 @@ if(WIN32) set(libs ${libs} ws2_32) endif(WIN32) -if(APPLE) +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") SET(CMAKE_C_ARCHIVE_CREATE " Scr ") SET(CMAKE_CXX_ARCHIVE_CREATE " Scr ") SET(CMAKE_C_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") SET(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") -endif(APPLE) +endif() if(USE_PKCS11_HELPER_LIBRARY) set(libs ${libs} pkcs11-helper)