|  | # Copyright 2015 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/sanitizers/sanitizers.gni") | 
|  | import("//build/toolchain/toolchain.gni") | 
|  |  | 
|  | # Used by libc++ and libc++abi. | 
|  | config("config") { | 
|  | cflags = [ "-fstrict-aliasing" ] | 
|  | if (is_win) { | 
|  | # libc++ wants to redefine the macros WIN32_LEAN_AND_MEAN and _CRT_RAND_S in its | 
|  | # implementation. | 
|  | cflags += [ "-Wno-macro-redefined" ] | 
|  | } else { | 
|  | cflags += [ "-fPIC" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | if (libcpp_is_static) { | 
|  | link_target_type = "source_set" | 
|  | } else { | 
|  | link_target_type = "shared_library" | 
|  | } | 
|  | target(link_target_type, "libc++") { | 
|  | if (!libcpp_is_static) { | 
|  | no_default_deps = true | 
|  | } | 
|  | sources = [ | 
|  | "trunk/src/algorithm.cpp", | 
|  | "trunk/src/any.cpp", | 
|  | "trunk/src/bind.cpp", | 
|  | "trunk/src/chrono.cpp", | 
|  | "trunk/src/condition_variable.cpp", | 
|  | "trunk/src/debug.cpp", | 
|  | "trunk/src/exception.cpp", | 
|  | "trunk/src/functional.cpp", | 
|  | "trunk/src/future.cpp", | 
|  | "trunk/src/hash.cpp", | 
|  | "trunk/src/ios.cpp", | 
|  | "trunk/src/iostream.cpp", | 
|  | "trunk/src/locale.cpp", | 
|  | "trunk/src/memory.cpp", | 
|  | "trunk/src/mutex.cpp", | 
|  | "trunk/src/new.cpp", | 
|  | "trunk/src/optional.cpp", | 
|  | "trunk/src/random.cpp", | 
|  | "trunk/src/regex.cpp", | 
|  | "trunk/src/shared_mutex.cpp", | 
|  | "trunk/src/stdexcept.cpp", | 
|  | "trunk/src/string.cpp", | 
|  | "trunk/src/strstream.cpp", | 
|  | "trunk/src/system_error.cpp", | 
|  | "trunk/src/thread.cpp", | 
|  | "trunk/src/typeinfo.cpp", | 
|  | "trunk/src/utility.cpp", | 
|  | "trunk/src/valarray.cpp", | 
|  | "trunk/src/variant.cpp", | 
|  | "trunk/src/vector.cpp", | 
|  | ] | 
|  | if (is_win) { | 
|  | sources += [ | 
|  | "trunk/src/support/win32/locale_win32.cpp", | 
|  | "trunk/src/support/win32/support.cpp", | 
|  | "trunk/src/support/win32/thread_win32.cpp", | 
|  | ] | 
|  | } | 
|  | configs -= [ | 
|  | "//build/config/compiler:chromium_code", | 
|  | "//build/config/compiler:no_exceptions", | 
|  | "//build/config/compiler:no_rtti", | 
|  | "//build/config/coverage:default_coverage", | 
|  | ] | 
|  | if (is_android && !libcpp_is_static) { | 
|  | configs -= [ "//build/config/android:hide_all_but_jni_onload" ] | 
|  | } | 
|  | configs += [ | 
|  | ":config", | 
|  | "//build/config/compiler:no_chromium_code", | 
|  | "//build/config/compiler:exceptions", | 
|  | "//build/config/compiler:rtti", | 
|  | "//build/config/sanitizers:sanitizer_options_link_helper", | 
|  | ] | 
|  |  | 
|  | defines = [ "_LIBCPP_BUILDING_LIBRARY" ] | 
|  | if (!is_clang && !libcpp_is_static) { | 
|  | # This is a temporary workaround to get libc++ builds working with | 
|  | # gcc.  It can be removed with either | 
|  | # https://reviews.llvm.org/D35326 or | 
|  | # https://reviews.llvm.org/D35388 lands. | 
|  | defines += [ "_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS=__attribute__((__visibility__(\"default\")))" ] | 
|  | } | 
|  | if (libcpp_is_static) { | 
|  | defines += [ | 
|  | # This resets the visibility to default only for the various | 
|  | # flavors of operator new and operator delete.  These symbols | 
|  | # are weak and get overriden by Chromium-provided ones, but if | 
|  | # these symbols had hidden visibility, this would make the | 
|  | # Chromium symbols hidden too because elf visibility rules | 
|  | # require that linkers use the least visible form when merging, | 
|  | # and if this is hidden, then when we merge it with tcmalloc's | 
|  | # operator new, hidden visibility would win. However, tcmalloc | 
|  | # needs a visible operator new to also override operator new | 
|  | # references from system libraries. | 
|  | # TODO(lld): Ask lld for a --force-public-visibility flag or | 
|  | # similar to that overrides the default elf merging rules, and | 
|  | # make tcmalloc's gn config pass that to all its dependencies, | 
|  | # then remove this override here. | 
|  | "_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))", | 
|  | ] | 
|  | } | 
|  |  | 
|  | if (!is_win) { | 
|  | defines += [ "LIBCXX_BUILDING_LIBCXXABI" ] | 
|  | deps = [ | 
|  | "//buildtools/third_party/libc++abi", | 
|  | ] | 
|  | } | 
|  | } |