| # Copyright 2017 The Fuchsia 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/clang/clang.gni") |
| import("//build/config/mac/mac_sdk.gni") |
| import("//build/config/sysroot.gni") |
| |
| config("compiler") { |
| cflags = [ "-mmacosx-version-min=" + mac_sdk_min ] |
| cflags_cc = [ |
| # macOS needs this to not complain about C++17isms that older macOS |
| # system libc++ doesn't support. However, we use our own toolchain's |
| # static libc++ anyway. |
| "-faligned-allocation", |
| ] |
| cflags_objcc = [ "-stdlib=libc++" ] |
| defines = [ |
| # libc++ headers mark some symbols as unavailable on macOS by default |
| # because the system libc++ doesn't support them. But we use our own |
| # toolchain's static libc++ anyway. |
| "_LIBCPP_DISABLE_AVAILABILITY", |
| ] |
| ldflags = [ |
| "-nostdlib++", |
| "${rebased_clang_prefix}/../lib/libc++.a", |
| ] |
| configs = [ |
| ":sysroot", |
| ":target", |
| ":clang_defaults", |
| ] |
| |
| rustflags = [ |
| "-Clinker=$rebased_clang_prefix/clang++", |
| "-Cdefault-linker-libraries", |
| "-Clink-arg=-mmacosx-version-min=" + mac_sdk_min, |
| ] |
| foreach(flag, ldflags) { |
| rustflags += [ "-Clink-arg=$flag" ] |
| } |
| } |
| |
| config("sysroot") { |
| cflags = [ "--sysroot=$sysroot" ] |
| ldflags = cflags |
| asmflags = cflags |
| |
| rustflags = [] |
| foreach(flag, ldflags) { |
| rustflags += [ "-Clink-arg=$flag" ] |
| } |
| } |
| |
| config("target") { |
| cflags = [ "--target=$current_target_tuple" ] |
| asmflags = cflags |
| ldflags = cflags |
| |
| rustflags = [] |
| foreach(flag, ldflags) { |
| rustflags += [ "-Clink-arg=$flag" ] |
| } |
| } |
| |
| # These flags are enabled by default in Fuchsia's Clang toolchain, but we set |
| # them explicitly to support other Clang toolchains and Clang-based tools. |
| config("clang_defaults") { |
| cflags_cc = [ |
| # Use libc++ as the C++ standard library. |
| "-stdlib=libc++", |
| ] |
| ldflags = [ |
| # Use libc++ as the C++ standard library. |
| "-stdlib=libc++", |
| |
| # Use compiler-rt as the compiler runtime. |
| "-rtlib=compiler-rt", |
| |
| # Use lld as the linker. |
| "-fuse-ld=lld", |
| ] |
| |
| rustflags = [] |
| foreach(flag, ldflags) { |
| rustflags += [ "-Clink-arg=$flag" ] |
| } |
| } |
| |
| # On Mac, this is used for everything except static libraries. |
| config("mac_dynamic_flags") { |
| ldflags = [ |
| "-Wl,-search_paths_first", |
| "-L.", |
| |
| # Path for loading shared libraries for unbundled binaries. |
| "-Wl,-rpath,@loader_path/.", |
| |
| # Path for loading shared libraries for bundled binaries. |
| # Get back from Binary.app/Contents/MacOS. |
| "-Wl,-rpath,@loader_path/../../..", |
| ] |
| |
| rustflags = [] |
| foreach(flag, ldflags) { |
| rustflags += [ "-Clink-arg=$flag" ] |
| } |
| } |
| |
| # On Mac, this is used only for executables. |
| config("mac_executable_flags") { |
| ldflags = [ "-Wl,-pie" ] # Position independent. |
| } |
| |
| # Standard libraries. |
| config("default_libs") { |
| frameworks = [ |
| "AppKit.framework", |
| "ApplicationServices.framework", |
| "Carbon.framework", |
| "CoreFoundation.framework", |
| "CoreVideo.framework", |
| "Foundation.framework", |
| "OpenGL.framework", |
| "Security.framework", |
| "IOKit.framework", |
| ] |
| } |
| |
| # This rule is expected to be used in conjunction with the removal of |
| # `symbol_no_undefined` from configs. |
| config("symbol_dynamic_lookup_undefined") { |
| ldflags = [ "-Wl,-undefined,dynamic_lookup" ] |
| } |