From 8af3923815643057b16567ed11792a575d867b7a Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Mon, 7 Oct 2019 09:19:18 -0400 Subject: [PATCH 1/4] Add a recipe for libmbedcrypto with a path prefix This caused problems when running multiple jobs at once, since there was no target matching libmbedcrypto.so with the path prefix. It only worked if it was built first, since such file was found. Additionally, building of libmbedcrypto.so now waits for the static .a version. Previously, recipes for both libmbedcrypto.a and libmbedcrypto.so could run independently when running parallel jobs, which resulted in the .o files being built twice. It could sometimes be a problem, since linking would start when building one of the object files was still in progress (the previous one existed). This in turn resulted in reading (and trying to link) a malformed file. The "|" character is followed by "order-only-prerequisites", and in this case, makes linking of the shared version of the library wait for the .a file. Since it's guaranteed to be always built in the "all" target, it's fine to do that. All of the .o files are only built once thanks to this change. --- library/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Makefile b/library/Makefile index 501421fb6..64f69a2d9 100644 --- a/library/Makefile +++ b/library/Makefile @@ -157,6 +157,11 @@ libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll libmbedcrypto.%: $(MAKE) CRYPTO_INCLUDES:="-I../../include -I../include" -C ../crypto/library $@ +libmbedcrypto.$(DLEXT): $(CRYPTO)libmbedcrypto.$(DLEXT) + +$(CRYPTO)libmbedcrypto.$(DLEXT): | libmbedcrypto.a + $(MAKE) CRYPTO_INCLUDES:="-I../../include -I../include" -C ../crypto/library libmbedcrypto.$(DLEXT) + .c.o: echo " CC $<" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $< From df2cd9e14f5fb49078cfea0e62a9c000bf130a01 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Mon, 7 Oct 2019 09:24:22 -0400 Subject: [PATCH 2/4] Makefiles: move the dependencies block to be after DLEXT definition Having it before them resulted in incomplete dependency names, always ending with a period. --- programs/Makefile | 12 ++++++------ tests/Makefile | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index dce970b96..188c2beea 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -23,12 +23,6 @@ include ../crypto/3rdparty/Makefile.inc LOCAL_CFLAGS += $(patsubst -I../3rdparty/%, -I../crypto/3rdparty/%, $(THIRDPARTY_INCLUDES)) LOCAL_CFLAGS += $(patsubst -I../3rdparty/%, -I../crypto/3rdparty/%, $(THIRDPARTY_INCLUDES)) -ifndef SHARED -DEP=../crypto/library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a -else -DEP=../crypto/library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT) -endif - ifdef DEBUG LOCAL_CFLAGS += -g3 endif @@ -51,6 +45,12 @@ EXEXT= SHARED_SUFFIX= endif +ifndef SHARED +DEP=../crypto/library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a +else +DEP=../crypto/library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT) +endif + # Zlib shared library extensions: ifdef ZLIB LOCAL_LDFLAGS += -lz diff --git a/tests/Makefile b/tests/Makefile index 0bed6b191..9698b8016 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -25,12 +25,6 @@ LOCAL_CFLAGS += $(patsubst -I../3rdparty/%, -I../crypto/3rdparty/%, $(THIRDPARTY # on non-POSIX platforms. LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L -ifndef SHARED -DEP=$(CRYPTO)libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a -else -DEP=$(CRYPTO)libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT) -endif - ifdef DEBUG LOCAL_CFLAGS += -g3 endif @@ -56,6 +50,12 @@ SHARED_SUFFIX= PYTHON ?= python2 endif +ifndef SHARED +DEP=$(CRYPTO)libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a +else +DEP=$(CRYPTO)libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT) +endif + # Zlib shared library extensions: ifdef ZLIB LOCAL_LDFLAGS += -lz From 232e8f959a8e0dbd4d07f098412744ba4b05acdf Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Thu, 3 Oct 2019 03:18:01 -0400 Subject: [PATCH 3/4] Enable parallel shared target tests Now that the dependency issues for shared target are fixed, the feature can be enabled in tests. --- tests/scripts/all.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 7f7c4bdbd..fc8f5ece6 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1101,7 +1101,7 @@ component_test_platform_calloc_macro () { component_test_make_shared () { msg "build/test: make shared" # ~ 40s - make SHARED=1 all check -j1 + make SHARED=1 all check ldd programs/util/strerror | grep libmbedcrypto } @@ -1260,15 +1260,15 @@ component_test_allow_sha1 () { component_build_mingw () { msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s - make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs -j1 + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs # note Make tests only builds the tests, but doesn't run them - make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests -j1 + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests make WINDOWS_BUILD=1 clean msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s - make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs -j1 - make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests -j1 + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests make WINDOWS_BUILD=1 clean } support_build_mingw() { From 8028cb19f4d4a9911c6f232cf1ed6ac813feff8d Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Tue, 8 Oct 2019 10:10:43 -0400 Subject: [PATCH 4/4] Makefile: add path prefixes to other versions of libmbedcrypto library --- library/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Makefile b/library/Makefile index 64f69a2d9..bc9363db2 100644 --- a/library/Makefile +++ b/library/Makefile @@ -146,11 +146,11 @@ libmbedx509.so: libmbedx509.$(SOEXT_X509) echo " LN $@ -> $<" ln -sf $< $@ -libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib +libmbedx509.dylib: $(OBJS_X509) $(CRYPTO)libmbedcrypto.dylib echo " LD $@" $(CC) -dynamiclib -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509) -libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll +libmbedx509.dll: $(OBJS_X509) $(CRYPTO)libmbedcrypto.dll echo " LD $@" $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)