Bug 1403346 - Move RTL_FLAGS to computed flags.
MozReview-Commit-ID: 9tOuNXjyJQD
--- a/config/config.mk
+++ b/config/config.mk
@@ -307,18 +307,18 @@ endif # CLANG_CL
# Use warnings-as-errors if ALLOW_COMPILER_WARNINGS is not set to 1 (which
# includes the case where it's undefined).
ifneq (1,$(ALLOW_COMPILER_WARNINGS))
CXXFLAGS += $(WARNINGS_AS_ERRORS)
CFLAGS += $(WARNINGS_AS_ERRORS)
endif # ALLOW_COMPILER_WARNINGS
-COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES)
-COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS) $(_DEPEND_CFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(MK_COMPILE_DEFINES)
+COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(OS_COMPILE_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES)
+COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(OS_COMPILE_CXXFLAGS) $(_DEPEND_CFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS)
COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS)
ASFLAGS += $(MOZBUILD_ASFLAGS)
ifndef CROSS_COMPILE
HOST_CFLAGS += $(RTL_FLAGS)
endif
--- a/python/mozbuild/mozbuild/compilation/database.py
+++ b/python/mozbuild/mozbuild/compilation/database.py
@@ -71,18 +71,17 @@ class CompileDBBackend(CommonBackend):
elif isinstance(obj, (Sources, GeneratedSources)):
# For other sources, include each source file.
for f in obj.files:
self._build_db_line(obj.objdir, obj.relativedir, obj.config, f,
obj.canonical_suffix)
elif isinstance(obj, VariablePassthru):
for var in ('MOZBUILD_CFLAGS', 'MOZBUILD_CXXFLAGS',
- 'MOZBUILD_CMFLAGS', 'MOZBUILD_CMMFLAGS',
- 'RTL_FLAGS'):
+ 'MOZBUILD_CMFLAGS', 'MOZBUILD_CMMFLAGS'):
if var in obj.variables:
self._local_flags[obj.objdir][var] = obj.variables[var]
if (obj.variables.get('ALLOW_COMPILER_WARNINGS') and
'WARNINGS_AS_ERRORS' in self._local_flags[obj.objdir]):
del self._local_flags[obj.objdir]['WARNINGS_AS_ERRORS']
elif isinstance(obj, PerSourceFlag):
self._per_source_flags[obj.file_name].extend(obj.flags)
@@ -191,18 +190,16 @@ class CompileDBBackend(CommonBackend):
if not value:
return
if isinstance(value, types.StringTypes):
value = value.split()
db.extend(value)
db.append('$(COMPUTED_%s)' % self.CFLAGS[canonical_suffix])
- if canonical_suffix in ('.c', '.cpp'):
- db.append('$(RTL_FLAGS)')
append_var('OS_COMPILE_%s' % self.CFLAGS[canonical_suffix])
append_var('OS_CPPFLAGS')
append_var('OS_%s' % self.CFLAGS[canonical_suffix])
append_var('MOZ_DEBUG_FLAGS')
append_var('MOZ_OPTIMIZE_FLAGS')
append_var('MOZ_FRAMEPTR_FLAGS')
db.append('$(WARNINGS_AS_ERRORS)')
db.append('$(MOZBUILD_%s)' % self.CFLAGS[canonical_suffix])
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -318,16 +318,17 @@ class CompileFlags(ContextDerivedValue,
('OS_INCLUDES', list(itertools.chain(*(context.config.substs.get(v, []) for v in (
'NSPR_CFLAGS', 'NSS_CFLAGS', 'MOZ_JPEG_CFLAGS', 'MOZ_PNG_CFLAGS',
'MOZ_ZLIB_CFLAGS', 'MOZ_PIXMAN_CFLAGS')))),
('CXXFLAGS', 'CFLAGS')),
('DSO', context.config.substs.get('DSO_CFLAGS'),
('CXXFLAGS', 'CFLAGS')),
('DSO_PIC', context.config.substs.get('DSO_PIC_CFLAGS'),
('CXXFLAGS', 'CFLAGS')),
+ ('RTL', None, ('CXXFLAGS', 'CFLAGS')),
)
self._known_keys = set(k for k, v, _ in self.flag_variables)
# Providing defaults here doesn't play well with multiple templates
# modifying COMPILE_FLAGS from the same moz.build, because the merge
# done after the template runs can't tell which values coming from
# a template were set and which were provided as defaults.
template_name = getattr(context, 'template', None)
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -953,45 +953,46 @@ class TreeMetadataEmitter(LoggingMixin):
passthru.variables['MOZBUILD_' + v] = context[v]
dist_install = context['DIST_INSTALL']
if dist_install is True:
passthru.variables['DIST_INSTALL'] = True
elif dist_install is False:
passthru.variables['NO_DIST_INSTALL'] = True
+ computed_flags = ComputedFlags(context, context['COMPILE_FLAGS'])
+
# Ideally, this should be done in templates, but this is difficult at
# the moment because USE_STATIC_LIBS can be set after a template
# returns. Eventually, with context-based templates, it will be
# possible.
if (context.config.substs.get('OS_ARCH') == 'WINNT' and
not context.config.substs.get('GNU_CC')):
use_static_lib = (context.get('USE_STATIC_LIBS') and
not context.config.substs.get('MOZ_ASAN'))
rtl_flag = '-MT' if use_static_lib else '-MD'
if (context.config.substs.get('MOZ_DEBUG') and
not context.config.substs.get('MOZ_NO_DEBUG_RTL')):
rtl_flag += 'd'
# Use a list, like MOZBUILD_*FLAGS variables
passthru.variables['RTL_FLAGS'] = [rtl_flag]
+ computed_flags.resolve_flags('RTL', [rtl_flag])
generated_files = set()
for obj in self._process_generated_files(context):
for f in obj.outputs:
generated_files.add(f)
yield obj
for path in context['CONFIGURE_SUBST_FILES']:
sub = self._create_substitution(ConfigFileSubstitution, context,
path)
generated_files.add(str(sub.relpath))
yield sub
- computed_flags = ComputedFlags(context, context['COMPILE_FLAGS'])
-
for defines_var, cls in (('DEFINES', Defines),
('HOST_DEFINES', HostDefines)):
defines = context.get(defines_var)
if defines:
defines_obj = cls(context, defines)
yield defines_obj
else:
# If we don't have explicitly set defines we need to make sure