Skip to content

Commit 9af5a56

Browse files
committed
Apply -t arg. Switch to std-gnu++14.
1 parent 3eca374 commit 9af5a56

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

build/config/BUILDCONFIG.gn

+3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ declare_args() {
130130

131131
# Compile for Thread Sanitizer to find threading bugs.
132132
is_tsan = false
133+
134+
# Use -std=gnu++XX instead of -std=c++XX
135+
use_stdgnu = false
133136
}
134137

135138
# =============================================================================

build/config/compiler/BUILD.gn

+11-3
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,18 @@ config("compiler") {
263263

264264
# C++14 compiler flags setup.
265265
# ---------------------------
266-
if (is_win) {
267-
cc_std = [ "/std:c++14" ]
266+
if (use_stdgnu) {
267+
if (is_win) {
268+
cc_std = [ "/std:gnu++14" ]
269+
} else {
270+
cc_std = [ "-std=gnu++14" ]
271+
}
268272
} else {
269-
cc_std = [ "-std=c++14" ]
273+
if (is_win) {
274+
cc_std = [ "/std:c++14" ]
275+
} else {
276+
cc_std = [ "-std=c++14" ]
277+
}
270278
}
271279
cflags_cc += cc_std
272280
cflags_objcc += cc_std

tools/gn.py

+24-10
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ def DontUseClang(args, target_os, host_cpu, target_cpu):
149149
# We don't have clang on Windows.
150150
return target_os == 'win'
151151

152+
def SetIsClang(args, gn_args):
153+
dont_use_clang = DontUseClang(args, gn_args['target_os'],
154+
gn_args['host_cpu'],
155+
gn_args['target_cpu'])
156+
gn_args['is_clang'] = args.clang and not dont_use_clang
157+
if 'toolchain_prefix' in gn_args:
158+
gn_args['is_clang'] = not gn_args['toolchain_prefix']
159+
gn_args['is_asan'] = args.asan and gn_args['is_clang']
160+
gn_args['is_msan'] = args.msan and gn_args['is_clang']
161+
gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
152162

153163
def UseSysroot(args, gn_args):
154164
# Don't try to use a Linux sysroot if we aren't on Linux.
@@ -157,6 +167,10 @@ def UseSysroot(args, gn_args):
157167
# Don't use the sysroot if we're given another sysroot.
158168
if TargetSysroot(args):
159169
return False
170+
# Don't use the sysroot if crossbuild.
171+
crossbuild = gn_args['target_cpu'] != gn_args['host_cpu']
172+
if crossbuild:
173+
return False
160174
# Otherwise use the sysroot.
161175
return True
162176

@@ -219,16 +233,7 @@ def ToGnArgs(args, mode, arch, target_os):
219233
if mode == 'product':
220234
gn_args['dart_runtime_mode'] = 'release'
221235
else:
222-
gn_args['dart_runtime_mode'] = 'develop'
223-
224-
dont_use_clang = DontUseClang(args, gn_args['target_os'],
225-
gn_args['host_cpu'],
226-
gn_args['target_cpu'])
227-
gn_args['is_clang'] = args.clang and not dont_use_clang
228-
229-
gn_args['is_asan'] = args.asan and gn_args['is_clang']
230-
gn_args['is_msan'] = args.msan and gn_args['is_clang']
231-
gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
236+
gn_args['dart_runtime_mode'] = 'develop'
232237

233238
if not args.platform_sdk and not gn_args['target_cpu'].startswith('arm'):
234239
gn_args['dart_platform_sdk'] = args.platform_sdk
@@ -245,6 +250,10 @@ def ToGnArgs(args, mode, arch, target_os):
245250
toolchain = ToolchainPrefix(args)
246251
if toolchain:
247252
gn_args['toolchain_prefix'] = ParseStringMap(arch, toolchain)
253+
254+
SetIsClang(args, gn_args)
255+
256+
gn_args['use_stdgnu'] = args.use_stdgnu
248257

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

0 commit comments

Comments
 (0)