Bug 1515843 - Stop building host static libraries. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 21 Dec 2018 23:00:00 +0000
changeset 508883 ec095af21520b791fcfdef6c88a90b48abe32762
parent 508882 2fa138ebd75d453d2d9d2a3b36571c5da06f4929
child 508884 a415ca5d5ffd1c934f1d2d6585535b08d634d2fd
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1515843
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1515843 - Stop building host static libraries. r=ted The build system has skipped creating target static libraries for very long, except in very specific cases. We can actually do the same for host static libraries, for which we don't even need the escape hatch to still allow to create static libraries. Depends on D15171 Differential Revision: https://phabricator.services.mozilla.com/D15172
config/makefiles/debugmake.mk
config/rules.mk
python/mozbuild/mozbuild/backend/common.py
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/backend/tup.py
--- a/config/makefiles/debugmake.mk
+++ b/config/makefiles/debugmake.mk
@@ -33,17 +33,17 @@ define print_var
 
 endef
 
 define print_vars
 $(foreach var,$1,$(call print_var,$(var)))
 endef
 
 showtargs:
-ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
+ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
 	@echo --------------------------------------------------------------------------------
 	$(call print_vars,\
 		PROGRAM \
 		SIMPLE_PROGRAMS \
 		LIBRARY \
 		SHARED_LIBRARY \
 		LIBS \
 		DEF_FILE \
@@ -107,13 +107,12 @@ showhost:
 		HOST_CFLAGS \
 		HOST_LDFLAGS \
 		HOST_LIBS \
 		HOST_EXTRA_LIBS \
 		HOST_EXTRA_DEPS \
 		HOST_PROGRAM \
 		HOST_OBJS \
 		HOST_PROGOBJS \
-		HOST_LIBRARY \
 	)
 
 INCLUDED_DEBUGMAKE_MK = 1
 endif #}
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -102,22 +102,16 @@ ifndef LIBRARY
 ifdef REAL_LIBRARY
 ifdef NO_EXPAND_LIBS
 # Only build actual library if it is requested.
 LIBRARY			:= $(REAL_LIBRARY)
 endif
 endif
 endif
 
-ifndef HOST_LIBRARY
-ifdef HOST_LIBRARY_NAME
-HOST_LIBRARY		:= $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
-endif
-endif
-
 ifdef FORCE_SHARED_LIB
 ifdef MKSHLIB
 
 ifdef LIB_IS_C_ONLY
 MKSHLIB			= $(MKCSHLIB)
 endif
 
 EMBED_MANIFEST_AT=2
@@ -183,17 +177,17 @@ endif
 ifdef MOZ_PROFILE_GENERATE
 $(foreach category,$(INSTALL_TARGETS),\
   $(eval $(category)_FILES := $(foreach file,$($(category)_FILES),$(if $(filter $(SIMPLE_PROGRAMS),$(notdir $(file))),,$(file)))))
 SIMPLE_PROGRAMS :=
 endif
 
 ifdef COMPILE_ENVIRONMENT
 ifndef TARGETS
-TARGETS			= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_SHARED_LIBRARY)
+TARGETS			= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_SHARED_LIBRARY)
 endif
 
 ifdef MOZ_PROFILE_GENERATE
 CPPSRCS := $(CPPSRCS) $(PGO_GEN_ONLY_CPPSRCS)
 endif
 
 COBJS = $(notdir $(CSRCS:.c=.$(OBJ_SUFFIX)))
 SOBJS = $(notdir $(SSRCS:.S=.$(OBJ_SUFFIX)))
@@ -220,17 +214,16 @@ HOST_OBJS = $(strip $(_HOST_OBJS))
 endif
 else
 LIBRARY :=
 SHARED_LIBRARY :=
 IMPORT_LIBRARY :=
 REAL_LIBRARY :=
 PROGRAM :=
 SIMPLE_PROGRAMS :=
