Define JNIEXPORT as visibility default with GCC?
martinrb at google.com
Wed Feb 13 17:14:40 PST 2013
This seems like an obvious improvement.
There are already bunches of places in the jdk sources that do things like:
#if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE)
#if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) &&
(__GNUC_MINOR__ > 2)
#define JNIEXPORT __attribute__((visibility("default")))
#define JNIIMPORT __attribute__((visibility("default")))
This is *crazy*. The visibility feature has nothing to do with x86, or
SOLARIS, or LINUX, or BSD.
JNIEXPORT should be defined to __attribute__((visibility("default")))
#if #and #only #if:
defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ >
and that change should simply be made to the public exported jdk jni headers
On Mon, Feb 11, 2013 at 10:26 AM, Jeremy Manson <jeremymanson at google.com>wrote:
> Hi folks,
> Pardon if this has come up before; a quick search didn't indicate
> anything, but the mailing list archives are kind of hard to search.
> I wonder if it makes sense to define JNIEXPORT as meaning __attribute__
> ((visibility ("default"))) when compiling with gcc. Currently, anyone
> building JNI code with -fvisibility=hidden and a stock Oracle JDK is at a
> loss: their JNI exports will be hidden along with everything else.
> I notice that both IcedTea and OS X have made this change independently,
> and it has been added to Hotspot's JNIEXPORT definition (so HS can be built
> with -fvisibility=hidden), but the change isn't present in the latest JDK8
> The workaround is pretty ugly: people who want to use -fvisibility=hidden
> have to redefine JNIEXPORT. Upstream, it would be a pretty simple change
> to jni_md.h, along the lines of:
> #if defined(__GNUC__) && __GNUC__ >= 4
> #define JNIEXPORT __attribute__ ((visibility ("default")))
> #define JNIEXPORT
> Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-runtime-dev