macho_dynamic.xcconfig   [plain text]



//
//  macho_dynamic.xcconfig
//  cctools
//
//  Created by Michael Trent on 12/21/18.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

// libmacho builds the standard set of variants
BUILD_VARIANTS = normal debug profile

// We need to use the macosx.internal SDKROOT in order for TAPI to work at all.
SDKROOT=macosx.internal

// When we build in B&I, the APP_EXTENSION_SAFE mach_header flag will be set
// on by default. In order for TAPI to model this correctly when building
// outside of B&I we can just default to using app extension safe API.
APPLICATION_EXTENSION_API_ONLY = YES

// libmacho is installed in /usr/lib/system
INSTALL_PATH = /usr/lib/system

// libmacho is zippered
//
// MDT Workaround for <rdar://problem/47985287> Guardian Submission Failure - Yager - cctools - 938
// stop zippering libmacho in cctools_ofiles_sdk.
CCTB_IS_cctools_ofiles_sdk = YES
IS_ZIPPERED_ = YES
IS_ZIPPERED = IS_ZIPPERED_${CCTB_IS_${CCTB_PROJECT}}

// MDT <rdar://problem/49996819> libmacho.dylib has a zippered 32bit slice on macOSJazz
// Do not zipper i386
IS_ZIPPERED[arch=i386] =

// The "dylib version" is an old Mach-O version numbering scheme stamped into
// MH_DYLIB binaries. Historically libmacho writes a compatibility version of
// 1.0.0 and a current version equivalent to its project source version.
DYLIB_COMPATIBILITY_VERSION = 1
DYLIB_CURRENT_VERSION = ${CCTB_VERSION}

// libmacho needs to only link against a specific set of system dylibs:
// libcompiler_rt, libsystem_malloc, libdyld, libsystem_c, and libsystem_kernel.
// One wrinkle is, when building against any simulator SDK, libmacho needs to
// link against libsystem_sim_kernel instead of libsystem_kernel.
LIBRARY_SEARCH_PATHS = ${SDKROOT}/usr/lib/system
LIBMACHO_DYLIBS = -lcompiler_rt -lsystem_malloc -ldyld -lsystem_c
LIBMACHO_SYSTEM_KERNEL = system_kernel
LIBMACHO_SYSTEM_KERNEL[sdk=*simulator*] = system_sim_kernel

LIBMACHO_ZIPPER_LD_FLAGS_MACOS_YES = -Wl,-iosmac_version_min,12.0
LIBMACHO_ZIPPER_LD_FLAGS = ${LIBMACHO_ZIPPER_LD_FLAGS_MACOS_${CCTB_MACOS}}

// MDT <rdar://problem/49996819> libmacho.dylib has a zippered 32bit slice on macOSJazz
// Do not zipper i386
LIBMACHO_ZIPPER_LD_FLAGS[arch=i386] =

OTHER_LDFLAGS = -nodefaultlibs -umbrella System -Wl,-application_extension ${LIBMACHO_DYLIBS} -l${LIBMACHO_SYSTEM_KERNEL} ${LIBMACHO_ZIPPER_LD_FLAGS}

// The libmacho dynamic library target can only install a subset of the mach-o
// header files, due to Xcode's limitation that there can be only one public
// header directory. The cctools project needs to install a tree of header
// directories, for historical reasons:
//
//   /usr/include/mach-o
//   /usr/include/mach-o/arm64
//   /usr/include/mach-o/x86_64
//   etc.
//
// this target will install the main mach-o header files as a convenience for
// tapi, and we'll manually add in the arch-specific public headers. All of the
// private header files will be installed in a separate target, as these are
// uninteresting to tapi.
PUBLIC_HEADERS_FOLDER_PATH=/usr/include/mach-o

// TAPI support is especially challenging for libmacho:
//
//   The libmacho target does not include all of the public header files (see
//   above) so TAPI needs to be told where to find the extra public headers.
//
//   libmacho is part of the System umbrella framework.
//
//   When building in macOS build trains, TAPI needs to be zippered to support
//   the desktop application stack. The settings for telling TAPI to "zipper"
//   the libmacho tbd are not supported in other build trains; since libmacho
//   will be built against the macOS SDK for macOS's cctools_ofiles and in
//   iOS's cctools_ofiles_sdk we need to conditionalize on the CCTB_MACOS
//   environment variable rather than an Xcode-supported SDK conditional.
//   That means we need to use Xcode variable substitution to include these
//   settings at build time.
//
// And to add insult to injury, Xcode's xcconfig file syntax does not support
// a way to break a value across more than one line. To keep this code readable
// individual options have been assigned into their own small variables, at
// the expense of obfuscating the true value of OTHER_TAPI_FLAGSS.
LIBMACHO_TAPI_FLAGS = -umbrella System -fapplication-extension

LIBMACHO_OTHER_TAPI_FLAGS_MACOS_YES = -target-variant x86_64-apple-ios12.0-macabi
LIBMACHO_ZIPPER_TAPI_FLAGS = ${LIBMACHO_OTHER_TAPI_FLAGS_MACOS_${CCTB_MACOS}}

// MDT <rdar://problem/49996819> libmacho.dylib has a zippered 32bit slice on macOSJazz
// Do not zipper i386
LIBMACHO_ZIPPER_TAPI_FLAGS[arch=i386] =

SLOT_NAME_H = -extra-public-header include/mach/slot_name.h
SWAP_HPPA_H = -extra-public-header include/mach-o/hppa/swap.h
SWAP_I386_H = -extra-public-header include/mach-o/i386/swap.h
SWAP_I860_H = -extra-public-header include/mach-o/i860/swap.h
SWAP_M68K_H = -extra-public-header include/mach-o/m68k/swap.h
SWAP_M88K_H = -extra-public-header include/mach-o/m88k/swap.h
SWAP_PPC_H = -extra-public-header include/mach-o/ppc/swap.h
SWAP_SPARC_H = -extra-public-header include/mach-o/sparc/swap.h

SUPPORTS_TEXT_BASED_API = YES
TAPI_VERIFY_MODE = Pedantic
OTHER_TAPI_FLAGS = ${LIBMACHO_TAPI_FLAGS} ${LIBMACHO_ZIPPER_TAPI_FLAGS} ${SLOT_NAME_H} ${SWAP_HPPA_H} ${SWAP_I386_H} ${SWAP_I860_H} ${SWAP_M68K_H} ${SWAP_M88K_H} ${SWAP_PPC_H} ${SWAP_SPARC_H}