From c150b738a2b3f1e10e526c3d8ad3a68b1fa97a8f Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 17 Aug 2017 16:21:23 -0400 Subject: [PATCH] Bug 1378830 - part 1 - define PROG_IS_C_ONLY variables for PROGRAM and SIMPLE_PROGRAMS; r=chmanchester Similar to the existing LIB_IS_C_ONLY variable, these variables indicate that the program in question has only C sources and so can be linked by the C compiler rather than the C++ compiler. We need to add a little more information to BaseProgram so we can avoid emitting periods into Makefile variables. --- config/rules.mk | 8 ++++++-- python/mozbuild/mozbuild/backend/configenvironment.py | 1 + python/mozbuild/mozbuild/backend/recursivemake.py | 11 ++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 9897c203feb4..1b4a378720d8 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -566,6 +566,10 @@ alltags: $(RM) TAGS find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM) +define EXPAND_CC_OR_CXX +$(if $(PROG_IS_C_ONLY_$(1)),$(EXPAND_CC),$(EXPAND_CCC)) +endef + # # PROGRAM = Foo # creates OBJS, links with LIBS to create Foo @@ -595,7 +599,7 @@ ifdef MOZ_PROFILE_GENERATE touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink endif else # !WINNT || GNU_CC - $(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) + $(call EXPAND_CC_OR_CXX,$@) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(call CHECK_BINARY,$@) endif # WINNT && !GNU_CC @@ -654,7 +658,7 @@ ifdef MSMANIFEST_TOOL fi endif # MSVC with manifest tool else - $(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) + $(call EXPAND_CC_OR_CXX,$@) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(call CHECK_BINARY,$@) endif # WINNT && !GNU_CC diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py index bdca3212d137..811e787d5d55 100644 --- a/python/mozbuild/mozbuild/backend/configenvironment.py +++ b/python/mozbuild/mozbuild/backend/configenvironment.py @@ -141,6 +141,7 @@ class ConfigEnvironment(object): else: self.import_prefix = self.dll_prefix self.import_suffix = self.dll_suffix + self.bin_suffix = self.substs.get('BIN_SUFFIX', '') global_defines = [name for name in self.defines if not name in self.non_global_defines] diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 8e6377661c73..f814036639bd 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -571,7 +571,7 @@ class RecursiveMakeBackend(CommonBackend): self._compile_graph[build_target] elif isinstance(obj, Program): - self._process_program(obj.program, backend_file) + self._process_program(obj, backend_file) self._process_linked_libraries(obj, backend_file) self._no_skip['syms'].add(backend_file.relobjdir) @@ -1093,8 +1093,10 @@ class RecursiveMakeBackend(CommonBackend): registered_xpt_files=' '.join(sorted(registered_xpt_files)), )) - def _process_program(self, program, backend_file): - backend_file.write('PROGRAM = %s\n' % program) + def _process_program(self, obj, backend_file): + backend_file.write('PROGRAM = %s\n' % obj.program) + if not obj.cxx_link and not self.environment.bin_suffix: + backend_file.write('PROG_IS_C_ONLY_%s := 1\n' % obj.program) def _process_host_program(self, program, backend_file): backend_file.write('HOST_PROGRAM = %s\n' % program) @@ -1120,8 +1122,11 @@ class RecursiveMakeBackend(CommonBackend): def _process_simple_program(self, obj, backend_file): if obj.is_unit_test: backend_file.write('CPP_UNIT_TESTS += %s\n' % obj.program) + assert obj.cxx_link else: backend_file.write('SIMPLE_PROGRAMS += %s\n' % obj.program) + if not obj.cxx_link and not self.environment.bin_suffix: + backend_file.write('PROG_IS_C_ONLY_%s := 1\n' % obj.program) def _process_host_simple_program(self, program, backend_file): backend_file.write('HOST_SIMPLE_PROGRAMS += %s\n' % program)