Skip to content
Permalink
Browse files

Apply -t arg. Switch to std-gnu++14.

  • Loading branch information...
manhluong committed May 17, 2018
1 parent 3eca374 commit 9af5a567c1c41a83d252cc9a869d70f5c9b79799
Showing with 38 additions and 13 deletions.
  1. +3 −0 build/config/BUILDCONFIG.gn
  2. +11 −3 build/config/compiler/BUILD.gn
  3. +24 −10 tools/gn.py
@@ -130,6 +130,9 @@ declare_args() {

# Compile for Thread Sanitizer to find threading bugs.
is_tsan = false

# Use -std=gnu++XX instead of -std=c++XX
use_stdgnu = false
}

# =============================================================================
@@ -263,10 +263,18 @@ config("compiler") {

# C++14 compiler flags setup.
# ---------------------------
if (is_win) {
cc_std = [ "/std:c++14" ]
if (use_stdgnu) {
if (is_win) {
cc_std = [ "/std:gnu++14" ]
} else {
cc_std = [ "-std=gnu++14" ]
}
} else {
cc_std = [ "-std=c++14" ]
if (is_win) {
cc_std = [ "/std:c++14" ]
} else {
cc_std = [ "-std=c++14" ]
}
}
cflags_cc += cc_std
cflags_objcc += cc_std
@@ -149,6 +149,16 @@ def DontUseClang(args, target_os, host_cpu, target_cpu):
# We don't have clang on Windows.
return target_os == 'win'

def SetIsClang(args, gn_args):
dont_use_clang = DontUseClang(args, gn_args['target_os'],
gn_args['host_cpu'],
gn_args['target_cpu'])
gn_args['is_clang'] = args.clang and not dont_use_clang
if 'toolchain_prefix' in gn_args:
gn_args['is_clang'] = not gn_args['toolchain_prefix']
gn_args['is_asan'] = args.asan and gn_args['is_clang']
gn_args['is_msan'] = args.msan and gn_args['is_clang']
gn_args['is_tsan'] = args.tsan and gn_args['is_clang']

def UseSysroot(args, gn_args):
# Don't try to use a Linux sysroot if we aren't on Linux.
@@ -157,6 +167,10 @@ def UseSysroot(args, gn_args):
# Don't use the sysroot if we're given another sysroot.
if TargetSysroot(args):
return False
# Don't use the sysroot if crossbuild.
crossbuild = gn_args['target_cpu'] != gn_args['host_cpu']
if crossbuild:
return False
# Otherwise use the sysroot.
return True

@@ -219,16 +233,7 @@ def ToGnArgs(args, mode, arch, target_os):
if mode == 'product':
gn_args['dart_runtime_mode'] = 'release'
else:
gn_args['dart_runtime_mode'] = 'develop'

dont_use_clang = DontUseClang(args, gn_args['target_os'],
gn_args['host_cpu'],
gn_args['target_cpu'])
gn_args['is_clang'] = args.clang and not dont_use_clang

gn_args['is_asan'] = args.asan and gn_args['is_clang']
gn_args['is_msan'] = args.msan and gn_args['is_clang']
gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
gn_args['dart_runtime_mode'] = 'develop'

if not args.platform_sdk and not gn_args['target_cpu'].startswith('arm'):
gn_args['dart_platform_sdk'] = args.platform_sdk
@@ -245,6 +250,10 @@ def ToGnArgs(args, mode, arch, target_os):
toolchain = ToolchainPrefix(args)
if toolchain:
gn_args['toolchain_prefix'] = ParseStringMap(arch, toolchain)

SetIsClang(args, gn_args)

gn_args['use_stdgnu'] = args.use_stdgnu

goma_dir = os.environ.get('GOMA_DIR')
goma_home_dir = os.path.join(os.getenv('HOME', ''), 'goma')
@@ -414,6 +423,11 @@ def parse_args(args):
other_group.add_argument('--toolchain-prefix', '-t',
type=str,
help='Comma-separated list of arch=/path/to/toolchain-prefix mappings')
other_group.add_argument('--use-stdgnu', '-stdgnu',
help='Use -std=gnu++XX instead of default -std=c++XX. Needed to crosscompile gproftools.',
default=False,
dest='use_stdgnu',
action='store_true')
other_group.add_argument('--tsan',
help='Build with TSAN',
default=UseTSAN(),

0 comments on commit 9af5a56

Please sign in to comment.
You can’t perform that action at this time.