[PATCH] Use vague linkage for Java methods
Ranjit Mathew
rmathew@gmail.com
Tue Mar 8 05:05:00 GMT 2005
Hi Julian,
I'm not a Java maintainer, but please CC java-patches@gcc.gnu.org
on all Java patches.
Java has its own ChangeLog under "gcc/java" and therefore
the ChangeLog entry must be just for "decl.c".
The braces ("{}") seem stylistically redundant to me.
Lastly, please do verify Java patches against the Jacks
testsuite as well:
http://gcc.gnu.org/install/test.html#TOC2
[That link to Jacks is outdated BTW - you can find Jacks
as the "jacks" CVS module within Mauve
(http://sources.redhat.com/mauve/).]
Thanks,
Ranjit.
Julian Brown wrote:
> Hi,
>
> This patch causes Java methods to be output with once-only ("vague")
> linkage (so long as they are non-abstract, non-private and non-static,
> which seem like the right conditions, but I'd be prepared to believe
> aren't perfect). This helps when using CNI to interface with C++,
> especially on platforms with COMDAT groups.
>
> It allows my previous patch to work again:
>
> http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01624.html
>
> The problem was that gcjh-produced header files sometimes output full
> methods in simple cases, which are then put into COMDAT groups by the
> C++ front-end. Java methods are currently output with weak linkage due
> to the definition of MAKE_DECL_ONE_ONLY, so this works, apparently
> somewhat accidentally.
>
> If MAKE_DECL_ONE_ONLY is altered to not use weak linkage, multiple
> definitions occur when mixing Java with CNI code.
>
> This patch has been tested independently (with c,c++,java) on
> i686-pc-linux-gnu.
>
> ChangeLog:
>
> * gcc/java/decl.c (finish_method): Give methods once-only linkage.
>
>
> ------------------------------------------------------------------------
>
> Index: gcc/java/decl.c
> ===================================================================
> RCS file: /home/gcc/repos/gcc/gcc/gcc/java/decl.c,v
> retrieving revision 1.209
> diff -c -p -r1.209 decl.c
> *** gcc/java/decl.c 14 Feb 2005 14:58:22 -0000 1.209
> --- gcc/java/decl.c 6 Mar 2005 23:55:51 -0000
> *************** finish_method (tree fndecl)
> *** 2036,2041 ****
> --- 2036,2050 ----
> build2 (TRY_FINALLY_EXPR, void_type_node, *tp, exit));
> }
>
> + /* Ensure non-abstract non-static non-private members are defined only once
> + when linking. This is an issue when using CNI to interface with C++ object
> + files. */
> + if (! METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl)
> + && ! METHOD_ABSTRACT (fndecl))
> + {
> + make_decl_one_only (fndecl);
> + }
> +
> /* Prepend class initialization for static methods reachable from
> other classes. */
> if (METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl)
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/
More information about the Gcc-patches
mailing list