Skip to content

Commit 92706bb

Browse files
committed
[debugserver] Use dlsym for posix_spawnattr_setarchpref_np
The @available check did not work as I thought it did. Use good old dlsym instead. (cherry picked from commit 13ee00d)
1 parent 8b08377 commit 92706bb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,9 +3261,14 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
32613261
bool slice_preference_set = false;
32623262

32633263
if (cpu_subtype != 0) {
3264-
if (@available(macOS 10.16, ios 10.14, watchos 7.0, tvos 14.0, *)) {
3265-
err.SetError(posix_spawnattr_setarchpref_np(&attr, 1, &cpu_type,
3266-
&cpu_subtype, &ocount));
3264+
typedef int (*posix_spawnattr_setarchpref_np_t)(
3265+
posix_spawnattr_t *, size_t, cpu_type_t *, cpu_subtype_t *, size_t *);
3266+
posix_spawnattr_setarchpref_np_t posix_spawnattr_setarchpref_np_fn =
3267+
(posix_spawnattr_setarchpref_np_t)dlsym(
3268+
RTLD_DEFAULT, "posix_spawnattr_setarchpref_np");
3269+
if (posix_spawnattr_setarchpref_np_fn) {
3270+
err.SetError((*posix_spawnattr_setarchpref_np)(&attr, 1, &cpu_type,
3271+
&cpu_subtype, &ocount));
32673272
slice_preference_set = err.Success();
32683273
if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
32693274
err.LogThreaded(

0 commit comments

Comments
 (0)