forked from OSchip/llvm-project
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.
llvm-svn: 226846
This commit is contained in:
parent
37c41c1d2c
commit
cd6bbba186
|
@ -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 ();
|
||||
|
|
|
@ -289,7 +289,7 @@ ClangModulesDeclVendor::Create(Target &target)
|
|||
"-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);
|
||||
|
||||
|
|
|
@ -1419,7 +1419,7 @@ PlatformDarwin::GetSDKDirectoryForModules (SDKType sdk_type)
|
|||
}
|
||||
|
||||
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::AddClangModuleCompilationOptionsForSDKType (std::vector<std::str
|
|||
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())
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -463,7 +463,7 @@ Platform::GetOSKernelDescription (std::string &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 =
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue