Mercury Bugs - mercury
View Issue Details
0000321mercuryBugpublic2014-02-20 20:412014-09-05 15:47
Reporterpbone 
Assigned Topbone 
PrioritynormalSeveritymajorReproducibilityhave not tried
StatusclosedResolutionunable to reproduce 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000321: Exception handling and intermodule optimisation create linker errors
DescriptionThe C linker gives me errors such as:

paul@oxygen> mmc --rebuild test -O2 --intermodule-optimization
Making Mercury/int3s/test.int3
Making Mercury/ints/test.int
Making Mercury/opts/test.opt
Making Mercury/cs/test.c
Making Mercury/os/test.o
Making test
** Error making `test'.
Mercury/os/test.o: In function `<predicate 'test.try_divide'/3 mode 0>':
test.c:(.text+0xe6): undefined reference to `<predicate 'exception.wrap_success_or_failure'/2 mode 0>'
collect2: error: ld returned 1 exit status

When I use at least -O2 and --intermodule-optimisation and my module includes exception handling code (see attached).

I'm using Mercury 14.01, this bug seems to be recent, it didn't occur in 13.05. I haven't checked versions in between.
Steps To ReproduceMercury 14.01 in the low-level C grade,

mmc --rebuild test -O2 --intermodule-optimization
TagsNo tags attached.
Attached Files? bug321.m (855) 2014-02-20 20:43
https://bugs.mercurylang.org/file_download.php?file_id=206&type=bug

Notes
(0000658)
juliensf   
2014-04-04 13:35   
What OS / processor is this occurring on?
How was the Mercury compiler built and installed? (E.g. was it directly from the source distribution or was it recompiled on the system that exhibits the problem?)
What version of GCC is this?
(0000659)
pbone   
2014-04-04 16:35   
This is my normal Debian Linux on x86_64 system.

paul@oxygen> uname -a
Linux oxygen 3.12-1-amd64 0000001 SMP Debian 3.12.9-1 (2014-02-01) x86_64 GNU/Linux
paul@oxygen> cat /etc/debian_version
jessie/sid
paul@oxygen> gcc --version
gcc (Debian 4.8.2-16) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I believe (but aren't certain) that I bootstrapped the Mercury installation using the same version. Ie, I used the source distribution, installed a single grade and the compiler, and then untared a fresh build tree and built the real version using the mmc I'd just installed.
(0000663)
pbone   
2014-04-24 14:25   
Working on this now.
(0000758)
pbone   
2014-08-12 15:56   
I revisited this today. It now seems like the exception.opt file that gets installed doesn't match the code compiled into libmer_std.so I don't yet know why or under what conditions this happens, because it doesn't always happen.
(0000784)
pbone   
2014-09-05 15:47   
I can't reliably reproduce this bug. Some installations of Mercury create the bug and some do not. I've tried many times to install different versions of Mercury in different ways and haven't found what causes it. It seems to be something wrong with how the exception module is compiled.

Issue History
2014-02-20 20:41pboneNew Issue
2014-02-20 20:41pboneStatusnew => assigned
2014-02-20 20:41pboneAssigned To => pbone
2014-02-20 20:43pboneFile Added: bug321.m
2014-04-04 13:35juliensfNote Added: 0000658
2014-04-04 16:35pboneNote Added: 0000659
2014-04-24 14:26pboneNote Added: 0000663
2014-04-24 14:26pboneStatusassigned => confirmed
2014-08-12 15:56pboneNote Added: 0000758
2014-09-05 15:47pboneNote Added: 0000784
2014-09-05 15:47pboneStatusconfirmed => closed
2014-09-05 15:47pboneResolutionopen => unable to reproduce