There’s no need to call posix_spawnp_setbinpref_np when we are launching in the shell. That only sets the architecture of the shell, we use “arch —arch” to actually pick the binary we actually want to launch’s architecture.

<rdar://problem/16103187>

llvm-svn: 201831
This commit is contained in:
Jim Ingham 2014-02-21 01:25:21 +00:00
parent f8cf1611e3
commit 90331d5cf4
1 changed files with 24 additions and 17 deletions

View File

@ -1743,25 +1743,32 @@ Host::LaunchProcessPosixSpawn (const char *exe_path, ProcessLaunchInfo &launch_i
// posix_spawnattr_setbinpref_np appears to be an Apple extension per:
// http://www.unix.com/man-page/OSX/3/posix_spawnattr_setbinpref_np/
#if defined (__APPLE__) && !defined (__arm__)
// We don't need to do this for ARM, and we really shouldn't now that we
// have multiple CPU subtypes and no posix_spawnattr call that allows us
// to set which CPU subtype to launch...
const ArchSpec &arch_spec = launch_info.GetArchitecture();
cpu_type_t cpu = arch_spec.GetMachOCPUType();
cpu_type_t sub = arch_spec.GetMachOCPUSubType();
if (cpu != 0 &&
cpu != UINT32_MAX &&
cpu != LLDB_INVALID_CPUTYPE &&
!(cpu == 0x01000007 && sub == 8)) // If haswell is specified, don't try to set the CPU type or we will fail
// Don't set the binpref if a shell was provided. After all, that's only going to affect what version of the shell
// is launched, not what fork of the binary is launched. We insert "arch --arch <ARCH> as part of the shell invocation
// to do that job on OSX.
if (launch_info.GetShell() == nullptr)
{
size_t ocount = 0;
error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
if (error.Fail() || log)
error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %llu )", cpu, (uint64_t)ocount);
// We don't need to do this for ARM, and we really shouldn't now that we
// have multiple CPU subtypes and no posix_spawnattr call that allows us
// to set which CPU subtype to launch...
const ArchSpec &arch_spec = launch_info.GetArchitecture();
cpu_type_t cpu = arch_spec.GetMachOCPUType();
cpu_type_t sub = arch_spec.GetMachOCPUSubType();
if (cpu != 0 &&
cpu != UINT32_MAX &&
cpu != LLDB_INVALID_CPUTYPE &&
!(cpu == 0x01000007 && sub == 8)) // If haswell is specified, don't try to set the CPU type or we will fail
{
size_t ocount = 0;
error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
if (error.Fail() || log)
error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %llu )", cpu, (uint64_t)ocount);
if (error.Fail() || ocount != 1)
return error;
if (error.Fail() || ocount != 1)
return error;
}
}
#endif