From be419a8edc10bc8a6b21bac0efc7ac9a0d88107b Mon Sep 17 00:00:00 2001 From: Josh Watzman Date: Wed, 13 Aug 2014 15:05:12 -0700 Subject: [PATCH] Remove constructor version attribute on OS X Summary: OS X doesn't support this -- it requires support at the linker level which OS X just doesn't have. Reasonable OS X compilers will yell about it, but even the ones that don't are just silently dropping it on the floor. So I'm not sure what //we// can do other than just silently dropping this on the floor too and hoping that everything works. Test Plan: HHVM build on OS X gets ever so slightly further (runs into other issues). HHVM build in fbcode still seems to build folly okay (didn't wait for it to finish fully). Fixes https://github.com/facebook/folly/issues/78 Reviewed By: tudorb@fb.com FB internal diff: D1487191 Blame Revision: rFBCODE502be7cb0fda306ddc33b9c5ad7a53b0cfbdc893 --- folly/VersionCheck.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/folly/VersionCheck.h b/folly/VersionCheck.h index a15675d7..2eda84d0 100644 --- a/folly/VersionCheck.h +++ b/folly/VersionCheck.h @@ -67,6 +67,14 @@ * * ... and then commpile your file with -DMYLIB_VERSION=\"1\" */ + +#ifdef __APPLE__ +// OS X doesn't support constructor priorities. Just pray it works, I guess. +#define FOLLY_VERSION_CHECK_PRIORITY __attribute__((constructor)) +#else +#define FOLLY_VERSION_CHECK_PRIORITY __attribute__((constructor(101))) +#endif + // Note that this is carefully crafted: PRODUCT##Version must have external // linkage (so it collides among versions), versionCheck must have internal // linkage (so it does NOT collide between versions); if we're trying to have @@ -75,7 +83,7 @@ #define FOLLY_VERSION_CHECK(PRODUCT, VERSION) \ const char* PRODUCT##Version = VERSION; \ namespace { \ - __attribute__((constructor(101))) void versionCheck() { \ + FOLLY_VERSION_CHECK_PRIORITY void versionCheck() { \ if (strcmp(PRODUCT##Version, VERSION)) { \ fprintf(stderr, \ "Invalid %s version: desired [%s], currently loaded [%s]\n", \ -- 2.34.1