[Lldb-commits] [lldb] cf24508 - Add support for more OS types to AddClangModuleCompilationOptionsForSDKType()
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 16 11:43:40 PDT 2020
Author: Adrian Prantl
Date: 2020-10-16T11:43:22-07:00
New Revision: cf245086518efbdf96c2d86697298a8da5c97669
URL: https://github.com/llvm/llvm-project/commit/cf245086518efbdf96c2d86697298a8da5c97669
DIFF: https://github.com/llvm/llvm-project/commit/cf245086518efbdf96c2d86697298a8da5c97669.diff
LOG: Add support for more OS types to AddClangModuleCompilationOptionsForSDKType()
This patch also avoids hardcoding the clang options, which makes it
less likely for them to become out-of-date.
rdar://problem/63791367+66927829
Differential Revision: https://reviews.llvm.org/D89428
Added:
Modified:
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 6f25128caf24..e0f52598e1e1 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1521,25 +1521,20 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
StreamString minimum_version_option;
bool use_current_os_version = false;
+ // If the SDK type is for the host OS, use its version number.
+ auto get_host_os = []() { return HostInfo::GetTargetTriple().getOS(); };
switch (sdk_type) {
+ case XcodeSDK::Type::MacOSX:
+ use_current_os_version = get_host_os() == llvm::Triple::MacOSX;
+ break;
case XcodeSDK::Type::iPhoneOS:
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
- use_current_os_version = true;
-#else
- use_current_os_version = false;
-#endif
+ use_current_os_version = get_host_os() == llvm::Triple::IOS;
break;
-
- case XcodeSDK::Type::iPhoneSimulator:
- use_current_os_version = false;
+ case XcodeSDK::Type::AppleTVOS:
+ use_current_os_version = get_host_os() == llvm::Triple::TvOS;
break;
-
- case XcodeSDK::Type::MacOSX:
-#if defined(__i386__) || defined(__x86_64__)
- use_current_os_version = true;
-#else
- use_current_os_version = false;
-#endif
+ case XcodeSDK::Type::watchOS:
+ use_current_os_version = get_host_os() == llvm::Triple::WatchOS;
break;
default:
break;
@@ -1559,32 +1554,49 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
}
}
// Only add the version-min options if we got a version from somewhere
- if (!version.empty()) {
+ if (!version.empty() && sdk_type != XcodeSDK::Type::Linux) {
+#define OPTION(PREFIX, NAME, VAR, ...) \
+ const char *opt_##VAR = NAME; \
+ (void)opt_##VAR;
+#include "clang/Driver/Options.inc"
+#undef OPTION
+ minimum_version_option << '-';
switch (sdk_type) {
- case XcodeSDK::Type::iPhoneOS:
- minimum_version_option.PutCString("-mios-version-min=");
- minimum_version_option.PutCString(version.getAsString());
+ case XcodeSDK::Type::MacOSX:
+ minimum_version_option << opt_mmacosx_version_min_EQ;
break;
case XcodeSDK::Type::iPhoneSimulator:
- minimum_version_option.PutCString("-mios-simulator-version-min=");
- minimum_version_option.PutCString(version.getAsString());
+ minimum_version_option << opt_mios_simulator_version_min_EQ;
break;
- case XcodeSDK::Type::MacOSX:
- minimum_version_option.PutCString("-mmacosx-version-min=");
- minimum_version_option.PutCString(version.getAsString());
+ case XcodeSDK::Type::iPhoneOS:
+ minimum_version_option << opt_mios_version_min_EQ;
+ break;
+ case XcodeSDK::Type::AppleTVSimulator:
+ minimum_version_option << opt_mtvos_simulator_version_min_EQ;
+ break;
+ case XcodeSDK::Type::AppleTVOS:
+ minimum_version_option << opt_mtvos_version_min_EQ;
break;
case XcodeSDK::Type::WatchSimulator:
- minimum_version_option.PutCString("-mwatchos-simulator-version-min=");
- minimum_version_option.PutCString(version.getAsString());
+ minimum_version_option << opt_mwatchos_simulator_version_min_EQ;
break;
- case XcodeSDK::Type::AppleTVSimulator:
- minimum_version_option.PutCString("-mtvos-version-min=");
- minimum_version_option.PutCString(version.getAsString());
+ case XcodeSDK::Type::watchOS:
+ minimum_version_option << opt_mwatchos_version_min_EQ;
break;
- default:
- llvm_unreachable("unsupported sdk");
+ case XcodeSDK::Type::bridgeOS:
+ case XcodeSDK::Type::Linux:
+ case XcodeSDK::Type::unknown:
+ if (lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST)) {
+ XcodeSDK::Info info;
+ info.type = sdk_type;
+ LLDB_LOGF(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "Clang modules on %s are not supported",
+ XcodeSDK::GetCanonicalName(info).c_str());
+ }
+ return;
}
- options.push_back(std::string(minimum_version_option.GetString()));
+ minimum_version_option << version.getAsString();
+ options.emplace_back(std::string(minimum_version_option.GetString()));
}
FileSpec sysroot_spec;
More information about the lldb-commits
mailing list