[m-dev.] Bug 321

Julien Fischer jfischer at opturion.com
Fri Feb 21 23:24:02 AEDT 2014

On Fri, 21 Feb 2014, Paul Bone wrote:

> I'm tracking down bug 321.  https://www.mercurylang.org/bugs/view.php?id=321
> As you recall this is the symptom:
>    The C linker gives me errors such as:
>    paul at 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
> After looking at the exception.m code and the HLDS dumps during compilation
> of my test.m I found that:
>    The linker can't find an address for: wrap_success_or_failure/2
>    But it can find addresses for: get_determinism/2

Is your test.m the same as the file bug321.m that you uploaded to
Mantis?  I ask, because when I try the file from Mantis everything
seems fine ...

> Both predicates are called by the same code in the HLDS representation of
> test.m but one works and what doesn't.

... and when I look at the HLDS dumps (of bug321.m)I see no reference to

> So I looked at readelf(1) dump of libmer_std.so's symbol table.
> get_determinism/2 is exported globally and wrap_success_or_failure/2 is
> exported locally.
> Both are declared and defined in the implementation section of the exception
> module.  So now I want to know why is one being treated differently.

get_determinism/2 is exported globally from exception.o because it
is referred to by opt-exported clauses in optimization interface for the
exception module.  (It is also subject of a no_inline pragma so its own
clauses do not appear in the .opt file.)

wrap_success_or_failure/2 is not exported because it only refererred by
the predicate try_det, whose own clauses are not opt-exported.


More information about the developers mailing list