Skip to content

Commit b35cf60

Browse files
authored
Reland "Upgrade compiler to Clang 10." (#327)
This reverts commit 1c98a42.
1 parent 9c89394 commit b35cf60

File tree

7 files changed

+110
-45
lines changed

7 files changed

+110
-45
lines changed

build/config/BUILDCONFIG.gn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) {
283283
is_clang = true
284284
}
285285

286+
use_flutter_cxx = is_clang && (is_linux || is_android)
287+
286288
if (is_msan && !is_linux) {
287289
assert(false, "Memory sanitizer is only available on Linux.")
288290
}
@@ -529,7 +531,7 @@ if (custom_toolchain != "") {
529531
#
530532
# Variables
531533
# no_default_deps: If true, no standard dependencies will be added.
532-
if (is_android || (is_linux && current_cpu != "x86")) {
534+
if (use_flutter_cxx) {
533535
foreach(_target_type,
534536
[
535537
"executable",

build/config/compiler/BUILD.gn

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ config("compiler") {
163163
common_mac_flags += [
164164
"-arch",
165165
"x86_64",
166-
"-march=core2",
167166
]
168167
} else if (current_cpu == "x86") {
169168
common_mac_flags += [
@@ -210,10 +209,6 @@ config("compiler") {
210209
ldflags += [ "-m32" ]
211210
if (is_clang) {
212211
cflags += [
213-
# Else building libyuv gives clang's register allocator issues,
214-
# see llvm.org/PR15798 / crbug.com/233709
215-
"-momit-leaf-frame-pointer",
216-
217212
# Align the stack on 16-byte boundaries, http://crbug.com/418554.
218213
"-mstack-alignment=16",
219214
"-mstackrealign",
@@ -500,6 +495,7 @@ config("compiler_arm_fpu") {
500495
config("runtime_library") {
501496
cflags = []
502497
cflags_cc = []
498+
cflags_objcc = []
503499
defines = []
504500
ldflags = []
505501
lib_dirs = []
@@ -521,6 +517,20 @@ config("runtime_library") {
521517
]
522518
}
523519

520+
if (use_flutter_cxx) {
521+
cflags_cc += [ "-nostdinc++" ]
522+
cflags_objcc += [ "-nostdinc++" ]
523+
524+
# Unwind seemes to be in these libraries in Linux.
525+
if (!is_linux) {
526+
ldflags += [ "-nostdlib++" ]
527+
}
528+
include_dirs = [
529+
"//third_party/libcxx/include",
530+
"//third_party/libcxxabi/include",
531+
]
532+
}
533+
524534
# Android standard library setup.
525535
if (is_android) {
526536
if (is_clang) {
@@ -531,8 +541,6 @@ config("runtime_library") {
531541
]
532542
}
533543

534-
defines += [ "__GNU_SOURCE=1" ] # Necessary for clone().
535-
536544
# TODO(jdduke) Re-enable on mips after resolving linking
537545
# issues with libc++ (crbug.com/456380).
538546
if (current_cpu != "mipsel" && current_cpu != "mips64el") {
@@ -556,11 +564,6 @@ config("runtime_library") {
556564
"-D__ANDROID_API__=$android_api_level",
557565
]
558566

559-
include_dirs = [
560-
"//third_party/libcxx/include",
561-
"//third_party/libcxxabi/include",
562-
]
563-
564567
# libunwind and libandroid_support also live in $android_libcpp_root.
565568
lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ]
566569

@@ -589,13 +592,7 @@ config("runtime_library") {
589592
# We compile our own libc++ on all Linux targets except i386 (for
590593
# gen_snapshot) where this is not supported.
591594
if (is_linux) {
592-
if (current_cpu != "x86") {
593-
cflags_cc += [ "-nostdinc++" ]
594-
include_dirs = [
595-
"//third_party/libcxx/include",
596-
"//third_party/libcxxabi/include",
597-
]
598-
} else {
595+
if (!use_flutter_cxx) {
599596
cflags_cc += [ "-stdlib=libstdc++" ]
600597
ldflags += [ "-stdlib=libstdc++" ]
601598
libs += [ "gcc" ]
@@ -638,6 +635,9 @@ if (is_win) {
638635
# Disables.
639636
"-Wno-missing-field-initializers", # "struct foo f = {0};"
640637
"-Wno-unused-parameter", # Unused function parameters.
638+
"-Wno-implicit-int-float-conversion",
639+
"-Wno-reorder-init-list",
640+
"-Wno-c99-designator",
641641
]
642642

643643
if (is_mac || is_ios) {

build/config/ios/BUILD.gn

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
import("//build/config/sysroot.gni")
65
import("//build/config/ios/ios_sdk.gni")
6+
import("//build/config/sysroot.gni")
77

88
config("sdk") {
99
common_flags = [ "-stdlib=libc++" ]
1010

1111
cflags = common_flags
1212
ldflags = common_flags
13+
14+
common_ccflags = [
15+
"-nostdinc++",
16+
"-isystem",
17+
"$xcode_toolchain/usr/include/c++/v1",
18+
]
19+
20+
cflags_cc = common_ccflags
21+
cflags_objcc = common_ccflags
1322
}

build/config/mac/BUILD.gn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ config("sdk") {
99

1010
cflags = common_flags
1111
ldflags = common_flags
12+
13+
common_ccflags = [
14+
"-nostdinc++",
15+
"-isystem",
16+
"$xcode_toolchain/usr/include/c++/v1",
17+
]
18+
19+
cflags_cc = common_ccflags
20+
cflags_objcc = common_ccflags
1221
}
1322

1423
# On Mac, this is used for everything except static libraries.

build/config/mac/xcode_toolchain.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/python
2+
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
import sys
7+
import os
8+
import subprocess
9+
10+
def Main():
11+
path = subprocess.check_output(['/usr/bin/env', 'xcode-select', '-p']).strip();
12+
path = os.path.join(path, "Toolchains", "XcodeDefault.xctoolchain")
13+
assert os.path.exists(path)
14+
print path
15+
16+
if __name__ == '__main__':
17+
sys.exit(Main())

build/config/sysroot.gni

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ declare_args() {
99
# The absolute path of the sysroot that is applied when compiling using
1010
# the target toolchain.
1111
target_sysroot = ""
12+
13+
# The absolute path to the Xcode toolchain. This is used to look for headers
14+
# that usually ship with the toolchain like c++/v1.
15+
xcode_toolchain = ""
1216
}
1317

1418
if (current_toolchain == default_toolchain && target_sysroot != "") {
@@ -31,3 +35,10 @@ if (current_toolchain == default_toolchain && target_sysroot != "") {
3135
} else {
3236
sysroot = ""
3337
}
38+
39+
if ((is_mac || is_ios) && xcode_toolchain == "") {
40+
xcode_toolchain = exec_script("//build/config/mac/xcode_toolchain.py",
41+
[],
42+
"trim string",
43+
[])
44+
}

build/secondary/third_party/libcxxabi/BUILD.gn

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,60 @@
55
import("$flutter_root/common/config.gni")
66

77
config("libcxxabi_config") {
8+
common_cc_flags = [ "-nostdinc++" ]
9+
10+
cflags_cc = common_cc_flags
11+
cflags_objcc = common_cc_flags
12+
813
include_dirs = [ "include" ]
914
}
1015

1116
source_set("libcxxabi") {
1217
visibility = [ "../libcxx:*" ]
1318

14-
sources = [
19+
public_configs = [ ":libcxxabi_config" ]
20+
21+
defines = [
22+
"_LIBCXXABI_NO_EXCEPTIONS",
23+
"_LIBCXXABI_BUILDING_LIBRARY",
24+
"LIBCXXABI_SILENT_TERMINATE",
25+
]
26+
27+
sources = []
28+
29+
# Compile libcxx ABI using C++11. This replicates the rule in the
30+
# CMakeLists on the "cxx_abiobjects" target.
31+
configs -= [ "//build/config/compiler:cxx_version_default" ]
32+
configs += [ "//build/config/compiler:cxx_version_11" ]
33+
34+
configs += [ "../libcxx:libcxx_config" ]
35+
36+
# No translation units in the engine are built with exceptions. But, using
37+
# Objective-C exceptions requires some infrastructure setup for exceptions.
38+
# Build support for the same in cxxabi on Darwin.
39+
if (is_mac || is_ios) {
40+
configs -= [ "//build/config/gcc:no_exceptions" ]
41+
sources += [
42+
"src/cxa_exception.cpp",
43+
"src/cxa_personality.cpp",
44+
]
45+
} else {
46+
sources += [ "src/cxa_noexception.cpp" ]
47+
}
48+
49+
# Third party dependencies may depend on RTTI. Add support for the same in
50+
# cxxabi.
51+
configs -= [ "//build/config/compiler:no_rtti" ]
52+
configs += [ "//build/config/compiler:rtti" ]
53+
54+
sources += [
1555
"src/abort_message.cpp",
1656
"src/cxa_aux_runtime.cpp",
1757
"src/cxa_default_handlers.cpp",
1858
"src/cxa_demangle.cpp",
1959
"src/cxa_exception_storage.cpp",
2060
"src/cxa_guard.cpp",
2161
"src/cxa_handlers.cpp",
22-
"src/cxa_noexception.cpp",
2362
"src/cxa_unexpected.cpp",
2463
"src/cxa_vector.cpp",
2564
"src/cxa_virtual.cpp",
@@ -29,26 +68,4 @@ source_set("libcxxabi") {
2968
"src/stdlib_stdexcept.cpp",
3069
"src/stdlib_typeinfo.cpp",
3170
]
32-
33-
public_configs = [ ":libcxxabi_config" ]
34-
35-
defines = [
36-
"_LIBCXXABI_NO_EXCEPTIONS",
37-
"_LIBCXXABI_BUILDING_LIBRARY",
38-
"LIBCXXABI_SILENT_TERMINATE",
39-
]
40-
41-
# ICU uses RTTI, so we need to build libcxxabi with support for it,
42-
# https://github.com/flutter/flutter/issues/24535.
43-
configs -= [ "//build/config/compiler:no_rtti" ]
44-
45-
# Compile libcxx ABI using an older standard. This replicates the rule in the
46-
# CMakeLists on the "cxx_abiobjects" target.
47-
configs -= [ "//build/config/compiler:cxx_version_default" ]
48-
configs += [ "//build/config/compiler:cxx_version_11" ]
49-
50-
configs += [
51-
"//build/config/compiler:rtti",
52-
"//third_party/libcxx:libcxx_config",
53-
]
5471
}

0 commit comments

Comments
 (0)