From 13ee00d0c95a4eede96ba9520146a01930af2a0a Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sat, 5 Dec 2020 14:05:54 -0800 Subject: [PATCH] [debugserver] Use dlsym for posix_spawnattr_setarchpref_np The @available check did not work as I thought it did. Use good old dlsym instead. --- lldb/tools/debugserver/source/MacOSX/MachProcess.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm index 232a0d2..386c5e4 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -3273,9 +3273,14 @@ pid_t MachProcess::PosixSpawnChildForPTraceDebugging( bool slice_preference_set = false; if (cpu_subtype != 0) { - if (@available(macOS 10.16, ios 10.14, watchos 7.0, tvos 14.0, *)) { - err.SetError(posix_spawnattr_setarchpref_np(&attr, 1, &cpu_type, - &cpu_subtype, &ocount)); + typedef int (*posix_spawnattr_setarchpref_np_t)( + posix_spawnattr_t *, size_t, cpu_type_t *, cpu_subtype_t *, size_t *); + posix_spawnattr_setarchpref_np_t posix_spawnattr_setarchpref_np_fn = + (posix_spawnattr_setarchpref_np_t)dlsym( + RTLD_DEFAULT, "posix_spawnattr_setarchpref_np"); + if (posix_spawnattr_setarchpref_np_fn) { + err.SetError((*posix_spawnattr_setarchpref_np)(&attr, 1, &cpu_type, + &cpu_subtype, &ocount)); slice_preference_set = err.Success(); if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS)) err.LogThreaded( -- 2.7.4