Patch: Fix for PR 2369
Bryce McKinlay
bryce@waitaki.otago.ac.nz
Thu Nov 15 07:14:00 GMT 2001
Per Bothner wrote:
> That would make us different from javac, which allows many classes to
> have
> a 'main' methods, and where which one is chosen is done at run-time,
> rather
> than compilation time. In our case we pick link time to choose the
> desired
> main.
>
> This is mainly an issue when compiling a whole bunch of classes into a
> .so,
> and where the .so has multiple entry points.
I don't think this would effect .so compilation. The driver would pass
the -fmain option to gcj in basically the same situations that it
presently invokes jvgenmain and cc1 to do it (ie when linking an
executable). If someone did "gcj Foo.o Bar.o" it would run jc1
exclusivly to find main and generate the C main.
> > It would also be nice if gcj would automatically find a "main" when
> no --main option is given.
>
> I agree. But it is a non-trivial. You might be linking in a C/C++
> driver that contains a 'main' (and uses the invocation interface).
> I could see: If no --main is specified, and there is no 'main'
> (C-style) entry-point, look for Java main methods. It could look
> for the first match, or it could require there only be a single match,
> but give preference to non-libraries.
If a C/C++ entry point is used then its reasonable to use "gcc" or "c++"
to link rather than gcj, or alternativly we could also provide a
"--no-main" option.
regards
Bryce.
More information about the Gcc-patches
mailing list