Skip to content

Commit

Permalink
Bug 290526 Fix gtests build for WIN% targets r=rrelyea
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jmglogow committed May 5, 2020
1 parent b4ab574 commit ea9bf78
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions coreconf/WIN32.mk
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gtests/certdb_gtest/manifest.mn
Expand Up @@ -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)
3 changes: 3 additions & 0 deletions gtests/common/Makefile
Expand Up @@ -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). #
#######################################################################
Expand Down
3 changes: 2 additions & 1 deletion gtests/google_test/Makefile
Expand Up @@ -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). #
Expand Down
2 changes: 1 addition & 1 deletion gtests/google_test/manifest.mn
Expand Up @@ -6,8 +6,8 @@ CORE_DEPTH = ../..
DEPTH = ../..

MODULE = gtest

LIBRARY_NAME = gtest
LIBRARY_VERSION = 1

INCLUDES += -Igtest/include/ -Igtest

Expand Down
2 changes: 2 additions & 0 deletions gtests/pkcs11testmodule/Makefile
Expand Up @@ -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). #
Expand Down

0 comments on commit ea9bf78

Please sign in to comment.