$ cat main.cpp #include <stdio.h>int main(){ printf("hello\n"); return 0;}
$ export MACOSX_DEPLOYMENT_TARGET=""$ clang++ main.cpp$ otool -l a.out | grep LC_VERSION_MIN_MACOSX -A3
$ export MACOSX_DEPLOYMENT_TARGET=10.14$ clang++ main.cpp $ otool -l a.out | grep LC_VERSION_MIN_MACOSX -A3
$ export MACOSX_DEPLOYMENT_TARGET=10.13$ clang++ main.cpp $ otool -l a.out | grep LC_VERSION_MIN_MACOSX -A3 cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.14
Bash#!/usr/bin/env bashdeclare -a deploymentTargets=("" "10.14" "10.13" "10.12")declare -a xcodes=("" "9" "7")for xcodeVersion in "${xcodes[@]}"; do echo "check Xcode '$xcodeVersion':" clangPath=/Applications/Xcode${xcodeVersion}.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ $clangPath -v echo "test without deplyment target:" $clangPath main.cpp otool -l a.out | grep LC_VERSION_MIN_MACOSX -A3 for deploymentTarget in "${deploymentTargets[@]}"; do echo "test with deplyment target '$deploymentTarget':" MACOSX_DEPLOYMENT_TARGET="$deploymentTarget" $clangPath main.cpp otool -l a.out | grep LC_VERSION_MIN_MACOSX -A3 done echo ""done
check Xcode '':Apple LLVM version 10.0.0 (clang-1000.11.45.5)Target: x86_64-apple-darwin17.7.0Thread model: posixInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bintest without deplyment target: cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '10.14':test with deplyment target '10.13': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '10.12': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.12 sdk 10.13check Xcode '9':Apple LLVM version 9.1.0 (clang-902.0.39.2)Target: x86_64-apple-darwin17.7.0Thread model: posixInstalledDir: /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bintest without deplyment target: cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '10.14': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.14 sdk 10.13test with deplyment target '10.13': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '10.12': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.12 sdk 10.13check Xcode '7':Apple LLVM version 7.3.0 (clang-703.0.31)Target: x86_64-apple-darwin17.7.0Thread model: posixInstalledDir: /Applications/Xcode7.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bintest without deplyment target: cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '10.14': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.14 sdk 10.13test with deplyment target '10.13': cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.13 sdk 10.13test with deplyment target '10.12':ld: warning: bad symbol action: $ld$weak$os10.12$_utimensat in dylib /usr/lib/system/libsystem_c.dylib cmd LC_VERSION_MIN_MACOSX cmdsize 16 version 10.12 sdk 10.13
Load command 9 cmd LC_BUILD_VERSION cmdsize 32 platform macos sdk 10.13 minos 10.14 ntools 1 tool ld version 409.12