Hi,
another very old thread that I can now revive a bit... also full quoted to spur your memory :-)
On Thu, Jul 06, 2006 at 07:32:31PM +0200, Frank Heckenbach wrote:
Waldek Hebisch wrote:
Frank Heckenbach wrote:
Waldek Hebisch wrote:
The driver passes options to collect2 via environment (see `set_collect_gcc_options' in `gpc.c'). The problem is that the driver does not remove options which are invalid for C compiler. In principle other languages should have the same problem, I wonder how (if???) they handle it.
Do you know what collect2 has to compile here at all? Perhaps other languages don't need to, and perhaps we can avoid it as well ...
I do not know more details, all I know is just from quick scan trough collect2 sources. Perhaps we should ask on gcc list?
Can you (Gert) check what it does? Perhaps catch the input file to collect2 and send it to us?
Frank
Actually the input file is not overly helpful, as it really only is the output of "as" - a plain .o file. But collect2 creates a C file on its own (!) and links that.
Digging through the code, I found an option ("-debug") that will make collect2 really verbose, and it will show what programs it calls, and what it does.
Looking at the output (appended below in all its glory) it seems that collect2 seems to collect some "constructor" stuff, builds a C program from that, and calls gcc to compile this. Actually, it prints that it has "0 constructors", but "10 frame tables"...
I do not have the slightest idea why it would want to do so, or whether this is unavoidable... - but you can nicely see the compiler invocation with the "wrong" flags.
The "... is valid for Pascal but not for C" line is coming from opts.c in gcc, function complain_wrong_lang().
So, here we go. "h2.pas" is a simple "hello, world" program:
---- snip ---- program h2;
begin writeln( 'world 2' ); end. ---- snap ----
gd@hilb31:/tmp> gpc -Wl,-debug -v -fno-unit-path -save-temps -o h2 h2.pas
Reading specs from /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/specs Configured with: ../gcc-3.4.6/configure --prefix=/gnu/gpc --enable-languages=pascal Thread model: aix gpc version 20060325, based on gcc-3.4.6 /gnu_61/gpc/bin/../libexec/gcc/rs6000-ibm-aix/3.4.6/gpc1 -E -quiet -v -iprefix /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/ h2.pas -famtmpfile=/tmp//ccCRckKT.gpa -fno-unit-path -o h2.i GNU Pascal Compiler PreProcessor version 20060325, based on gcc-3.4.6 /gnu_61/gpc/bin/../libexec/gcc/rs6000-ibm-aix/3.4.6/gpc1 -fpreprocessed h2.i -quiet -dumpbase h2.pas -auxbase h2 -famtmpfile=/tmp//ccCRckKT.gpa -fno-unit-path -version -o h2.s GNU Pascal version 20060325, based on gcc-3.4.6 (rs6000-ibm-aix) compiled by GNU C version 4.2.0. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 as -u -mppc -o h2.o h2.s /gnu_61/gpc/bin/../libexec/gcc/rs6000-ibm-aix/3.4.6/collect2 -bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect -o h2 /lib/crt0.o -L/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6 -L/gnu_61/gpc/bin/../lib/gcc -L/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6 -L/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../.. -L/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../.. -debug h2.o -lgpc -lm /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc.a /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc_eh.a -lc /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc.a /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc_eh.a Convert string '/gnu_61/gpc/bin/../libexec/gcc/rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../libexec/gcc/:/gnu/gpc/libexec/gcc/rs6000-ibm-aix/3.4.6/:/gnu/gpc/libexec/gcc/rs6000-ibm-aix/3.4.6/:/gnu/gpc/libexec/gcc/rs6000-ibm-aix/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/:/usr/libexec/gcc/rs6000-ibm-aix/3.4.6/:/usr/libexec/gcc/rs6000-ibm-aix/:/usr/lib/gcc/rs6000-ibm-aix/3.4.6/:/usr/lib/gcc/rs6000-ibm-aix/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/rs6000-ibm-aix/3.4.6/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/' into prefixes, separator = ':' - add prefix: /gnu_61/gpc/bin/../libexec/gcc/rs6000-ibm-aix/3.4.6/ - add prefix: /gnu_61/gpc/bin/../libexec/gcc/ - add prefix: /gnu/gpc/libexec/gcc/rs6000-ibm-aix/3.4.6/ - add prefix: /gnu/gpc/libexec/gcc/rs6000-ibm-aix/3.4.6/ - add prefix: /gnu/gpc/libexec/gcc/rs6000-ibm-aix/ - add prefix: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/ - add prefix: /gnu/gpc/lib/gcc/rs6000-ibm-aix/ - add prefix: /usr/libexec/gcc/rs6000-ibm-aix/3.4.6/ - add prefix: /usr/libexec/gcc/rs6000-ibm-aix/ - add prefix: /usr/lib/gcc/rs6000-ibm-aix/3.4.6/ - add prefix: /usr/lib/gcc/rs6000-ibm-aix/ - add prefix: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/rs6000-ibm-aix/3.4.6/ - add prefix: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/ - add prefix: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/rs6000-ibm-aix/3.4.6/ - add prefix: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/ Convert string '/bin:.:/local/bin:/medat/bin:/usr/linux/bin:/usr/local/bin:/gnu/bin:/gnulocal/bin:/usr/vac/bin:/opt/freeware/bin:/usr/bin:/etc:/usr/sbin:/usr/bin/X11:/sbin:/usr/java/jre/bin:/usr/java/bin:/medat/modem/bin:/ora/app/oracle/product/11.1.0/bin:/home/dba/bin:/ora/medat/bin:/gnulocal/bin:/home/gd/bin' into prefixes, separator = ':' - add prefix: /bin/ - add prefix: ./ - add prefix: /local/bin/ - add prefix: /medat/bin/ - add prefix: /usr/linux/bin/ - add prefix: /usr/local/bin/ - add prefix: /gnu/bin/ - add prefix: /gnulocal/bin/ - add prefix: /usr/vac/bin/ - add prefix: /opt/freeware/bin/ - add prefix: /usr/bin/ - add prefix: /etc/ - add prefix: /usr/sbin/ - add prefix: /usr/bin/X11/ - add prefix: /sbin/ - add prefix: /usr/java/jre/bin/ - add prefix: /usr/java/bin/ - add prefix: /medat/modem/bin/ - add prefix: /ora/app/oracle/product/11.1.0/bin/ - add prefix: /home/dba/bin/ - add prefix: /ora/medat/bin/ - add prefix: /gnulocal/bin/ - add prefix: /home/gd/bin/ Looking for 'real-ld' Looking for 'collect-ld' Looking for 'ld' Looking for 'ld' Looking for '/usr/ucb/nm' - failed to locate using absolute path Looking for 'gnm' Looking for 'gnm' Looking for 'nm' Looking for 'nm' Looking for 'gstrip' Looking for 'gstrip' Looking for 'strip' Looking for 'strip' Looking for 'gpc' Looking for 'gpc' Convert string '/gnu/lib:/gnu/samba/lib:/corba/v158/ACE_wrappers/lib' into prefixes, separator = ':' - add prefix: /gnu/lib/ - add prefix: /gnu/samba/lib/ - add prefix: /corba/v158/ACE_wrappers/lib/ searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgpc.a found: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgpc.a searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libm.a searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libm.so searching for: /gnu_61/gpc/bin/../lib/gcc/libm.a searching for: /gnu_61/gpc/bin/../lib/gcc/libm.so searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/libm.a searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/libm.so searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../libm.a searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../libm.so searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../libm.a searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../libm.so searching for: /gnu/lib/libm.a searching for: /gnu/lib/libm.so searching for: /gnu/samba/lib/libm.a searching for: /gnu/samba/lib/libm.so searching for: /corba/v158/ACE_wrappers/lib/libm.a searching for: /corba/v158/ACE_wrappers/lib/libm.so searching for: /lib/libm.a found: /lib/libm.a searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libc.a searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libc.so searching for: /gnu_61/gpc/bin/../lib/gcc/libc.a searching for: /gnu_61/gpc/bin/../lib/gcc/libc.so searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/libc.a searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/libc.so searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../libc.a searching for: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../libc.so searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../libc.a searching for: /gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../libc.so searching for: /gnu/lib/libc.a searching for: /gnu/lib/libc.so searching for: /gnu/samba/lib/libc.a searching for: /gnu/samba/lib/libc.so searching for: /corba/v158/ACE_wrappers/lib/libc.a searching for: /corba/v158/ACE_wrappers/lib/libc.so searching for: /lib/libc.a found: /lib/libc.a List of libraries: /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgpc.a, /lib/libm.a, /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc.a, /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc_eh.a, /lib/libc.a, sec=2 class=2 type=0 _GLOBAL__F___divdi3 sec=2 class=2 type=0 _GLOBAL__F___moddi3 sec=2 class=2 type=0 _GLOBAL__F___udivdi3 sec=2 class=2 type=0 _GLOBAL__F___umoddi3 sec=2 class=2 type=0 _GLOBAL__F___udiv_w_sdiv sec=2 class=2 type=0 _GLOBAL__F___udivmoddi4 sec=2 class=2 type=0 _GLOBAL__F__Unwind_GetGR sec=2 class=2 type=0 _GLOBAL__F___register_frame_info_bases sec=2 class=2 type=0 _GLOBAL__F___gnat_default_lock sec=2 class=2 type=0 _GLOBAL__F___gcc_personality_v0 collect2 version 3.4.6 ld_file_name = /bin/ld c_file_name = /gnu/bin/gpc nm_file_name = /bin/nm strip_file_name = /bin/strip c_file = /tmp//ccGqyPUX.c o_file = /tmp//ccqwtITO.o COLLECT_GCC_OPTIONS = '-famtmpfile=/tmp//ccCRckKT.gpa' '-v' '-fno-unit-path' '-save-temps' '-o' 'h2' COLLECT_GCC = gpc COMPILER_PATH = /gnu_61/gpc/bin/../libexec/gcc/rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../libexec/gcc/:/gnu/gpc/libexec/gcc/rs6000-ibm-aix/3.4.6/:/gnu/gpc/libexec/gcc/rs6000-ibm-aix/3.4.6/:/gnu/gpc/libexec/gcc/rs6000-ibm-aix/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/:/usr/libexec/gcc/rs6000-ibm-aix/3.4.6/:/usr/libexec/gcc/rs6000-ibm-aix/:/usr/lib/gcc/rs6000-ibm-aix/3.4.6/:/usr/lib/gcc/rs6000-ibm-aix/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/rs6000-ibm-aix/3.4.6/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/bin/ LIBRARY_PATH = /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../lib/gcc/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/:/usr/lib/gcc/rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/lib/rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/lib/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/lib/rs6000-ibm-aix/3.4.6/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../../rs6000-ibm-aix/lib/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../rs6000-ibm-aix/3.4.6/:/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../../:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../rs6000-ibm-aix/3.4.6/:/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../../:/lib/rs6000-ibm-aix/3.4.6/:/lib/:/usr/lib/rs6000-ibm-aix/3.4.6/:/usr/lib/
0 constructor(s) found 0 destructor(s) found 10 frame table(s) found [Leaving h2]
write_c_file - output name is h2, prefix is h2
========== output_file = h2, c_file = /tmp//ccGqyPUX.c #ifdef __cplusplus extern "C" { #endif
write_c_file - output name is h2, prefix is h2 static int count; typedef void entry_pt(); extern void *x6 __asm__ ("_GLOBAL__F___divdi3"); extern void *x7 __asm__ ("_GLOBAL__F___moddi3"); extern void *x8 __asm__ ("_GLOBAL__F___udivdi3"); extern void *x9 __asm__ ("_GLOBAL__F___umoddi3"); extern void *x10 __asm__ ("_GLOBAL__F___udiv_w_sdiv"); extern void *x11 __asm__ ("_GLOBAL__F___udivmoddi4"); extern void *x12 __asm__ ("_GLOBAL__F__Unwind_GetGR"); extern void *x13 __asm__ ("_GLOBAL__F___register_frame_info_bases"); extern void *x14 __asm__ ("_GLOBAL__F___gnat_default_lock"); extern void *x15 __asm__ ("_GLOBAL__F___gcc_personality_v0"); static void *frame_table[] = { &x6, &x7, &x8, &x9, &x10, &x11, &x12, &x13, &x14, &x15, 0 }; struct object { void *pc_begin; void *pc_end; void *fde_begin; void *fde_array; __SIZE_TYPE__ count; struct object *next; }; extern void __register_frame_info_table (void *, struct object *); extern void *__deregister_frame_info (void *); static void reg_frame () { static struct object ob; __register_frame_info_table (frame_table, &ob); } static void dereg_frame () { __deregister_frame_info (frame_table); } void _GLOBAL__FI_h2() { static entry_pt *ctors[] = { reg_frame, }; entry_pt **p; if (count++ != 0) return; p = ctors + 1; while (p > ctors) (*--p)(); } void _GLOBAL__FD_h2() { static entry_pt *dtors[] = { dereg_frame, }; entry_pt **p; if (--count != 0) return; p = dtors; while (p < dtors + 1) (*p++)(); } #ifdef __cplusplus } #endif ========== end of c_file
========== export_file = /tmp//ccsRlM3F.x ========== end of export_file
/gnu/bin/gpc -x c -c -o /tmp//ccqwtITO.o -famtmpfile=/tmp//ccCRckKT.gpa -fno-unit-path -fno-profile-arcs -fno-test-coverage -fno-branch-probabilities -fno-exceptions -w /tmp//ccGqyPUX.c cc1: warning: command line option "-fno-unit-path" is valid for Pascal but not for C /bin/ld -bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect -o h2 /lib/crt0.o /tmp//ccqwtITO.o -L/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6 -L/gnu_61/gpc/bin/../lib/gcc -L/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6 -L/gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/../../.. -L/gnu/gpc/lib/gcc/rs6000-ibm-aix/3.4.6/../../.. h2.o -lgpc -lm /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc.a /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc_eh.a -lc /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc.a /gnu_61/gpc/bin/../lib/gcc/rs6000-ibm-aix/3.4.6/libgcc_eh.a -binitfini:_GLOBAL__FI_h2:_GLOBAL__FD_h2 [Leaving /tmp//ccGqyPUX.c] [Leaving /tmp//ccqwtITO.o] [Leaving /tmp//ccsRlM3F.x]