15f9996aaSopenharmony_ci# Copyright (c) 2013 The Chromium Authors. All rights reserved. 25f9996aaSopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 35f9996aaSopenharmony_ci# found in the LICENSE file. 45f9996aaSopenharmony_ci 55f9996aaSopenharmony_ciimport("//build/config/c++/c++.gni") 65f9996aaSopenharmony_ciimport("//build/config/mac/mac_sdk.gni") 75f9996aaSopenharmony_ciimport("//build/config/mac/symbols.gni") 85f9996aaSopenharmony_ciimport("//build/config/sysroot.gni") 95f9996aaSopenharmony_ci 105f9996aaSopenharmony_ci# This is included by reference in the //build/config/compiler config that 115f9996aaSopenharmony_ci# is applied to all targets. It is here to separate out the logic. 125f9996aaSopenharmony_ciconfig("compiler") { 135f9996aaSopenharmony_ci # These flags are shared between the C compiler and linker. 145f9996aaSopenharmony_ci common_mac_flags = [] 155f9996aaSopenharmony_ci 165f9996aaSopenharmony_ci # CPU architecture. 175f9996aaSopenharmony_ci if (current_cpu == "x64") { 185f9996aaSopenharmony_ci common_mac_flags += [ 195f9996aaSopenharmony_ci "-arch", 205f9996aaSopenharmony_ci "x86_64", 215f9996aaSopenharmony_ci ] 225f9996aaSopenharmony_ci } else if (current_cpu == "x86") { 235f9996aaSopenharmony_ci common_mac_flags += [ 245f9996aaSopenharmony_ci "-arch", 255f9996aaSopenharmony_ci "i386", 265f9996aaSopenharmony_ci ] 275f9996aaSopenharmony_ci } 285f9996aaSopenharmony_ci 295f9996aaSopenharmony_ci # This is here so that all files get recompiled after an Xcode update. 305f9996aaSopenharmony_ci # (defines are passed via the command line, and build system rebuild things 315f9996aaSopenharmony_ci # when their commandline changes). Nothing should ever read this define. 325f9996aaSopenharmony_ci defines = [ "CR_XCODE_VERSION=$xcode_version" ] 335f9996aaSopenharmony_ci 345f9996aaSopenharmony_ci defines += [ 355f9996aaSopenharmony_ci "_LIBCPP_CONFIG_SITE", 365f9996aaSopenharmony_ci "_LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT=0", 375f9996aaSopenharmony_ci ] 385f9996aaSopenharmony_ci 395f9996aaSopenharmony_ci asmflags = common_mac_flags 405f9996aaSopenharmony_ci cflags = common_mac_flags 415f9996aaSopenharmony_ci 425f9996aaSopenharmony_ci # Without this, the constructors and destructors of a C++ object inside 435f9996aaSopenharmony_ci # an Objective C struct won't be called, which is very bad. 445f9996aaSopenharmony_ci cflags_objcc = [ "-fobjc-call-cxx-cdtors" ] 455f9996aaSopenharmony_ci 465f9996aaSopenharmony_ci ldflags = common_mac_flags 475f9996aaSopenharmony_ci 485f9996aaSopenharmony_ci # Create a new read-only segment for protected memory. The default segments 495f9996aaSopenharmony_ci # (__TEXT and __DATA) are mapped read-execute and read-write by default. 505f9996aaSopenharmony_ci ldflags += [ 515f9996aaSopenharmony_ci "-segprot", 525f9996aaSopenharmony_ci "PROTECTED_MEMORY", 535f9996aaSopenharmony_ci "rw", 545f9996aaSopenharmony_ci "r", 555f9996aaSopenharmony_ci ] 565f9996aaSopenharmony_ci 575f9996aaSopenharmony_ci if (save_unstripped_output) { 585f9996aaSopenharmony_ci ldflags += [ "-Wcrl,unstripped," + rebase_path(root_out_dir) ] 595f9996aaSopenharmony_ci } 605f9996aaSopenharmony_ci 615f9996aaSopenharmony_ci if (export_libcxxabi_from_executables) { 625f9996aaSopenharmony_ci ldflags += [ "-Wl,-undefined,dynamic_lookup" ] 635f9996aaSopenharmony_ci } 645f9996aaSopenharmony_ci} 655f9996aaSopenharmony_ci 665f9996aaSopenharmony_ci# This is included by reference in the //build/config/compiler:runtime_library 675f9996aaSopenharmony_ci# config that is applied to all targets. It is here to separate out the logic 685f9996aaSopenharmony_ci# that is Mac-only. Please see that target for advice on what should go in 695f9996aaSopenharmony_ci# :runtime_library vs. :compiler. 705f9996aaSopenharmony_ciconfig("runtime_library") { 715f9996aaSopenharmony_ci common_flags = [ 725f9996aaSopenharmony_ci "-isysroot", 735f9996aaSopenharmony_ci sysroot, 745f9996aaSopenharmony_ci "-mmacosx-version-min=$mac_deployment_target", 755f9996aaSopenharmony_ci ] 765f9996aaSopenharmony_ci 775f9996aaSopenharmony_ci asmflags = common_flags 785f9996aaSopenharmony_ci cflags = common_flags 795f9996aaSopenharmony_ci ldflags = common_flags 805f9996aaSopenharmony_ci framework_dirs = [ sysroot ] 815f9996aaSopenharmony_ci 825f9996aaSopenharmony_ci # Prevent Mac OS X AssertMacros.h (included by system header) from defining 835f9996aaSopenharmony_ci # macros that collide with common names, like 'check', 'require', and 845f9996aaSopenharmony_ci # 'verify'. 855f9996aaSopenharmony_ci # http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMacros.h 865f9996aaSopenharmony_ci defines = [ "__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0" ] 875f9996aaSopenharmony_ci} 885f9996aaSopenharmony_ci 895f9996aaSopenharmony_ci# On Mac, this is used for everything except static libraries. 905f9996aaSopenharmony_ciconfig("mac_dynamic_flags") { 915f9996aaSopenharmony_ci ldflags = [ "-Wl,-ObjC" ] # Always load Objective-C categories and classes. 925f9996aaSopenharmony_ci 935f9996aaSopenharmony_ci if (is_component_build) { 945f9996aaSopenharmony_ci ldflags += [ 955f9996aaSopenharmony_ci # Path for loading shared libraries for unbundled binaries. 965f9996aaSopenharmony_ci "-Wl,-rpath,@loader_path/.", 975f9996aaSopenharmony_ci 985f9996aaSopenharmony_ci # Path for loading shared libraries for bundled binaries. Get back from 995f9996aaSopenharmony_ci # Binary.app/Contents/MacOS. 1005f9996aaSopenharmony_ci "-Wl,-rpath,@loader_path/../../..", 1015f9996aaSopenharmony_ci ] 1025f9996aaSopenharmony_ci } 1035f9996aaSopenharmony_ci} 1045f9996aaSopenharmony_ci 1055f9996aaSopenharmony_ci# The ldflags referenced below are handled by 1065f9996aaSopenharmony_ci# //build/toolchain/mac/linker_driver.py. 1075f9996aaSopenharmony_ci# Remove this config if a target wishes to change the arguments passed to the 1085f9996aaSopenharmony_ci# strip command during linking. This config by default strips all symbols 1095f9996aaSopenharmony_ci# from a binary, but some targets may wish to specify an exports file to 1105f9996aaSopenharmony_ci# preserve specific symbols. 1115f9996aaSopenharmony_ciconfig("strip_all") { 1125f9996aaSopenharmony_ci if (enable_stripping) { 1135f9996aaSopenharmony_ci ldflags = [ "-Wcrl,strip,-x,-S" ] 1145f9996aaSopenharmony_ci } 1155f9996aaSopenharmony_ci} 116