Commit 29682b84 authored by Scott Graham's avatar Scott Graham

gn: various gyp flag matching for 'base'

- Don't remove -fno-ident from gyp build (was added about 3y ago, seemingly unnecessary for current clang)
- Add -fno-slp-vectorize to GN to make builds match (both to be removed after next clang roll)
- Make usage of -Wno-reserved-user-defined-literal match (required for dbus pre-trusty)
- Add -march=x86-64 to gn cflags
- Default symbol_level based on is_debug, and turn it off by default in Release (same as gyp)

Also, fiddle with output of gyp_flag_compare.py.

R=brettw@chromium.org
BUG=335824

Review URL: https://codereview.chromium.org/562383002

Cr-Commit-Position: refs/heads/master@{#294489}
parent 8a450db4
......@@ -3654,9 +3654,6 @@
],
}],
['clang==1', {
'cflags!': [
'-fno-ident',
],
# TODO(thakis): Remove once http://llvm.org/PR20354 is fixed
# and the fix is in chromium.
'cflags': [ '-fno-slp-vectorize', ],
......
......@@ -22,7 +22,8 @@ declare_args() {
# 2 means regular build with symbols.
# 1 means minimal symbols, usually enough for backtraces only.
# 0 means no symbols.
symbol_level = 2
# -1 means auto-set (off in release, regular in debug).
symbol_level = -1
# Component build.
is_component_build = false
......@@ -354,6 +355,17 @@ if (is_debug) {
}
_native_compiler_configs += [ _default_optimization_config ]
# If it wasn't manually set, set to an appropriate default.
if (symbol_level == -1) {
# Linux is slowed by having symbols as part of the target binary, whereas
# Mac and Windows have them separate, so in Release Linux, default them off.
if (is_debug || !is_linux) {
symbol_level = 2
} else {
symbol_level = 0
}
}
# Symbol setup.
if (symbol_level == 2) {
_default_symbols_config = "//build/config/compiler:symbols"
......
......@@ -103,6 +103,14 @@ config("compiler") {
}
}
if (is_clang) {
cflags += [
# TODO(thakis): Remove once http://llvm.org/PR20354 is fixed
# and the fix is in chromium.
"-fno-slp-vectorize",
]
}
if (is_clang && !is_win) {
# This is here so that all files get recompiled after a clang roll and
# when turning clang on or off. (defines are passed via the command line,
......@@ -150,7 +158,7 @@ config("compiler") {
# CPU architecture. We may or may not be doing a cross compile now, so for
# simplicity we always explicitly set the architecture.
if (cpu_arch == "x64") {
cflags += [ "-m64" ]
cflags += [ "-m64", "-march=x86-64", ]
ldflags += [ "-m64" ]
} else if (cpu_arch == "x86") {
cflags += [ "-m32" ]
......@@ -704,13 +712,10 @@ config("default_warnings") {
# which we no longer use. Check if it makes sense to remove
# this as well. http://crbug.com/316352
"-Wno-unneeded-internal-declaration",
]
if (!is_mac && !is_ios) {
cflags_cc += [
"-Wno-reserved-user-defined-literal",
]
}
# TODO(thakis): Remove, http://crbug.com/263960
"-Wno-reserved-user-defined-literal",
]
}
if (gcc_version >= 48) {
cflags_cc += [
......
......@@ -13,6 +13,13 @@ import subprocess
import sys
# Must be in src/.
os.chdir(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
g_total_differences = 0
def FindAndRemoveArgWithValue(command_line, argname):
"""Given a command line as a list, remove and return the value of an option
that takes a value as a separate entry.
......@@ -42,6 +49,25 @@ def MergeSpacedArgs(command_line, argname):
return result
def NormalizeSymbolArguments(command_line):
"""Normalize -g arguments.
If there's no -g args, it's equivalent to -g0. -g2 is equivalent to -g.
Modifies |command_line| in place.
"""
# Strip -g0 if there's no symbols.
have_some_symbols = False
for x in command_line:
if x.startswith('-g') and x != '-g0':
have_some_symbols = True
if not have_some_symbols and '-g0' in command_line:
command_line.remove('-g0')
# Rename -g2 to -g.
if '-g2' in command_line:
command_line[index('-g2')] = '-g'
def GetFlags(lines):
"""Turn a list of command lines into a semi-structured dict."""
flags_by_output = {}
......@@ -56,6 +82,8 @@ def GetFlags(lines):
output_name = FindAndRemoveArgWithValue(command_line, '-o')
dep_name = FindAndRemoveArgWithValue(command_line, '-MF')
NormalizeSymbolArguments(command_line)
command_line = MergeSpacedArgs(command_line, '-Xclang')
defines = [x for x in command_line if x.startswith('-D')]
......@@ -74,6 +102,21 @@ def GetFlags(lines):
x not in dash_f and \
x not in warnings and \
x not in cc_file]
# Filter for libFindBadConstructs.so having a relative path in one and
# absolute path in the other.
others_filtered = []
for x in others:
if x.startswith('-Xclang ') and x.endswith('libFindBadConstructs.so'):
others_filtered.append(
'-Xclang ' +
os.path.join(os.getcwd(),
os.path.normpath(
os.path.join('out/gn_flags', x.split(' ', 1)[1]))))
else:
others_filtered.append(x)
others = others_filtered
flags_by_output[cc_file[0]] = {
'output': output_name,
'depname': dep_name,
......@@ -89,25 +132,29 @@ def GetFlags(lines):
def CompareLists(gyp, gn, name, dont_care_gyp=None, dont_care_gn=None):
"""Return a report of any differences between gyp and gn lists, ignoring
anything in |dont_care_{gyp|gn}| respectively."""
global g_total_differences
if not dont_care_gyp:
dont_care_gyp = []
if not dont_care_gn:
dont_care_gn = []
output = ''
if gyp[name] != gn[name]:
output += ' %s differ:\n' % name
gyp_set = set(gyp[name])
gn_set = set(gn[name])
missing_in_gyp = gyp_set - gn_set
missing_in_gn = gn_set - gyp_set
missing_in_gyp -= set(dont_care_gyp)
missing_in_gn -= set(dont_care_gn)
if missing_in_gyp or missing_in_gn:
output += ' %s differ:\n' % name
if missing_in_gyp:
output += ' In gyp, but not in GN:\n %s' % '\n '.join(
sorted(missing_in_gyp)) + '\n'
g_total_differences += len(missing_in_gyp)
if missing_in_gn:
output += ' In GN, but not in gyp:\n %s' % '\n '.join(
sorted(missing_in_gn)) + '\n\n'
g_total_differences += len(missing_in_gn)
return output
......@@ -166,6 +213,7 @@ def main():
print '\n'.join(sorted(files))
print diff
print 'Total differences:', g_total_differences
return 1 if files_with_given_differences or different_source_list else 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment