[Lldb-commits] [lldb] r226846 - Fix the -*-version-min option to not try and use the current OS version for iOS and the simulator since llvm/clang will assert and kill LLDB.
Greg Clayton
gclayton at apple.com
Thu Jan 22 10:25:49 PST 2015
Author: gclayton
Date: Thu Jan 22 12:25:49 2015
New Revision: 226846
URL: http://llvm.org/viewvc/llvm-project?rev=226846&view=rev
Log:
Fix the -*-version-min option to not try and use the current OS version for iOS and the simulator since llvm/clang will assert and kill LLDB.
Modified:
lldb/trunk/include/lldb/Target/Platform.h
lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
lldb/trunk/source/Target/Platform.cpp
Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Thu Jan 22 12:25:49 2015
@@ -569,7 +569,7 @@ namespace lldb_private {
// Appends the platform-specific options required to find the modules for the current platform.
virtual void
- AddClangModuleCompilationOptions (std::vector<std::string> &options);
+ AddClangModuleCompilationOptions (Target *target, std::vector<std::string> &options);
ConstString
GetWorkingDirectory ();
Modified: lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp (original)
+++ lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp Thu Jan 22 12:25:49 2015
@@ -289,7 +289,7 @@ ClangModulesDeclVendor::Create(Target &t
"-Werror=non-modular-include-in-framework-module"
};
- target.GetPlatform()->AddClangModuleCompilationOptions(compiler_invocation_arguments);
+ target.GetPlatform()->AddClangModuleCompilationOptions(&target, compiler_invocation_arguments);
compiler_invocation_arguments.push_back(ModuleImportBufferName);
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Thu Jan 22 12:25:49 2015
@@ -1419,7 +1419,7 @@ PlatformDarwin::GetSDKDirectoryForModule
}
void
-PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (std::vector<std::string> &options, SDKType sdk_type)
+PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std::vector<std::string> &options, SDKType sdk_type)
{
const std::vector<std::string> apple_arguments =
{
@@ -1435,28 +1435,67 @@ PlatformDarwin::AddClangModuleCompilatio
apple_arguments.end());
StreamString minimum_version_option;
- unsigned int major = 0, minor = 0, micro = 0;
- GetOSVersion(major, minor, micro);
- if (micro == UINT32_MAX)
- micro = 0; // FIXME who actually likes this behavior?
-
+ uint32_t versions[3] = { 0, 0, 0 };
+ bool use_current_os_version = false;
switch (sdk_type)
{
- case SDKType::iPhoneOS:
- minimum_version_option.PutCString("-mios-version-min=");
- minimum_version_option.PutCString(clang::VersionTuple(major, minor, micro).getAsString().c_str());
- break;
- case SDKType::iPhoneSimulator:
- minimum_version_option.PutCString("-mios-simulator-version-min=");
- minimum_version_option.PutCString(clang::VersionTuple(major, minor, micro).getAsString().c_str());
- break;
- case SDKType::MacOSX:
- minimum_version_option.PutCString("-mmacosx-version-min=");
- minimum_version_option.PutCString(clang::VersionTuple(major, minor, micro).getAsString().c_str());
+ case SDKType::iPhoneOS:
+#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
+ use_current_os_version = true;
+#else
+ use_current_os_version = false;
+#endif
+ break;
+
+ case SDKType::iPhoneSimulator:
+ use_current_os_version = false;
+ break;
+
+ case SDKType::MacOSX:
+#if defined (__i386__) || defined (__x86_64__)
+ use_current_os_version = true;
+#else
+ use_current_os_version = false;
+#endif
+ break;
}
-
- options.push_back(minimum_version_option.GetString());
-
+
+ if (use_current_os_version)
+ GetOSVersion(versions[0], versions[1], versions[2]);
+ else if (target)
+ {
+ // Our OS doesn't match our executable so we need to get the min OS version from the object file
+ ModuleSP exe_module_sp = target->GetExecutableModule();
+ if (exe_module_sp)
+ {
+ ObjectFile *object_file = exe_module_sp->GetObjectFile();
+ if (object_file)
+ object_file->GetMinimumOSVersion(versions, 3);
+ }
+ }
+ // Only add the version-min options if we got a version from somewhere
+ if (versions[0])
+ {
+ if (versions[2] == UINT32_MAX)
+ versions[2] = 0; // FIXME who actually likes this behavior?
+
+ switch (sdk_type)
+ {
+ case SDKType::iPhoneOS:
+ minimum_version_option.PutCString("-mios-version-min=");
+ minimum_version_option.PutCString(clang::VersionTuple(versions[0], versions[1], versions[2]).getAsString().c_str());
+ break;
+ case SDKType::iPhoneSimulator:
+ minimum_version_option.PutCString("-mios-simulator-version-min=");
+ minimum_version_option.PutCString(clang::VersionTuple(versions[0], versions[1], versions[2]).getAsString().c_str());
+ break;
+ case SDKType::MacOSX:
+ minimum_version_option.PutCString("-mmacosx-version-min=");
+ minimum_version_option.PutCString(clang::VersionTuple(versions[0], versions[1], versions[2]).getAsString().c_str());
+ }
+ options.push_back(minimum_version_option.GetString());
+ }
+
FileSpec sysroot_spec = GetSDKDirectoryForModules(sdk_type);
if (sysroot_spec.IsDirectory())
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Thu Jan 22 12:25:49 2015
@@ -130,7 +130,7 @@ protected:
GetSDKDirectoryForModules (PlatformDarwin::SDKType sdk_type);
void
- AddClangModuleCompilationOptionsForSDKType (std::vector<std::string> &options, SDKType sdk_type);
+ AddClangModuleCompilationOptionsForSDKType (lldb_private::Target *target, std::vector<std::string> &options, SDKType sdk_type);
std::string m_developer_directory;
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Thu Jan 22 12:25:49 2015
@@ -99,9 +99,9 @@ public:
GetSDKDirectory (lldb_private::Target &target) override;
void
- AddClangModuleCompilationOptions (std::vector<std::string> &options) override
+ AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
{
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(options, PlatformDarwin::SDKType::MacOSX);
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::MacOSX);
}
private:
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Thu Jan 22 12:25:49 2015
@@ -97,9 +97,9 @@ public:
lldb_private::ArchSpec &arch) override;
void
- AddClangModuleCompilationOptions (std::vector<std::string> &options) override
+ AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
{
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(options, PlatformDarwin::SDKType::iPhoneOS);
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneOS);
}
protected:
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h Thu Jan 22 12:25:49 2015
@@ -99,9 +99,9 @@ public:
lldb_private::ArchSpec &arch) override;
void
- AddClangModuleCompilationOptions (std::vector<std::string> &options) override
+ AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
{
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(options, PlatformDarwin::SDKType::iPhoneSimulator);
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneSimulator);
}
protected:
Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=226846&r1=226845&r2=226846&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Thu Jan 22 12:25:49 2015
@@ -463,7 +463,7 @@ Platform::GetOSKernelDescription (std::s
}
void
-Platform::AddClangModuleCompilationOptions (std::vector<std::string> &options)
+Platform::AddClangModuleCompilationOptions (Target *target, std::vector<std::string> &options)
{
std::vector<std::string> default_compilation_options =
{
More information about the lldb-commits
mailing list