Bug 58215

Summary: -fwhole-program cause gcj undefined reference to `Main::class$'
Product: gcc Reporter: Pekka Järveläinen <pj>
Component: javaAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P3    
Version: 4.8.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: test file to compile

Description Pekka Järveläinen 2013-08-22 08:36:48 UTC
Created attachment 30683 [details]
test file to compile

/v/linux212_x86_64/lang/gcc/4.8.1/bin/gcj  -pipe -Wall -O3 -fomit-frame-pointer  -ffast-math -fprefetch-loop-arrays -fwhole-program -march=core-avx-i -mavx -mtune=core-avx-i --main=nbody nbody.java -o nbody.gcj -lm
/tmp/ccmUUeIk.o: In function `main':
:(.text.startup+0x13): undefined reference to `nbody::class$'
collect2: error: ld returned 1 exit status
I tested also compiler version 4.8.0

without -fwhole-program it works.
Operating system is RHEL6.

By the way  ecj[1] was missing when ../gcc-4.8.1/configure --prefix=/v/linux212_x86_64/lang/gcc/4.8.1 --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --with-mpc=/v/linux212_x86_64/appl/math/mpc/latest

-v output:

 /v/linux212_x86_64/lang/gcc/4.8.1/bin/gcj -v  -pipe -Wall -O3 -fomit-frame-pointer -fwhole-program  -ffast-math -fprefetch-loop-arrays  -march=native --main=nbody nbody.java -o nbody.gcj -lmUsing built-in specs.
Reading specs from /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../libgcj.spec
rename spec startfile to startfileorig
rename spec lib to liborig
COLLECT_GCC=/v/linux212_x86_64/lang/gcc/4.8.1/bin/gcj
COLLECT_LTO_WRAPPER=/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.1/configure --prefix=/v/linux212_x86_64/lang/gcc/4.8.1 --enable-threads=posix --enable-checking=release --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --with-mpc=/v/linux212_x86_64/appl/math/mpc/latest
Thread model: posix
gcc version 4.8.1 (GCC) 
COLLECT_GCC_OPTIONS='-fsaw-java-file' '-v' '-pipe' '-Wall' '-O3' '-fomit-frame-pointer' '-fwhole-program' '-ffast-math' '-fprefetch-loop-arrays' '-march=native' '-o' 'nbody.gcj' '-fbootclasspath=./:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/../../share/java/libgcj-4.8.1.jar' '-specs=libgcj.spec' '-shared-libgcc'
 ecj1 nbody.java -Wall -fbootclasspath=./:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/../../share/java/libgcj-4.8.1.jar -fsource=1.5 -ftarget=1.5 -fzip-dependency /tmp/ccmrtjNR.zip -fzip-target /tmp/ccYW3BtZ.jar
COLLECT_GCC_OPTIONS='-fsaw-java-file' '-v' '-pipe' '-Wall' '-O3' '-fomit-frame-pointer' '-fwhole-program' '-ffast-math' '-fprefetch-loop-arrays' '-march=native' '-o' 'nbody.gcj' '-fbootclasspath=./:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/../../share/java/libgcj-4.8.1.jar' '-specs=libgcj.spec' '-shared-libgcc'
 /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/jc1 /tmp/ccYW3BtZ.jar -fsource-filename=nbody.java -fhash-synchronization -fno-use-divide-subroutine -fuse-boehm-gc -fnon-call-exceptions -fkeep-inline-functions -march=core2 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt --param l1-cache-size=0 --param l1-cache-line-size=0 --param l2-cache-size=3072 -mtune=core2 -quiet -dumpbase nbody.java -auxbase nbody -O3 -Wall -version -fsaw-java-file -fomit-frame-pointer -fwhole-program -ffast-math -fprefetch-loop-arrays -fbootclasspath=./:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/../../share/java/libgcj-4.8.1.jar -faux-classpath /tmp/ccmrtjNR.zip -o - |
 as -v --64 -o /tmp/ccP6jDJ8.o
GNU assembler version 2.20.51.0.2 (x86_64-redhat-linux) using BFD version version 2.20.51.0.2-5.36.el6 20100205
GNU Java (GCC) version 4.8.1 (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Java (GCC) version 4.8.1 (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Class path starts here:
    /tmp/ccmrtjNR.zip/ (zip)
    ./ (system)
    /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/../../share/java/libgcj-4.8.1.jar/ (system) (zip)
COLLECT_GCC_OPTIONS= '-v' '-pipe' '-Wall' '-O3' '-fomit-frame-pointer' '-fwhole-program' '-ffast-math' '-fprefetch-loop-arrays' '-march=native' '-o' 'nbody.gcj'  '-specs=libgcj.spec' '-shared-libgcc'
 /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/jvgenmain nbodymain |
 /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/cc1 -march=core2 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt --param l1-cache-size=0 --param l1-cache-line-size=0 --param l2-cache-size=3072 -mtune=core2 -quiet -dumpbase nbodymain.c -O3 -version -fomit-frame-pointer -fwhole-program -ffast-math -fprefetch-loop-arrays -fdollars-in-identifiers -o - |
 as -v --64 -o /tmp/cc8AWOmi.o
GNU C (GCC) version 4.8.1 (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU assembler version 2.20.51.0.2 (x86_64-redhat-linux) using BFD version version 2.20.51.0.2-5.36.el6 20100205
GNU C (GCC) version 4.8.1 (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6e97cfc87a38e5c5b2ec8fc9619970a7
COMPILER_PATH=/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../libexec/gcc/
LIBRARY_PATH=/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS= '-v' '-pipe' '-Wall' '-O3' '-fomit-frame-pointer' '-fwhole-program' '-ffast-math' '-fprefetch-loop-arrays' '-march=native' '-o' 'nbody.gcj'  '-specs=libgcj.spec' '-shared-libgcc'
 /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o nbody.gcj /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/crtbegin.o -L/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1 -L/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc -L/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../.. /tmp/cc8AWOmi.o /tmp/ccP6jDJ8.o -lm -lgcc_s -lgcc -lgcj -lm -lpthread -lrt -ldl -lgcc_s -lgcc -lc -lgcc_s -lgcc /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/crtfastmath.o /fs/appl/linux/linux212_x86_64/lang/gcc/4.8.1/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/crtend.o /usr/lib/../lib64/crtn.o
/tmp/cc8AWOmi.o: In function `main':
:(.text.startup+0x13): undefined reference to `nbody::class$'
collect2: error: ld returned 1 exit status
Comment 1 Andrew Pinski 2016-09-30 22:52:15 UTC
Closing as won't fix as the Java front-end has been removed from the trunk.