This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

I need help for changing the java driver (gcj and libs with a main())


Hi!
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
   linking step.

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[0]
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,
Martin.

-- 
The early bird gets the worm. If you want something else for       
breakfast, get up later.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]