-HOST_LIBRARY :=
 HOST_SHARED_LIBRARY :=
 HOST_PROGRAM :=
 HOST_SIMPLE_PROGRAMS :=
 endif
 
 ALL_TRASH = \
 	$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
 	$(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
@@ -447,17 +440,17 @@ everything::
 GLOBAL_DEPS += Makefile $(addprefix $(DEPTH)/config/,$(INCLUDED_AUTOCONF_MK)) $(MOZILLA_DIR)/config/config.mk
 
 ##############################################
 ifdef COMPILE_ENVIRONMENT
 OBJ_TARGETS = $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS)
 
 compile:: host target
 
-host:: $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_RUST_PROGRAMS) $(HOST_RUST_LIBRARY_FILE) $(HOST_SHARED_LIBRARY)
+host:: $(HOST_OBJS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_RUST_PROGRAMS) $(HOST_RUST_LIBRARY_FILE) $(HOST_SHARED_LIBRARY)
 
 target:: $(filter-out $(MOZBUILD_NON_DEFAULT_TARGETS),$(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(RUST_LIBRARY_FILE) $(RUST_PROGRAMS))
 
 ifndef LIBRARY
 ifdef OBJS
 target:: $(OBJS)
 endif
 endif
@@ -593,36 +586,36 @@ ifdef ENABLE_STRIP
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
 endif
 
 $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS) $(call mkdir_deps,$(DEPTH)/dist/host/bin)
 	$(REPORT_BUILD)
 ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
