From ea9bf78defa950cea1ed95baad8931cf4e662c30 Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Tue, 5 May 2020 12:29:29 +0000 Subject: [PATCH] Bug 290526 Fix gtests build for WIN% targets r=rrelyea The google_test gtest build doesn't provide any exports for the shared library on Windows and the gyp build also builds just a static library. So build gtest and gtestutil libraries as static. For whatever reason, the Windows linker doesn't find the main function inside the gtestutil library, if we don't tell it to build a console executable. But linking works fine, if the object file is used directly. But since we can have different main() objects based on build flags, we enforce building console applications binaries. Differential Revision: https://phabricator.services.mozilla.com/D70665 --HG-- extra : moz-landing-system : lando --- coreconf/WIN32.mk | 2 ++ gtests/certdb_gtest/manifest.mn | 2 +- gtests/common/Makefile | 3 +++ gtests/google_test/Makefile | 3 ++- gtests/google_test/manifest.mn | 2 +- gtests/pkcs11testmodule/Makefile | 2 ++ 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/coreconf/WIN32.mk b/coreconf/WIN32.mk index d5573abf4b..0ef16895cd 100644 --- a/coreconf/WIN32.mk +++ b/coreconf/WIN32.mk @@ -187,6 +187,8 @@ endif endif # Purify requires /FIXED:NO when linking EXEs. LDFLAGS += /FIXED:NO + # So the linker will find main in the gtestutil library + LDFLAGS += -SUBSYSTEM:CONSOLE endif ifneq ($(_MSC_VER),$(_MSC_VER_6)) # NSS has too many of these to fix, downgrade the warning diff --git a/gtests/certdb_gtest/manifest.mn b/gtests/certdb_gtest/manifest.mn index c95cf991f3..2edcf92615 100644 --- a/gtests/certdb_gtest/manifest.mn +++ b/gtests/certdb_gtest/manifest.mn @@ -21,4 +21,4 @@ REQUIRES = nspr nss libdbm gtest PROGRAM = certdb_gtest EXTRA_LIBS = $(DIST)/lib/$(LIB_PREFIX)gtest.$(LIB_SUFFIX) $(EXTRA_OBJS) \ - ../common/$(OBJDIR)/gtests$(OBJ_SUFFIX) + $(DIST)/lib/$(LIB_PREFIX)gtestutil.$(LIB_SUFFIX) diff --git a/gtests/common/Makefile b/gtests/common/Makefile index e17bc282c4..1476e45df0 100644 --- a/gtests/common/Makefile +++ b/gtests/common/Makefile @@ -20,6 +20,9 @@ include $(CORE_DEPTH)/coreconf/config.mk # (3) Include "component" configuration information. (OPTIONAL) # ####################################################################### +SHARED_LIBRARY = $(NULL) +IMPORT_LIBRARY = $(NULL) + ####################################################################### # (4) Include "local" platform-dependent assignments (OPTIONAL). # ####################################################################### diff --git a/gtests/google_test/Makefile b/gtests/google_test/Makefile index 21fef55ac2..f801ba1d45 100644 --- a/gtests/google_test/Makefile +++ b/gtests/google_test/Makefile @@ -20,7 +20,8 @@ include $(CORE_DEPTH)/coreconf/config.mk # (3) Include "component" configuration information. (OPTIONAL) # ####################################################################### - +SHARED_LIBRARY = $(NULL) +IMPORT_LIBRARY = $(NULL) ####################################################################### # (4) Include "local" platform-dependent assignments (OPTIONAL). # diff --git a/gtests/google_test/manifest.mn b/gtests/google_test/manifest.mn index 565d79c09f..2858dc72d3 100644 --- a/gtests/google_test/manifest.mn +++ b/gtests/google_test/manifest.mn @@ -6,8 +6,8 @@ CORE_DEPTH = ../.. DEPTH = ../.. MODULE = gtest + LIBRARY_NAME = gtest -LIBRARY_VERSION = 1 INCLUDES += -Igtest/include/ -Igtest diff --git a/gtests/pkcs11testmodule/Makefile b/gtests/pkcs11testmodule/Makefile index ca3ffb0af3..a052055f3a 100644 --- a/gtests/pkcs11testmodule/Makefile +++ b/gtests/pkcs11testmodule/Makefile @@ -20,6 +20,8 @@ include $(CORE_DEPTH)/coreconf/config.mk # (3) Include "component" configuration information. (OPTIONAL) # ####################################################################### +LIBRARY = $(NULL) +IMPORT_LIBRARY = $(NULL) ####################################################################### # (4) Include "local" platform-dependent assignments (OPTIONAL). #