From: Daniel Dunbar Date: Fri, 30 Oct 2009 18:12:31 +0000 (+0000) Subject: Remove clang-cc code for handling -mmacosx-version-min and X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c15e71fb260629e58c25798f1040e5a3305f9f6;p=clang Remove clang-cc code for handling -mmacosx-version-min and -miphoneos-version-min. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85601 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Coverage/targets.c b/test/Coverage/targets.c index 663f4abf02..c4f030fff3 100644 --- a/test/Coverage/targets.c +++ b/test/Coverage/targets.c @@ -18,6 +18,6 @@ // RUN: clang-cc -g -triple x86_64-unknown-unknown -emit-llvm -o %t %s && // clang 1.0 fails to compile Python 2.6 -// RUN: clang-cc -g -triple x86_64-apple-darwin9 -emit-llvm -o %t %s -mmacosx-version-min=10.4 && +// RUN: clang -ccc-host-triple x86_64-apple-darwin9 -### -S %s -mmacosx-version-min=10.4 && // RUN: true diff --git a/test/Frontend/darwin-version.c b/test/Frontend/darwin-version.c index 513ea197e8..3217b9ad5e 100644 --- a/test/Frontend/darwin-version.c +++ b/test/Frontend/darwin-version.c @@ -1,23 +1,23 @@ -// RUN: clang-cc -triple armv6-apple-darwin9 -dM -E -o %t - < /dev/null && -// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '10000' | count 1 && +// RUN: clang -ccc-host-triple armv6-apple-darwin9 -dM -E -o %t %s && +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '30000' | count 1 && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0 && -// RUN: clang-cc -triple armv6-apple-darwin9 -miphoneos-version-min=2.0 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple armv6-apple-darwin9 -miphoneos-version-min=2.0 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20000' | count 1 && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0 && -// RUN: clang-cc -triple armv6-apple-darwin9 -miphoneos-version-min=2.2 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple armv6-apple-darwin9 -miphoneos-version-min=2.2 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20200' | count 1 && -// RUN: clang-cc -triple i686-apple-darwin8 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple i686-apple-darwin8 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0 && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1 && -// RUN: clang-cc -triple i686-apple-darwin9 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple i686-apple-darwin9 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1 && -// RUN: clang-cc -triple i686-apple-darwin10 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple i686-apple-darwin10 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1 && -// RUN: clang-cc -triple i686-apple-darwin9 -mmacosx-version-min=10.4 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple i686-apple-darwin9 -mmacosx-version-min=10.4 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0 && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1 && -// RUN: clang-cc -triple i686-apple-darwin9 -mmacosx-version-min=10.5 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple i686-apple-darwin9 -mmacosx-version-min=10.5 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1 && -// RUN: clang-cc -triple i686-apple-darwin9 -mmacosx-version-min=10.6 -dM -E -o %t - < /dev/null && +// RUN: clang -ccc-host-triple i686-apple-darwin9 -mmacosx-version-min=10.6 -dM -E -o %t %s && // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1 && // RUN: true diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index 2d05859ebc..5840f5f990 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -657,6 +657,10 @@ static llvm::cl::opt TargetABI("target-abi", llvm::cl::desc("Target a particular ABI type")); +static llvm::cl::opt +TargetTriple("triple", + llvm::cl::desc("Specify target triple (e.g. i686-apple-darwin9)")); + // It might be nice to add bounds to the CommandLine library directly. struct OptLevelParser : public llvm::cl::parser { @@ -875,123 +879,6 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, Options.setMainFileName(MainFileName.c_str()); } -//===----------------------------------------------------------------------===// -// Target Triple Processing. -//===----------------------------------------------------------------------===// - -static llvm::cl::opt -TargetTriple("triple", - llvm::cl::desc("Specify target triple (e.g. i686-apple-darwin9)")); - -static llvm::cl::opt -MacOSVersionMin("mmacosx-version-min", - llvm::cl::desc("Specify target Mac OS X version (e.g. 10.5)")); - -// If -mmacosx-version-min=10.3.9 is specified, change the triple from being -// something like powerpc-apple-darwin9 to powerpc-apple-darwin7 - -// FIXME: We should have the driver do this instead. -static void HandleMacOSVersionMin(llvm::Triple &Triple) { - if (Triple.getOS() != llvm::Triple::Darwin) { - fprintf(stderr, - "-mmacosx-version-min only valid for darwin (Mac OS X) targets\n"); - exit(1); - } - - // Validate that MacOSVersionMin is a 'version number', starting with 10.[3-9] - if (MacOSVersionMin.size() < 4 || - MacOSVersionMin.substr(0, 3) != "10." || - !isdigit(MacOSVersionMin[3])) { - fprintf(stderr, - "-mmacosx-version-min=%s is invalid, expected something like '10.4'.\n", - MacOSVersionMin.c_str()); - exit(1); - } - - unsigned VersionNum = MacOSVersionMin[3]-'0'; - llvm::SmallString<16> NewDarwinString; - NewDarwinString += "darwin"; - - // Turn MacOSVersionMin into a darwin number: e.g. 10.3.9 is 3 -> darwin7. - VersionNum += 4; - if (VersionNum > 9) { - NewDarwinString += '1'; - VersionNum -= 10; - } - NewDarwinString += (VersionNum+'0'); - - if (MacOSVersionMin.size() == 4) { - // "10.4" is ok. - } else if (MacOSVersionMin.size() == 6 && - MacOSVersionMin[4] == '.' && - isdigit(MacOSVersionMin[5])) { // 10.4.7 is ok. - // Add the period piece (.7) to the end of the triple. This gives us - // something like ...-darwin8.7 - NewDarwinString += '.'; - NewDarwinString += MacOSVersionMin[5]; - } else { // "10.4" is ok. 10.4x is not. - fprintf(stderr, - "-mmacosx-version-min=%s is invalid, expected something like '10.4'.\n", - MacOSVersionMin.c_str()); - exit(1); - } - - Triple.setOSName(NewDarwinString.str()); -} - -static llvm::cl::opt -IPhoneOSVersionMin("miphoneos-version-min", - llvm::cl::desc("Specify target iPhone OS version (e.g. 2.0)")); - -// If -miphoneos-version-min=2.2 is specified, change the triple from being -// something like armv6-apple-darwin10 to armv6-apple-darwin9.2.2. We use -// 9 as the default major Darwin number, and encode the iPhone OS version -// number in the minor version and revision. - -// FIXME: We should have the driver do this instead. -static void HandleIPhoneOSVersionMin(llvm::Triple &Triple) { - if (Triple.getOS() != llvm::Triple::Darwin) { - fprintf(stderr, - "-miphoneos-version-min only valid for darwin (Mac OS X) targets\n"); - exit(1); - } - - // Validate that IPhoneOSVersionMin is a 'version number', starting with - // [2-9].[0-9] - if (IPhoneOSVersionMin.size() != 3 || !isdigit(IPhoneOSVersionMin[0]) || - IPhoneOSVersionMin[1] != '.' || !isdigit(IPhoneOSVersionMin[2])) { - fprintf(stderr, - "-miphoneos-version-min=%s is invalid, expected something like '2.0'.\n", - IPhoneOSVersionMin.c_str()); - exit(1); - } - - // Turn IPhoneOSVersionMin into a darwin number: e.g. 2.0 is 2 -> 9.2.0 - llvm::SmallString<16> NewDarwinString; - NewDarwinString += "darwin9."; - NewDarwinString += IPhoneOSVersionMin; - Triple.setOSName(NewDarwinString.str()); -} - -/// CreateTargetTriple - Process the various options that affect the target -/// triple and build a final aggregate triple that we are compiling for. -static llvm::Triple CreateTargetTriple() { - // Initialize base triple. If a -triple option has been specified, use - // that triple. Otherwise, default to the host triple. - llvm::Triple Triple(TargetTriple); - if (Triple.getTriple().empty()) - Triple = llvm::Triple(llvm::sys::getHostTriple()); - - // If -mmacosx-version-min=10.3.9 is specified, change the triple from being - // something like powerpc-apple-darwin9 to powerpc-apple-darwin7 - if (!MacOSVersionMin.empty()) - HandleMacOSVersionMin(Triple); - else if (!IPhoneOSVersionMin.empty()) - HandleIPhoneOSVersionMin(Triple); - - return Triple; -} - //===----------------------------------------------------------------------===// // SourceManager initialization. //===----------------------------------------------------------------------===// @@ -2323,8 +2210,13 @@ int main(int argc, char **argv) { llvm::llvm_install_error_handler(LLVMErrorHandler, static_cast(&Diags)); + // Initialize base triple. If a -triple option has been specified, use + // that triple. Otherwise, default to the host triple. + llvm::Triple Triple(TargetTriple); + if (Triple.getTriple().empty()) + Triple = llvm::Triple(llvm::sys::getHostTriple()); + // Get information about the target being compiled for. - llvm::Triple Triple = CreateTargetTriple(); llvm::OwningPtr Target(TargetInfo::CreateTargetInfo(Triple.getTriple()));