Re: [pcre-dev] [Bug 664] ABI breakage in PCRE 7.6

Top Page
Delete this message
Author: Craig Silverstein
Date:  
To: 664, ph10
CC: pcre-dev, iant
Subject: Re: [pcre-dev] [Bug 664] ABI breakage in PCRE 7.6
Attached below is the patch to make __USER_LABEL_PREFIX__ compile
correctly. This does not solve the "alias definitions are not
supported in Mach-O" warning, but at least it lets the code compile
better.

We still get, in leopard, this error:
pcrecpp.cc:79: error: 'pcrecpp::no_arg' aliased to undefined symbol '__ZN7pcrecpp2RE6no_argE'

This seems to be a bug in gcc 4.0.1; at least, I don't see the error
when compiling with gcc 4.0.3. Reports on the web indicate it works
fine with gcc 3 as well.

I don't quite know how to proceed. I think we may have to either give
up on backwards-ABI-compatibility for leopard (and any other mac
system that uses gcc 4.0.1), or else revert this patch and go back to
having the windows problem.

craig

--cut here--

Index: pcrecpp.cc
===================================================================
--- pcrecpp.cc    (revision 328)
+++ pcrecpp.cc    (working copy)
@@ -64,18 +64,21 @@
 // only the __attribute__ syntax, but also __USER_LABEL_PREFIX__, are
 // gnu-specific.)
 #if defined(__GNUC__) && __GNUC__ >= 3
-#if defined(__ELF__)
+# define AS_STRING(x)   AS_STRING_INTERNAL(x)
+# define AS_STRING_INTERNAL(x)   #x
+# define USER_LABEL_PREFIX  AS_STRING(__USER_LABEL_PREFIX__)
+# if defined(__ELF__)
 extern Arg no_arg
-  __attribute__((alias(__USER_LABEL_PREFIX__ "_ZN7pcrecpp2RE6no_argE")));
-#else
+  __attribute__((alias(USER_LABEL_PREFIX "_ZN7pcrecpp2RE6no_argE")));
+# else
 // While we know elf supports strong aliases, not all formats do (Mach
 // doesn't, for instance).  So make aliases weak by default.  This is
 // a smidge less safe in theory (conceivably, someone could override
 // this symbol in their own binary), but perfectly ok in practice.
 extern Arg no_arg
-  __attribute__((weak, alias(__USER_LABEL_PREFIX__ "_ZN7pcrecpp2RE6no_argE")));
+  __attribute__((weak, alias(USER_LABEL_PREFIX "_ZN7pcrecpp2RE6no_argE")));
+# endif
 #endif
-#endif


// If a regular expression has no error, its error_ field points here
static const string empty_string;