@@ -2909,20 +2909,32 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2909
2909
return exe_module_sp->GetArchitecture ().GetTriple ();
2910
2910
};
2911
2911
2912
+ ArchSpec active_arch;
2913
+ llvm::Triple active_triple;
2914
+ if (sc.module_sp ) {
2915
+ active_arch = sc.module_sp ->GetArchitecture ();
2916
+ active_triple = active_arch.GetTriple ();
2917
+ }
2918
+
2919
+ // When no module triple, fallback to the target triple.
2920
+ if (!active_arch || active_triple == llvm::Triple ()) {
2921
+ active_arch = target.GetArchitecture ();
2922
+ active_triple = active_arch.GetTriple ();
2923
+ }
2924
+
2912
2925
llvm::Triple computed_triple;
2913
- llvm::Triple target_triple = target.GetArchitecture ().GetTriple ();
2914
2926
2915
- if (target. GetArchitecture () .IsFullySpecifiedTriple ()) {
2927
+ if (active_arch .IsFullySpecifiedTriple ()) {
2916
2928
// If a fully specified triple was passed in, for example
2917
2929
// through CreateTargetWithFileAndTargetTriple(), prefer that.
2918
2930
LOG_PRINTF (GetLog (LLDBLog::Types), " Fully specified target triple %s." ,
2919
- target_triple .str ().c_str ());
2920
- computed_triple = target_triple ;
2931
+ active_triple .str ().c_str ());
2932
+ computed_triple = active_arch. GetTriple () ;
2921
2933
} else {
2922
2934
// Underspecified means that one or more of vendor, os, or os
2923
2935
// version (Darwin only) is missing.
2924
2936
LOG_PRINTF (GetLog (LLDBLog::Types), " Underspecified target triple %s." ,
2925
- target_triple .str ().c_str ());
2937
+ active_triple .str ().c_str ());
2926
2938
llvm::VersionTuple platform_version;
2927
2939
PlatformSP platform_sp (target.GetPlatform ());
2928
2940
if (platform_sp)
@@ -2940,15 +2952,15 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2940
2952
// plaform (e.g., ios-macabi runs on the macOS, but uses iOS
2941
2953
// version numbers).
2942
2954
if (!platform_version.empty () &&
2943
- target_triple .getEnvironment () == llvm::Triple::UnknownEnvironment) {
2955
+ active_triple .getEnvironment () == llvm::Triple::UnknownEnvironment) {
2944
2956
LOG_PRINTF (GetLog (LLDBLog::Types), " Completing triple based on platform." );
2945
2957
2946
2958
llvm::SmallString<32 > buffer;
2947
2959
{
2948
2960
llvm::raw_svector_ostream os (buffer);
2949
- os << target_triple .getArchName () << ' -' ;
2950
- os << target_triple .getVendorName () << ' -' ;
2951
- os << llvm::Triple::getOSTypeName (target_triple .getOS ());
2961
+ os << active_triple .getArchName () << ' -' ;
2962
+ os << active_triple .getVendorName () << ' -' ;
2963
+ os << llvm::Triple::getOSTypeName (active_triple .getOS ());
2952
2964
os << platform_version.getAsString ();
2953
2965
}
2954
2966
computed_triple = llvm::Triple (buffer);
0 commit comments