@@ -92,6 +92,15 @@ Status TargetList::CreateTargetInternal(
92
92
ArchSpec platform_arch (arch);
93
93
94
94
bool prefer_platform_arch = false ;
95
+ auto update_platform_arch = [&](const ArchSpec &module_arch) {
96
+ // If the OS or vendor weren't specified, then adopt the module's
97
+ // architecture so that the platform matching can be more accurate.
98
+ if (!platform_arch.TripleOSWasSpecified () ||
99
+ !platform_arch.TripleVendorWasSpecified ()) {
100
+ prefer_platform_arch = true ;
101
+ platform_arch = module_arch;
102
+ }
103
+ };
95
104
96
105
CommandInterpreter &interpreter = debugger.GetCommandInterpreter ();
97
106
@@ -134,12 +143,8 @@ Status TargetList::CreateTargetInternal(
134
143
matching_module_spec.GetArchitecture ())) {
135
144
// If the OS or vendor weren't specified, then adopt the module's
136
145
// architecture so that the platform matching can be more
137
- // accurate
138
- if (!platform_arch.TripleOSWasSpecified () ||
139
- !platform_arch.TripleVendorWasSpecified ()) {
140
- prefer_platform_arch = true ;
141
- platform_arch = matching_module_spec.GetArchitecture ();
142
- }
146
+ // accurate.
147
+ update_platform_arch (matching_module_spec.GetArchitecture ());
143
148
} else {
144
149
StreamString platform_arch_strm;
145
150
StreamString module_arch_strm;
@@ -162,16 +167,15 @@ Status TargetList::CreateTargetInternal(
162
167
}
163
168
} else {
164
169
if (arch.IsValid ()) {
170
+ // Fat binary. A (valid) architecture was specified.
165
171
module_spec.GetArchitecture () = arch;
166
172
if (module_specs.FindMatchingModuleSpec (module_spec,
167
173
matching_module_spec)) {
168
- prefer_platform_arch = true ;
169
- platform_arch = matching_module_spec.GetArchitecture ();
174
+ update_platform_arch (matching_module_spec.GetArchitecture ());
170
175
}
171
176
} else {
172
- // No architecture specified, check if there is only one platform for
173
- // all of the architectures.
174
-
177
+ // Fat binary. No architecture specified, check if there is
178
+ // only one platform for all of the architectures.
175
179
typedef std::vector<PlatformSP> PlatformList;
176
180
PlatformList platforms;
177
181
PlatformSP host_platform_sp = Platform::GetHostPlatform ();
@@ -263,7 +267,8 @@ Status TargetList::CreateTargetInternal(
263
267
// If we have a valid architecture, make sure the current platform is
264
268
// compatible with that architecture
265
269
if (!prefer_platform_arch && arch.IsValid ()) {
266
- if (!platform_sp->IsCompatibleArchitecture (arch, false , &platform_arch)) {
270
+ ArchSpec compatible_arch;
271
+ if (!platform_sp->IsCompatibleArchitecture (arch, false , &compatible_arch)) {
267
272
platform_sp = Platform::GetPlatformForArchitecture (arch, &platform_arch);
268
273
if (!is_dummy_target && platform_sp)
269
274
debugger.GetPlatformList ().SetSelectedPlatform (platform_sp);
0 commit comments