Bug 56706 - [4.8 Regression] failure building CP2K at -flto -O2
Summary: [4.8 Regression] failure building CP2K at -flto -O2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 59154
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-24 09:14 UTC by Joost VandeVondele
Modified: 2015-06-23 08:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.7.2, 4.9.0
Known to fail: 4.8.3, 4.8.5
Last reconfirmed: 2014-03-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2013-03-24 09:14:00 UTC
The 4.8.1 branch fails to build CP2K in LTO mode. At linking, the following error message appears:

/data/vjoost/clean/cp2k/cp2k/makefiles/../src/dbcsr_lib/dbcsr_blas_operations.F:64: error: undefined reference to 'iseed.2556.979179.13933'
/data/vjoost/clean/cp2k/cp2k/makefiles/../src/dbcsr_lib/dbcsr_blas_operations.F:62: error: undefined reference to 'iseed.2556.979179.13933'
/data/vjoost/clean/cp2k/cp2k/makefiles/../src/dbcsr_lib/dbcsr_blas_operations.F:58: error: undefined reference to 'iseed.2556.979179.13933'
/data/vjoost/clean/cp2k/cp2k/makefiles/../src/dbcsr_lib/dbcsr_blas_operations.F:60: error: undefined reference to 'iseed.2556.979179.13933'
collect2: error: ld returned 1 exit status

The error is absent if the optimization options used are -flto -O1 instead of -flto -O2.

I have not been able to reduce this to a small testcase, so I'll post as simple as possible build instructions in a next comment
Comment 1 Joost VandeVondele 2013-03-24 09:26:30 UTC
Get trunk CP2K and build with lto (note, this requires checking=release, PR45586) and a couple of minutes on a larger machine.

svn co  svn://svn.code.sf.net/p/cp2k/code/trunk/cp2k cp2k
cd cp2k/makefiles/
cat ../arch/lto.sopt # and check all is appropriate (note blas/lapack linking)
make -j48 ARCH=lto VERSION=sopt


starting a fresh build goes with
make -j48 ARCH=lto VERSION=sopt realclean
Comment 2 Joost VandeVondele 2013-03-24 09:31:04 UTC
The failure is absent on the 4.7 branch
Comment 3 Jakub Jelinek 2013-05-31 10:58:22 UTC
GCC 4.8.1 has been released.
Comment 4 Jakub Jelinek 2013-10-16 09:50:20 UTC
GCC 4.8.2 has been released.
Comment 5 Joost VandeVondele 2013-10-20 15:12:06 UTC
Jan, could you look into this LTO failure, or suggest how I can help to get this fixed ? 

The problem seems to be related to iseed, an argument to dbcsr_lapack_larnv in dbcsr_lib/dbcsr_blas_operations.F. This function is only called from dbcsr_make_random_matrix, where iseed is defined as a local SAVE'd variable. I think that none of the callers of dbcsr_make_random_matrix ends up in the binary, so I expect dbcsr_make_random_matrix is removed by LTO, but somehow the reference to iseed remains, leading to linking errors.
Comment 6 Richard Biener 2013-10-25 12:24:54 UTC
I understand that both the 4.8 branch and trunk fail?
Comment 7 Joost VandeVondele 2013-10-25 16:17:51 UTC
(In reply to Richard Biener from comment #6)
> I understand that both the 4.8 branch and trunk fail?

Correct.
Comment 8 Richard Biener 2013-11-22 10:38:48 UTC
Waiting for analysis.
Comment 9 Joost VandeVondele 2013-11-22 10:40:47 UTC
(In reply to Richard Biener from comment #8)
> Waiting for analysis.

Analysis by whom, and if me, what can I do ?
Comment 10 Joost VandeVondele 2013-11-22 11:05:00 UTC
So, after the change from fat to slim lto, I've added the CP2K SVN repo to use gcc-ar (so that the instructions in comment #1 should still work). 

Now, the issue discussed here fails to reproduce because during the lto phase we run into:

/data/vjoost/clean/cp2k/cp2k/makefiles/../src/thermostat_methods.F:102:0: internal compiler error: tree check: expected ssa_name, have integer_cst in simplify_conversion_from_bitmask, at tree-ssa-forwprop.c:1189
   SUBROUTINE create_thermostats(thermostats, md_section, force_env, simpar, &
 ^
0xb15de4 tree_check_failed(tree_node const*, char const*, int, char const*, ...)
	../../gcc/gcc/tree.c:9189
0x9e52c0 tree_check
	../../gcc/gcc/tree.h:2710
0x9e52c0 simplify_conversion_from_bitmask
	../../gcc/gcc/tree-ssa-forwprop.c:1189
0x9ef3cd ssa_forward_propagate_and_combine
	../../gcc/gcc/tree-ssa-forwprop.c:3552
0x9ef3cd execute
	../../gcc/gcc/tree-ssa-forwprop.c:3661
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[2]: *** [/tmp/ccEVGVIu.ltrans20.ltrans.o] Error 1
Comment 11 Joost VandeVondele 2013-11-22 11:08:11 UTC
the ICE just mentioned is PR59154.
Comment 12 Joost VandeVondele 2013-11-27 08:35:22 UTC
Building with 4.9.0 now works, 4.8.3 [gcc-4_8-branch revision 203695] still fails.
Comment 13 Joost VandeVondele 2013-12-05 08:48:09 UTC
The 4.9 problem is gone, not sure which revision fixed this, the only thing I noticed was this comment.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45375#c195

and I have now a couple of LTO builds as part of our daily gcc tester, so I'll notice quickly if it regresses.

Not sure if it is worth keeping the bug open for 4.8, I guess there will be other issues popping up with 4.8 anyway.
Comment 14 Joost VandeVondele 2014-03-15 09:30:20 UTC
current 4.8 branch still fails as described in comment #0
Comment 15 Richard Biener 2014-05-22 09:03:42 UTC
GCC 4.8.3 is being released, adjusting target milestone.
Comment 16 Jakub Jelinek 2014-12-19 13:35:50 UTC
GCC 4.8.4 has been released.
Comment 17 Richard Biener 2015-06-23 08:32:54 UTC
Fixed for 4.9.0.