Work on Clang for pure GN build.
This hooks up Clang in the pure GN build (not the hybrid GYP mode). Clang gave some warnings about compiler flags which made me realize that we were giving linker flags to the compiler in some cases. So I enhanced our pkg-config wrapper to to add libraries to the cflags (missing else), return ldflags separately, and also strip out -pthread which was getting included over and over. BUG= Review URL: https://codereview.chromium.org/147923010 git-svn-id: http://src.chromium.org/svn/trunk/src/build@248477 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
f902545676
Коммит
22b3476400
|
@ -12,8 +12,8 @@ from optparse import OptionParser
|
|||
# This script runs pkg-config, optionally filtering out some results, and
|
||||
# returns the result.
|
||||
#
|
||||
# The result will be [ <includes>, <cflags>, <libs>, <lib_dirs> ] where each
|
||||
# member is itself a list of strings.
|
||||
# The result will be [ <includes>, <cflags>, <libs>, <lib_dirs>, <ldflags> ]
|
||||
# where each member is itself a list of strings.
|
||||
#
|
||||
# You can filter out matches using "-v <regexp>" where all results from
|
||||
# pkgconfig matching the given regular expression will be ignored. You can
|
||||
|
@ -138,6 +138,7 @@ includes = []
|
|||
cflags = []
|
||||
libs = []
|
||||
lib_dirs = []
|
||||
ldflags = []
|
||||
|
||||
for flag in all_flags[:]:
|
||||
if len(flag) == 0 or MatchesAnyRegexp(flag, strip_out):
|
||||
|
@ -145,14 +146,21 @@ for flag in all_flags[:]:
|
|||
|
||||
if flag[:2] == '-l':
|
||||
libs.append(RewritePath(flag[2:], prefix, sysroot))
|
||||
if flag[:2] == '-L':
|
||||
elif flag[:2] == '-L':
|
||||
lib_dirs.append(RewritePath(flag[2:], prefix, sysroot))
|
||||
elif flag[:2] == '-I':
|
||||
includes.append(RewritePath(flag[2:], prefix, sysroot))
|
||||
elif flag[:3] == '-Wl':
|
||||
ldflags.append(flag)
|
||||
elif flag == '-pthread':
|
||||
# Many libs specify "-pthread" which we don't need since we always include
|
||||
# this anyway. Removing it here prevents a bunch of duplicate inclusions on
|
||||
# the command line.
|
||||
pass
|
||||
else:
|
||||
cflags.append(flag)
|
||||
|
||||
# Output a GN array, the first one is the cflags, the second are the libs. The
|
||||
# JSON formatter prints GN compatible lists when everything is a list of
|
||||
# strings.
|
||||
print json.dumps([includes, cflags, libs, lib_dirs])
|
||||
print json.dumps([includes, cflags, libs, lib_dirs, ldflags])
|
||||
|
|
|
@ -34,5 +34,6 @@ template("pkg_config") {
|
|||
cflags = pkgresult[1]
|
||||
libs = pkgresult[2]
|
||||
lib_dirs = pkgresult[3]
|
||||
ldflags = pkgresult[4]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("../clang.gni")
|
||||
import("../goma.gni")
|
||||
import("../gcc_toolchain.gni")
|
||||
import("//build/config/sysroot.gni")
|
||||
import("//build/toolchain/clang.gni")
|
||||
import("//build/toolchain/gcc_toolchain.gni")
|
||||
import("//build/toolchain/goma.gni")
|
||||
|
||||
if (is_gyp) {
|
||||
# Set the compilers for GYP to use. This logic is only relevant to GYP where
|
||||
|
@ -47,8 +47,6 @@ if (is_gyp) {
|
|||
}
|
||||
}
|
||||
|
||||
# ARM --------------------------------------------------------------------------
|
||||
|
||||
gcc_toolchain("arm") {
|
||||
cc = "arm-linux-gnueabi-gcc"
|
||||
cxx = "arm-linux-gnueabi-g++"
|
||||
|
@ -59,11 +57,22 @@ gcc_toolchain("arm") {
|
|||
toolchain_os = "linux"
|
||||
}
|
||||
|
||||
# 32-bit -----------------------------------------------------------------------
|
||||
|
||||
gcc_toolchain("x86") {
|
||||
cc = "gcc"
|
||||
cxx = "g++"
|
||||
if (is_clang) {
|
||||
if (use_clang_type_profiler) {
|
||||
prefix = rebase_path("//third_party/llvm-allocated-type/Linux_ia32/bin",
|
||||
".", root_build_dir)
|
||||
} else {
|
||||
prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
|
||||
".", root_build_dir)
|
||||
}
|
||||
cc = "$prefix/clang"
|
||||
cxx = "$prefix/clang++"
|
||||
} else {
|
||||
cc = "gcc"
|
||||
cxx = "g++"
|
||||
}
|
||||
|
||||
ar = "ar"
|
||||
ld = cxx
|
||||
|
||||
|
@ -72,8 +81,21 @@ gcc_toolchain("x86") {
|
|||
}
|
||||
|
||||
gcc_toolchain("x64") {
|
||||
cc = "gcc"
|
||||
cxx = "g++"
|
||||
if (is_clang) {
|
||||
if (use_clang_type_profiler) {
|
||||
prefix = rebase_path("//third_party/llvm-allocated-type/Linux_x64/bin",
|
||||
".", root_build_dir)
|
||||
} else {
|
||||
prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
|
||||
".", root_build_dir)
|
||||
}
|
||||
cc = "$prefix/clang"
|
||||
cxx = "$prefix/clang++"
|
||||
} else {
|
||||
cc = "gcc"
|
||||
cxx = "g++"
|
||||
}
|
||||
|
||||
ar = "ar"
|
||||
ld = cxx
|
||||
|
||||
|
@ -81,8 +103,6 @@ gcc_toolchain("x64") {
|
|||
toolchain_os = "linux"
|
||||
}
|
||||
|
||||
# MIPS -----------------------------------------------------------------------
|
||||
|
||||
gcc_toolchain("mipsel") {
|
||||
cc = "mipsel-linux-gnu-gcc"
|
||||
cxx = "mipsel-linux-gnu-g++"
|
||||
|
|
Загрузка…
Ссылка в новой задаче