-	$(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $($(notdir $@)_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 ifdef MSMANIFEST_TOOL
 	@if test -f $@.manifest; then \
 		if test -f '$(srcdir)/$(notdir $@).manifest'; then \
 			echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest and $@.manifest'; \
 			$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		else \
 			echo 'Embedding manifest from $@.manifest'; \
 			$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		fi; \
 	elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
 		echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
 		$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
 	fi
 endif	# MSVC with manifest tool
 else
 ifeq ($(HOST_CPP_PROG_LINK),1)
-	$(HOST_CXX) -o $@ $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_CXX) -o $@ $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 else
-	$(HOST_CC) -o $@ $(HOST_C_LDFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_CC) -o $@ $(HOST_C_LDFLAGS) $(HOST_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 endif # HOST_CPP_PROG_LINK
 endif
 ifndef CROSS_COMPILE
 	$(call py_action,check_binary,--host $@)
 endif
 
 #
 # This is an attempt to support generation of multiple binaries
@@ -651,25 +644,25 @@ endif # WINNT && !GNU_CC
 
 ifdef ENABLE_STRIP
 	$(STRIP) $(STRIP_FLAGS) $@
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
 endif
 
-$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(_OBJ_SUFFIX) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
+$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
 	$(REPORT_BUILD)
 ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
-	$(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $($(notdir $@)_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 else
 ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
-	$(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXX_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXX_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 else
-	$(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_C_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_C_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 endif
 endif
 ifndef CROSS_COMPILE
 	$(call py_action,check_binary,--host $@)
 endif
 
 $(LIBRARY): $(OBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
 	$(REPORT_BUILD)
@@ -682,28 +675,23 @@ ifeq ($(OS_ARCH),WINNT)
 # but make will happily consider the import library before it is refreshed
 # when rebuilding the corresponding shared library. Defining an empty recipe
 # for import libraries forces make to wait for the shared library recipe to
 # have run before considering other targets that depend on the import library.
 # See bug 795204.
 $(IMPORT_LIBRARY): $(SHARED_LIBRARY) ;
 endif
 
-$(HOST_LIBRARY): $(HOST_OBJS) Makefile
-	$(REPORT_BUILD)
-	$(RM) $@
-	$(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
-
-$(HOST_SHARED_LIBRARY): $(HOST_OBJS) Makefile
+$(HOST_SHARED_LIBRARY): Makefile
 	$(REPORT_BUILD)
 	$(RM) $@
 ifdef _MSC_VER
-	$(HOST_LINKER) -NOLOGO -DLL -OUT:$@ $(HOST_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_LINKER) -NOLOGO -DLL -OUT:$@ $($(notdir $@)_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 else
-	$(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+	$(HOST_CXX) $(HOST_OUTOPTION)$@ $($(notdir $@)_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
 endif
 
 # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
 # so instead of deleting .o files after repacking them into a dylib, we make
 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
 # so no need to conditionalize on OS version or debugging format.
 
 $(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(RUST_STATIC_LIB) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
--- a/python/mozbuild/mozbuild/backend/common.py
+++ b/python/mozbuild/mozbuild/backend/common.py
@@ -246,18 +246,18 @@ class CommonBackend(BuildBackend):
                 objs.append(o)
                 # This is slightly odd, but for consistency with the
                 # recursivemake backend we don't replace OBJ_SUFFIX if any
                 # object in a library has `no_pgo` set.
                 if lib.no_pgo_objs or lib.no_pgo:
                     no_pgo_objs.append(o)
 
         def expand(lib, recurse_objs, system_libs):
-            if isinstance(lib, StaticLibrary):
-                if lib.no_expand_lib:
+            if isinstance(lib, (HostLibrary, StaticLibrary)):
+                if not isinstance(lib, HostLibrary) and lib.no_expand_lib:
                     static_libs.append(lib)
                     recurse_objs = False
                 elif recurse_objs:
                     add_objs(lib)
 
                 for l in lib.linked_libraries:
                     expand(l, recurse_objs, system_libs)
 
@@ -269,39 +269,49 @@ class CommonBackend(BuildBackend):
 
             elif isinstance(lib, SharedLibrary):
                 if lib not in seen_libs:
                     seen_libs.add(lib)
                     shared_libs.append(lib)
 
         add_objs(input_bin)
 
-        system_libs = not isinstance(input_bin, StaticLibrary)
+        system_libs = not isinstance(input_bin, (HostLibrary, StaticLibrary))
         for lib in input_bin.linked_libraries:
             if isinstance(lib, RustLibrary):
                 continue
-            elif isinstance(lib, StaticLibrary):
+            elif isinstance(lib, (HostLibrary, StaticLibrary)):
                 expand(lib, True, system_libs)
             elif isinstance(lib, SharedLibrary):
                 if lib not in seen_libs:
                     seen_libs.add(lib)
                     shared_libs.append(lib)
 
         for lib in input_bin.linked_system_libs:
             if lib not in seen_libs:
                 seen_libs.add(lib)
                 os_libs.append(lib)
 
         return (objs, sorted(seen_pgo_gen_only_objs), no_pgo_objs, \
                 shared_libs, os_libs, static_libs)
 
-    def _make_list_file(self, objdir, objs, name):
+    def _make_list_file(self, kind, objdir, objs, name):
         if not objs:
             return None
-        list_style = self.environment.substs.get('EXPAND_LIBS_LIST_STYLE')
+        if kind == 'target':
+            list_style = self.environment.substs.get('EXPAND_LIBS_LIST_STYLE')
+        else:
+            # The host compiler is not necessarily the same kind as the target
+            # compiler, so we can't be sure EXPAND_LIBS_LIST_STYLE is the right
+            # style to use ; however, all compilers support the `list` type, so
+            # use that. That doesn't cause any practical problem because where
+            # it really matters to use something else than `list` is when
+            # linking tons of objects (because of command line argument limits),
+            # which only really happens for libxul.
+            list_style = 'list'
         list_file_path = mozpath.join(objdir, name)
         objs = [os.path.relpath(o, objdir) for o in objs]
         if list_style == 'linkerscript':
             ref = list_file_path
             content = '\n'.join('INPUT("%s")' % o for o in objs)
         elif list_style == 'filelist':
             ref = "-Wl,-filelist," + list_file_path
             content = '\n'.join(objs)
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -690,17 +690,16 @@ class RecursiveMakeBackend(CommonBackend
             self._process_linked_libraries(obj, backend_file)
             self._no_skip['syms'].add(backend_file.relobjdir)
 
         elif isinstance(obj, StaticLibrary):
             self._process_static_library(obj, backend_file)
             self._process_linked_libraries(obj, backend_file)
 
         elif isinstance(obj, HostLibrary):
-            self._process_host_library(obj, backend_file)
             self._process_linked_libraries(obj, backend_file)
 
         elif isinstance(obj, HostSharedLibrary):
             self._process_host_shared_library(obj, backend_file)
             self._process_linked_libraries(obj, backend_file)
 
         elif isinstance(obj, ObjdirFiles):
             self._process_objdir_files(obj, obj.files, backend_file)
@@ -1344,19 +1343,16 @@ class RecursiveMakeBackend(CommonBackend
         target_dir = mozpath.join(backend_file.objdir, libdef.target_dir)
         target_dir = mozpath.normpath(target_dir)
         backend_file.write('CARGO_TARGET_DIR := %s\n' % target_dir)
         if libdef.features:
             backend_file.write('%s := %s\n' % (libdef.FEATURES_VAR, ' '.join(libdef.features)))
         if libdef.output_category:
             self._process_non_default_target(libdef, libdef.import_name, backend_file)
 
-    def _process_host_library(self, libdef, backend_file):
-        backend_file.write('HOST_LIBRARY_NAME = %s\n' % libdef.basename)
-
     def _process_host_shared_library(self, libdef, backend_file):
         backend_file.write('HOST_SHARED_LIBRARY = %s\n' % libdef.lib_name)
 
     def _build_target_for_obj(self, obj):
         if hasattr(obj, 'output_category') and obj.output_category:
             target_name = obj.output_category
         else:
             target_name = obj.KIND
@@ -1370,82 +1366,83 @@ class RecursiveMakeBackend(CommonBackend
 
         topobjdir = mozpath.normsep(obj.topobjdir)
         # This will create the node even if there aren't any linked libraries.
         build_target = self._build_target_for_obj(obj)
         self._compile_graph[build_target]
 
         objs, pgo_gen_objs, no_pgo_objs, shared_libs, os_libs, static_libs = self._expand_libs(obj)
 
+        obj_target = obj.name
+        if isinstance(obj, Program):
+            obj_target = self._pretty_path(obj.output_path, backend_file)
+
+        profile_gen_objs = []
+
         if obj.KIND == 'target':
-            obj_target = obj.name
-            if isinstance(obj, Program):
-                obj_target = self._pretty_path(obj.output_path, backend_file)
-
             is_unit_test = isinstance(obj, BaseProgram) and obj.is_unit_test
-            profile_gen_objs = []
 
             doing_pgo = self.environment.substs.get('MOZ_PGO')
             obj_suffix_change_needed = (self.environment.substs.get('GNU_CC') or
                                         self.environment.substs.get('CLANG_CL'))
             if doing_pgo and obj_suffix_change_needed:
                 # We use a different OBJ_SUFFIX for the profile generate phase on
                 # systems where the pgo generate phase requires instrumentation
                 # that can only be removed by recompiling objects. These get
                 # picked up via OBJS_VAR_SUFFIX in config.mk.
                 if not is_unit_test and not isinstance(obj, SimpleProgram):
                     profile_gen_objs = [o if o in no_pgo_objs else '%s.%s' %
                                         (mozpath.splitext(o)[0], 'i_o') for o in objs]
                     profile_gen_objs += ['%s.%s' % (mozpath.splitext(o)[0], 'i_o')
                                          for o in pgo_gen_objs]
 
-            def write_obj_deps(target, objs_ref, pgo_objs_ref):
-                if pgo_objs_ref:
-                    backend_file.write('ifdef MOZ_PROFILE_GENERATE\n')
-                    backend_file.write('%s: %s\n' % (target, pgo_objs_ref))
-                    backend_file.write('else\n')
-                    backend_file.write('%s: %s\n' % (target, objs_ref))
-                    backend_file.write('endif\n')
-                else:
-                    backend_file.write('%s: %s\n' % (target, objs_ref))
+        def write_obj_deps(target, objs_ref, pgo_objs_ref):
+            if pgo_objs_ref:
+                backend_file.write('ifdef MOZ_PROFILE_GENERATE\n')
+                backend_file.write('%s: %s\n' % (target, pgo_objs_ref))
+                backend_file.write('else\n')
+                backend_file.write('%s: %s\n' % (target, objs_ref))
+                backend_file.write('endif\n')
+            else:
+                backend_file.write('%s: %s\n' % (target, objs_ref))
 
-            objs_ref = ' \\\n    '.join(os.path.relpath(o, obj.objdir)
-                                        for o in objs)
-            pgo_objs_ref = ' \\\n    '.join(os.path.relpath(o, obj.objdir)
-                                            for o in profile_gen_objs)
-            # Don't bother with a list file if we're only linking objects built
-            # in this directory or building a real static library. This
-            # accommodates clang-plugin, where we would otherwise pass an
-            # incorrect list file format to the host compiler as well as when
-            # creating an archive with AR, which doesn't understand list files.
-            if (objs == obj.objs and not isinstance(obj, StaticLibrary) or
-              isinstance(obj, StaticLibrary) and obj.no_expand_lib):
-                backend_file.write_once('%s_OBJS := %s\n' % (obj.name,
-                                                             objs_ref))
-                if profile_gen_objs:
-                    backend_file.write_once('%s_PGO_OBJS := %s\n' % (obj.name,
-                                                                     pgo_objs_ref))
-                write_obj_deps(obj_target, objs_ref, pgo_objs_ref)
-            elif not isinstance(obj, StaticLibrary):
-                list_file_path = '%s.list' % obj.name.replace('.', '_')
-                list_file_ref = self._make_list_file(obj.objdir, objs,
-                                                     list_file_path)
-                backend_file.write_once('%s_OBJS := %s\n' %
-                                        (obj.name, list_file_ref))
-                backend_file.write_once('%s: %s\n' % (obj_target, list_file_path))
-                if profile_gen_objs:
-                    pgo_list_file_path = '%s_pgo.list' % obj.name.replace('.', '_')
-                    pgo_list_file_ref = self._make_list_file(obj.objdir,
-                                                             profile_gen_objs,
-                                                             pgo_list_file_path)
-                    backend_file.write_once('%s_PGO_OBJS := %s\n' %
-                                            (obj.name, pgo_list_file_ref))
-                    backend_file.write_once('%s: %s\n' % (obj_target,
-                                                          pgo_list_file_path))
-                write_obj_deps(obj_target, objs_ref, pgo_objs_ref)
+        objs_ref = ' \\\n    '.join(os.path.relpath(o, obj.objdir)
+                                    for o in objs)
+        pgo_objs_ref = ' \\\n    '.join(os.path.relpath(o, obj.objdir)
+                                        for o in profile_gen_objs)
+        # Don't bother with a list file if we're only linking objects built
+        # in this directory or building a real static library. This
+        # accommodates clang-plugin, where we would otherwise pass an
+        # incorrect list file format to the host compiler as well as when
+        # creating an archive with AR, which doesn't understand list files.
+        if (objs == obj.objs and not isinstance(obj, (HostLibrary, StaticLibrary)) or
+          isinstance(obj, StaticLibrary) and obj.no_expand_lib):
+            backend_file.write_once('%s_OBJS := %s\n' % (obj.name,
+                                                         objs_ref))
+            if profile_gen_objs:
+                backend_file.write_once('%s_PGO_OBJS := %s\n' % (obj.name,
+                                                                 pgo_objs_ref))
+            write_obj_deps(obj_target, objs_ref, pgo_objs_ref)
+        elif not isinstance(obj, (HostLibrary, StaticLibrary)):
+            list_file_path = '%s.list' % obj.name.replace('.', '_')
+            list_file_ref = self._make_list_file(obj.KIND, obj.objdir, objs,
+                                                 list_file_path)
+            backend_file.write_once('%s_OBJS := %s\n' %
+                                    (obj.name, list_file_ref))
+            backend_file.write_once('%s: %s\n' % (obj_target, list_file_path))
+            if profile_gen_objs:
+                pgo_list_file_path = '%s_pgo.list' % obj.name.replace('.', '_')
+                pgo_list_file_ref = self._make_list_file(obj.KIND, obj.objdir,
+                                                         profile_gen_objs,
+                                                         pgo_list_file_path)
+                backend_file.write_once('%s_PGO_OBJS := %s\n' %
+                                        (obj.name, pgo_list_file_ref))
+                backend_file.write_once('%s: %s\n' % (obj_target,
+                                                      pgo_list_file_path))
+            write_obj_deps(obj_target, objs_ref, pgo_objs_ref)
 
         for lib in shared_libs:
             backend_file.write_once('SHARED_LIBS += %s\n' %
                                     pretty_relpath(lib, lib.import_name))
         for lib in static_libs:
             backend_file.write_once('STATIC_LIBS += %s\n' %
                                     pretty_relpath(lib, lib.import_name))
         for lib in os_libs:
@@ -1453,17 +1450,17 @@ class RecursiveMakeBackend(CommonBackend
                 backend_file.write_once('OS_LIBS += %s\n' % lib)
             else:
                 backend_file.write_once('HOST_EXTRA_LIBS += %s\n' % lib)
 
         for lib in obj.linked_libraries:
             if not isinstance(lib, ExternalLibrary):
                 self._compile_graph[build_target].add(
                     self._build_target_for_obj(lib))
-            if isinstance(lib, (HostLibrary, HostRustLibrary)):
+            if isinstance(lib, HostRustLibrary):
                 backend_file.write_once('HOST_LIBS += %s\n' %
                                         pretty_relpath(lib, lib.import_name))
 
         # We have to link any Rust libraries after all intermediate static
         # libraries have been listed to ensure that the Rust libraries are
         # searched after the C/C++ objects that might reference Rust symbols.
         if isinstance(obj, (SharedLibrary, Program)):
             self._process_rust_libraries(obj, backend_file, pretty_relpath)
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -410,17 +410,17 @@ class TupBackend(CommonBackend):
             ['-o', shlib.lib_name]
         )
 
         objs, _, _, shared_libs, os_libs, static_libs = self._expand_libs(shlib)
         static_libs = self._lib_paths(backend_file.objdir, static_libs)
         shared_libs = self._lib_paths(backend_file.objdir, shared_libs)
 
         list_file_name = '%s.list' % shlib.name.replace('.', '_')
-        list_file = self._make_list_file(backend_file.objdir, objs, list_file_name)
+        list_file = self._make_list_file(shlib.KIND, backend_file.objdir, objs, list_file_name)
 
         rust_linked = [l for l in backend_file.shared_lib.linked_libraries
                        if isinstance(l, RustLibrary)]
 
         inputs = objs + static_libs + shared_libs
 
         extra_inputs = []
         if rust_linked:
@@ -481,17 +481,17 @@ class TupBackend(CommonBackend):
 
         extra_inputs = []
         if rust_linked:
             extra_inputs = [self._rust_output_group(rust_linked[0].output_category) or
                             self._rust_libs]
             static_libs += self._lib_paths(backend_file.objdir, rust_linked)
 
         list_file_name = '%s.list' % prog.name.replace('.', '_')
-        list_file = self._make_list_file(backend_file.objdir, objs, list_file_name)
+        list_file = self._make_list_file(prog.KIND, backend_file.objdir, objs, list_file_name)
 
         if isinstance(prog, SimpleProgram):
             outputs = [prog.name]
         else:
             outputs = [mozpath.relpath(prog.output_path.full_path,
                                        backend_file.objdir)]
 
         cmd = (