This is the mail archive of the
mailing list for the GCC project.
I need help for changing the java driver (gcj and libs with a main())
- To: gcc at gcc dot gnu dot org
- Subject: I need help for changing the java driver (gcj and libs with a main())
- From: Martin Kahlert <martin dot kahlert at infineon dot com>
- Date: Mon, 7 May 2001 15:13:32 +0200
- Cc: java at gcc dot gnu dot org
- Reply-To: martin dot kahlert at infineon dot com
I am trying to solve the following problem:
You can tell gcj, which java class contains the main function that
should serve as the executable's main.
The corresponding function is generated by an executable named
jvgenmain during java's lang_specific_pre_link() function.
In gcc.c lang_specific_pre_link() is called *after* all input files were
a) processed by their compilers or
b) the argument (e.g. a library on the command line) was copied for the
This is o.k. as long as i do not specify any library, which has a main
function inside it.
If i use for example the command line
gcj -o hello hello.java --main=hello -lg2c,
the linker gets (translated to readable):
collect2 [a lot of stuff] hello.o -lg2c generated_main.o [a lot other stuff]
libg2c contains a main function, which calls something like __MAIN__.
and thus the linker will see it before the correct main routine from our code.
There are some possibilities to solve this:
a) sort all libraries to the end of the argument list in gcc.c (could have bad
side effects to other languages - i do not know)
b) do something similar like Fortran: put a main() into libgcj and call the generated
__MAIN__JAVA__ (which one will win if i do the above gcj command???)
c) Put lang_specific_pre_link at the beginning of the argument processing in
gcc.c, so the generated_main.o will become outfiles
d) Define another function (which has to be provided by all languages) which
generates additional object files (not libraries) and call that early in
gcc.c before the libs have a chance to show up.
I would be glad to hear some ideas from you gurus, since i am very new to
coding for gcc.
Thanks a lot,
The early bird gets the worm. If you want something else for
breakfast, get up later.