Remove clang-cc code for handling -mmacosx-version-min and

-miphoneos-version-min.

llvm-svn: 85601
This commit is contained in:
Daniel Dunbar 2009-10-30 18:12:31 +00:00
parent 624c21b029
commit f3355a61c4
3 changed files with 21 additions and 129 deletions

View File

@ -18,6 +18,6 @@
// RUN: clang-cc -g -triple x86_64-unknown-unknown -emit-llvm -o %t %s &&
// <rdar://problem/7181838> 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

View File

@ -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

View File

@ -657,6 +657,10 @@ static llvm::cl::opt<std::string>
TargetABI("target-abi",
llvm::cl::desc("Target a particular ABI type"));
static llvm::cl::opt<std::string>
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<unsigned> {
@ -875,123 +879,6 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
Options.setMainFileName(MainFileName.c_str());
}
//===----------------------------------------------------------------------===//
// Target Triple Processing.
//===----------------------------------------------------------------------===//
static llvm::cl::opt<std::string>
TargetTriple("triple",
llvm::cl::desc("Specify target triple (e.g. i686-apple-darwin9)"));
static llvm::cl::opt<std::string>
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<std::string>
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<void*>(&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<TargetInfo>
Target(TargetInfo::CreateTargetInfo(Triple.getTriple()));