diff options
author | Chris Lattner <sabre@nondot.org> | 2008-09-30 01:13:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-09-30 01:13:12 +0000 |
commit | 6a30c1fc7f3050fc14ca9d3bd713fced65db89a2 (patch) | |
tree | e7f69efbb8b955967e143433d96182eb20fd130d /Driver/clang.cpp | |
parent | 898d508d4c9e9d45914952473e39196b20830a9f (diff) |
start handling 'mmacosx-version-min', this is not complete yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56828 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/clang.cpp')
-rw-r--r-- | Driver/clang.cpp | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp index ff98bff9dc..691b8245ca 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -613,6 +613,10 @@ TargetTriple("triple", static llvm::cl::opt<std::string> Arch("arch", llvm::cl::desc("Specify target architecture (e.g. i686)")); +static llvm::cl::opt<std::string> +MacOSVersionMin("mmacosx-version-min", + llvm::cl::desc("Specify target Mac OS/X version (e.g. 10.5)")); + static std::string CreateTargetTriple() { // Initialize base triple. If a -triple option has been specified, use // that triple. Otherwise, default to the host triple. @@ -621,20 +625,46 @@ static std::string CreateTargetTriple() { // If -arch foo was specified, remove the architecture from the triple we have // so far and replace it with the specified one. - if (Arch.empty()) - return Triple; + if (!Arch.empty()) { + // Decompose the base triple into "arch" and suffix. + std::string::size_type FirstDashIdx = Triple.find('-'); - // Decompose the base triple into "arch" and suffix. - std::string::size_type FirstDashIdx = Triple.find("-"); + if (FirstDashIdx == std::string::npos) { + fprintf(stderr, + "Malformed target triple: \"%s\" ('-' could not be found).\n", + Triple.c_str()); + exit(1); + } - if (FirstDashIdx == std::string::npos) { - fprintf(stderr, - "Malformed target triple: \"%s\" ('-' could not be found).\n", - Triple.c_str()); - exit(1); + Triple = Arch + std::string(Triple.begin()+FirstDashIdx, Triple.end()); + } + + // 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()) { + std::string::size_type DarwinDashIdx = Triple.find("-darwin"); + if (DarwinDashIdx == std::string::npos) { + fprintf(stderr, + "-mmacosx-version-min only valid for darwin (Mac OS/X) targets\n"); + exit(1); + } + DarwinDashIdx += strlen("-darwin"); + + // Validate that there is a number after the "-darwin" and nothing else. + bool IsValidDarwinNumber = Triple.size() != DarwinDashIdx; + for (unsigned i = 0; i != DarwinDashIdx; ++i) + if (Triple[DarwinDashIdx] < '0' || Triple[DarwinDashIdx] > '9') + IsValidDarwinNumber = false; + if (IsValidDarwinNumber) { + fprintf(stderr, "invalid darwin target triple '%s' expected number\n", + Triple.c_str()); + exit(1); + } + + // TODO: Turn MacOSVersionMin into darwin number: 10.3.9 -> 7. } - return Arch + std::string(Triple.begin()+FirstDashIdx, Triple.end()); + return Triple; } //===----------------------------------------------------------------------===// |