Commit acad4965 authored by thakis@chromium.org's avatar thakis@chromium.org

Use clang as default host compiler when cross-compiling

chrome/android still used system gcc as host compiler, and system gcc is
gcc 4.6 on Ubuntu Precise. This is too old.

Instead, use clang by default as host compiler (except when building for
AOSP, see http://crbug.com/377684 for that). This is controlled by a new
gyp variable host_clang, which only has an effect if clang=0. The existing
clang gyp variable means "use clang for everything"; if it's not set then
host_clang means "use clang for host compiles".

If your system gcc is 4.8+ and you don't want to use clang, you can set
host_clang=0 to use system gcc for host compiles instead.

In host_clang mode, our clang plugins currently aren't used (I figure if you
want plugins, you can just use clang=1). clang_warning_flags on the other
hand are used, to make sure the build stays warning-free.

BUG=360311
R=hans@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287386 0039d316-1c4b-4281-b951-d872f2087c98
parent 93ea39da
...@@ -543,8 +543,12 @@ ...@@ -543,8 +543,12 @@
# for details. # for details.
'chromium_win_pch%': 0, 'chromium_win_pch%': 0,
# Clang stuff.
'make_clang_dir%': 'third_party/llvm-build/Release+Asserts',
# Set this to true when building with Clang. # Set this to true when building with Clang.
# See http://code.google.com/p/chromium/wiki/Clang for details. # See http://code.google.com/p/chromium/wiki/Clang for details.
# If this is set, clang is used as both host and target compiler in
# cross-compile builds.
'clang%': 0, 'clang%': 0,
# Enable plug-in installation by default. # Enable plug-in installation by default.
...@@ -604,6 +608,14 @@ ...@@ -604,6 +608,14 @@
'ozone_auto_platforms%': 1, 'ozone_auto_platforms%': 1,
'conditions': [ 'conditions': [
['android_webview_build==0', {
# If this is set clang is used as host compiler, but not as target
# compiler. Always do this by default, except when building for AOSP.
'host_clang%': 1,
}, {
# See http://crbug.com/377684
'host_clang%': 0,
}],
# A flag for POSIX platforms # A flag for POSIX platforms
['OS=="win"', { ['OS=="win"', {
'os_posix%': 0, 'os_posix%': 0,
...@@ -1254,7 +1266,8 @@ ...@@ -1254,7 +1266,8 @@
# Clang stuff. # Clang stuff.
'clang%': '<(clang)', 'clang%': '<(clang)',
'make_clang_dir%': 'third_party/llvm-build/Release+Asserts', 'host_clang%': '<(host_clang)',
'make_clang_dir%': '<(make_clang_dir)',
# Control which version of clang to use when building for iOS. If set to # Control which version of clang to use when building for iOS. If set to
# '1', uses the version of clang that ships with Xcode. If set to '0', uses # '1', uses the version of clang that ships with Xcode. If set to '0', uses
...@@ -2273,6 +2286,14 @@ ...@@ -2273,6 +2286,14 @@
'chromium_win_pch': 0, 'chromium_win_pch': 0,
}], }],
['host_clang==1', {
'host_cc': '<(make_clang_dir)/bin/clang',
'host_cxx': '<(make_clang_dir)/bin/clang++',
}, {
'host_cc': '<!(which gcc)',
'host_cxx': '<!(which g++)',
}],
# The seccomp-bpf sandbox is only supported on four architectures # The seccomp-bpf sandbox is only supported on four architectures
# currently. # currently.
# Do not disable seccomp_bpf anywhere without talking to # Do not disable seccomp_bpf anywhere without talking to
...@@ -3907,6 +3928,13 @@ ...@@ -3907,6 +3928,13 @@
'-std=gnu++11', '-std=gnu++11',
], ],
}], }],
['clang==0 and host_clang==1', {
'target_conditions': [
['_toolset=="host"', {
'cflags_cc': [ '-std=gnu++11', ],
}],
],
}],
['clang==1 and clang_use_chrome_plugins==1', { ['clang==1 and clang_use_chrome_plugins==1', {
'cflags': [ 'cflags': [
'<@(clang_chrome_plugins_flags)', '<@(clang_chrome_plugins_flags)',
...@@ -4254,7 +4282,7 @@ ...@@ -4254,7 +4282,7 @@
}], }],
], ],
}], }],
['host_gcc_version>=47 and clang==0', { ['host_gcc_version>=47 and clang==0 and host_clang==0', {
'target_conditions': [ 'target_conditions': [
['_toolset=="host"', { ['_toolset=="host"', {
'cflags_cc': [ 'cflags_cc': [
...@@ -5518,6 +5546,13 @@ ...@@ -5518,6 +5546,13 @@
], ],
}, },
}], }],
['gcc_version>=48 and clang==0 and host_clang==1', {
'target_defaults': {
'target_conditions': [
['_toolset=="host"', { 'cflags!': [ '-Wno-unused-local-typedefs' ]}],
],
},
}],
# We need a special case to handle the android webview build on mac because # We need a special case to handle the android webview build on mac because
# the host gcc there doesn't accept this flag, but the target gcc may # the host gcc there doesn't accept this flag, but the target gcc may
# require it. # require it.
...@@ -5553,16 +5588,16 @@ ...@@ -5553,16 +5588,16 @@
'make_global_settings': [ 'make_global_settings': [
['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'], ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'], ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
['CC.host', '<!(which gcc)'], ['CC.host', '<(host_cc)'],
['CXX.host', '<!(which g++)'], ['CXX.host', '<(host_cxx)'],
], ],
}], }],
['OS=="linux" and target_arch=="mipsel"', { ['OS=="linux" and target_arch=="mipsel"', {
'make_global_settings': [ 'make_global_settings': [
['CC', '<(sysroot)/../bin/mipsel-linux-gnu-gcc'], ['CC', '<(sysroot)/../bin/mipsel-linux-gnu-gcc'],
['CXX', '<(sysroot)/../bin/mipsel-linux-gnu-g++'], ['CXX', '<(sysroot)/../bin/mipsel-linux-gnu-g++'],
['CC.host', '<!(which gcc)'], ['CC.host', '<(host_cc)'],
['CXX.host', '<!(which g++)'], ['CXX.host', '<(host_cxx)'],
], ],
}], }],
['OS=="linux" and target_arch=="arm" and host_arch!="arm" and chromeos==0 and clang==0', { ['OS=="linux" and target_arch=="arm" and host_arch!="arm" and chromeos==0 and clang==0', {
...@@ -5571,8 +5606,8 @@ ...@@ -5571,8 +5606,8 @@
'make_global_settings': [ 'make_global_settings': [
['CC', '<!(which arm-linux-gnueabihf-gcc)'], ['CC', '<!(which arm-linux-gnueabihf-gcc)'],
['CXX', '<!(which arm-linux-gnueabihf-g++)'], ['CXX', '<!(which arm-linux-gnueabihf-g++)'],
['CC.host', '<!(which gcc)'], ['CC.host', '<(host_cc)'],
['CXX.host', '<!(which g++)'], ['CXX.host', '<(host_cxx)'],
], ],
}], }],
......
...@@ -46,5 +46,13 @@ ...@@ -46,5 +46,13 @@
}, },
}, },
}], }],
['clang==0 and host_clang==1', {
'target_conditions': [
['_toolset=="host"', {
'cflags': [ '>@(clang_warning_flags)' ],
'cflags!': [ '>@(clang_warning_flags_unset)' ],
}],
],
}],
], ],
} }
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