OS X doesn't support constructor priorities
authorJosh Watzman <jwatzman@fb.com>
Thu, 7 May 2015 16:42:01 +0000 (09:42 -0700)
committerPraveen Kumar Ramakrishnan <praveenr@fb.com>
Tue, 12 May 2015 00:02:26 +0000 (17:02 -0700)
Summary:
OS X doesn't support constructor init priorities, at all. AIUI,
it's a limitation of their actual binary format and loader, not just a
tooling/compiler limitation.

This particular usage appears to just be for for logging/bug-finding
purposes, so it looks like just removing the priority on OS X isn't the
end of the world?

Test Plan: g++-4.9 on OS X compiles this file now.

Reviewed By: njormrod@fb.com

Subscribers: ldbrandy, jdelong, folly-diffs@, yfeldblum, chalfant

FB internal diff: D2040557

Signature: t1:2040557:1430975025:73f817b5d19a18dca6b19ba783dbea99192cbc41

folly/Singleton.cpp

index bfd63e57ceb99b7c8c4d8039cf1016325c63f40e..d389f6efaf57d5b11b252a8f854ee1563a1a359e 100644 (file)
@@ -45,7 +45,12 @@ struct FatalHelper {
   std::vector<detail::TypeDescriptor> leakedSingletons_;
 };
 
+#ifdef __APPLE__
+// OS X doesn't support constructor priorities.
+FatalHelper fatalHelper;
+#else
 FatalHelper __attribute__ ((__init_priority__ (101))) fatalHelper;
+#endif
 
 }