Commit d90ab7ef authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Move c++flags config inclusion from compiler to runtime_library

R=dpranke@chromium.org
CC=thakis@chromium.org

Change-Id: I6ed223a1fe08fa95837156ae9f4800acf7396524
Reviewed-on: https://chromium-review.googlesource.com/592512Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491145}
parent 40794fa3
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/c++/c++.gni")
import("//build/config/sysroot.gni")
config("c++flags") {
if (use_custom_libcxx) {
if (!is_clang) {
# Gcc has a built-in abs() definition with default visibility.
# If it was not disabled, it would conflict with libc++'s abs()
# with hidden visibility.
cflags = [ "-fno-builtin-abs" ]
}
cflags_cc = [
"-nostdinc++",
"-isystem" + rebase_path("$libcxx_prefix/include", root_build_dir),
"-isystem" + rebase_path("$libcxxabi_prefix/include", root_build_dir),
]
# This condition should match the one in buildtools/third_party/libc++abi.
if ((is_linux && current_cpu == "arm") || is_fuchsia) {
cflags_c = [ "-isystem" +
rebase_path("$libunwind_prefix/include", root_build_dir) ]
cflags_cc += [ "-isystem" +
rebase_path("$libunwind_prefix/include", root_build_dir) ]
}
# Make sure we don't link against libc++ or libstdc++.
ldflags = [ "-nodefaultlibs" ]
# Unfortunately, there's no way to disable linking against just
# libc++ (besides using clang instead of clang++); -nodefaultlibs
# removes all of the default libraries, so add back the ones that we
# need.
libs = [
"c",
"m",
]
if (!is_mac && !is_fuchsia) {
libs += [
"gcc_s",
"rt",
]
} else if (is_fuchsia) {
# TODO(thakis): Once Fuchsia's libclang_rt.builtin no longer has upstream
# patches, we might want to make tools/clang/scripts/update.py build it
# and bundle it with the clang package instead of using the library from
# the SDK, https://crbug.com/724204
# If clang grows a flag like -nodefaultlibs++, then this here should use
# -resource-dir instead.
# Note: Intentionally 6.0.0 instead of $clang_version because the clang
# version of the toolchain_libs directory in the Fuchsia SDK can be
# different from the version of Chromium's clang.
lib_dirs = [ "$fuchsia_sdk/toolchain_libs/clang/6.0.0/lib/fuchsia" ]
# TODO(fuchsia): We probably want to support more archs one day.
libs += [ "clang_rt.builtins-x86_64" ]
}
if (is_mac && using_sanitizer) {
lib_dirs = [ "//third_party/llvm-build/Release+Asserts/lib/clang/$clang_version/lib/darwin" ]
if (is_asan) {
libs += [ "clang_rt.asan_osx_dynamic" ]
}
}
}
}
......@@ -182,8 +182,6 @@ config("compiler") {
}
configs += [
"//build/config/c++:c++flags",
# See the definitions below.
":compiler_cpu_abi",
":compiler_codegen",
......
......@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/c++/c++.gni")
import("//build/config/clang/clang.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/sysroot.gni")
......@@ -18,11 +19,84 @@ group("posix") {
# that is Posix-only. Please see that target for advice on what should go in
# :runtime_library vs. :compiler.
config("runtime_library") {
asmflags = []
cflags = []
cflags_c = []
cflags_cc = []
cflags_objc = []
cflags_objcc = []
ldflags = []
lib_dirs = []
libs = []
if (use_custom_libcxx) {
if (!is_clang) {
# Gcc has a built-in abs() definition with default visibility.
# If it was not disabled, it would conflict with libc++'s abs()
# with hidden visibility.
cflags += [ "-fno-builtin-abs" ]
}
cflags_cc += [
"-nostdinc++",
"-isystem" + rebase_path("$libcxx_prefix/include", root_build_dir),
"-isystem" + rebase_path("$libcxxabi_prefix/include", root_build_dir),
]
# This condition should match the one in buildtools/third_party/libc++abi.
if ((is_linux && current_cpu == "arm") || is_fuchsia) {
cflags_c += [ "-isystem" +
rebase_path("$libunwind_prefix/include", root_build_dir) ]
cflags_cc += [ "-isystem" +
rebase_path("$libunwind_prefix/include", root_build_dir) ]
}
# Make sure we don't link against libc++ or libstdc++.
ldflags += [ "-nodefaultlibs" ]
# Unfortunately, there's no way to disable linking against just
# libc++ (besides using clang instead of clang++); -nodefaultlibs
# removes all of the default libraries, so add back the ones that we
# need.
libs += [
"c",
"m",
]
if (!is_mac && !is_fuchsia) {
libs += [
"gcc_s",
"rt",
]
} else if (is_fuchsia) {
# TODO(thakis): Once Fuchsia's libclang_rt.builtin no longer has upstream
# patches, we might want to make tools/clang/scripts/update.py build it
# and bundle it with the clang package instead of using the library from
# the SDK, https://crbug.com/724204
# If clang grows a flag like -nodefaultlibs++, then this here should use
# -resource-dir instead.
# Note: Intentionally 6.0.0 instead of $clang_version because the clang
# version of the toolchain_libs directory in the Fuchsia SDK can be
# different from the version of Chromium's clang.
lib_dirs += [ "$fuchsia_sdk/toolchain_libs/clang/6.0.0/lib/fuchsia" ]
# TODO(fuchsia): We probably want to support more archs one day.
libs += [ "clang_rt.builtins-x86_64" ]
}
if (is_mac && using_sanitizer) {
lib_dirs += [ "//third_party/llvm-build/Release+Asserts/lib/clang/$clang_version/lib/darwin" ]
if (is_asan) {
libs += [ "clang_rt.asan_osx_dynamic" ]
}
}
}
if (!is_mac && !is_ios && sysroot != "") {
# Pass the sysroot to all C compiler variants, the assembler, and linker.
sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
asmflags = sysroot_flags
ldflags = sysroot_flags
asmflags += sysroot_flags
ldflags += sysroot_flags
# When use_custom_libcxx=true, some -isystem flags get passed to
# cflags_cc to set up libc++ include paths. We want to make sure
......@@ -32,10 +106,10 @@ config("runtime_library") {
# cflags* will be appended on the compiler command line after
# 'cflags'." Because of this, we must set the sysroot flags for
# all cflags variants instead of using 'cflags' directly.
cflags_c = sysroot_flags
cflags_cc = sysroot_flags
cflags_objc = sysroot_flags
cflags_objcc = sysroot_flags
cflags_c += sysroot_flags
cflags_cc += sysroot_flags
cflags_objc += sysroot_flags
cflags_objcc += sysroot_flags
# Need to get some linker flags out of the sysroot.
ld_paths = exec_script("sysroot_ld_path.py",
......
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