From 60aaf83b1f4370b9d757fd12b274443153ca9008 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 29 Jul 2026 07:46:52 +0000 Subject: [PATCH 10/13] folly/Subprocess: avoid constructor priority with GCC on Darwin GCC rejects __attribute__((constructor(priority))) on Darwin because the platform linker does not support init priorities (gcc bug 119435). Use a plain constructor attribute there; Mach-O initializer order is link-order-based anyway. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013G8CDpEyDCCgV4jaMM9WME --- folly/Subprocess.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/folly/Subprocess.cpp b/folly/Subprocess.cpp index 43cb04206..50cc4a298 100644 --- a/folly/Subprocess.cpp +++ b/folly/Subprocess.cpp @@ -74,6 +74,15 @@ __attribute__((noinline, no_sanitize("address", "undefined", "thread"))) #endif +/// GCC on Darwin rejects constructor priorities since the platform linker +/// does not support them (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119435 +/// "Darwin: constructor priorities are not supported"). +#if defined(__APPLE__) && !defined(__clang__) +#define FOLLY_DETAIL_SUBPROCESS_CONSTRUCTOR __attribute__((constructor)) +#else +#define FOLLY_DETAIL_SUBPROCESS_CONSTRUCTOR __attribute__((constructor(101))) +#endif + constexpr int kExecFailure = 127; constexpr int kChildFailure = 126; @@ -178,7 +187,7 @@ struct subprocess_libc { FOLLY_DETAIL_SUBPROCESS_LIBC_X(FOLLY_DETAIL_SUBPROCESS_LIBC_FIELD_DEFN) -__attribute__((constructor(101))) static void subprocess_libc_init() { +FOLLY_DETAIL_SUBPROCESS_CONSTRUCTOR static void subprocess_libc_init() { auto handle = !kIsSanitize ? nullptr : ::dlopen(subprocess_libc_soname, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); -- 2.43.0