|View Issue Details [ Jump to Notes ]||[ Issue History ] [ Print ]|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000052||mercury||Bug||public||2008-03-13 17:07||2008-03-27 23:42|
|Target Version||Fixed in Version|
|Summary||0000052: rebuilding a program with a mutable in a different grade causes invalid c to be generated|
|Description||Compile the attached program in hlc.gc and then rebuild in asm_fast.gc and the c compiler gives an error:|
jupiter:/home/jupiter/maclarty/mut> mmc --make mut --grade hlc.gc
jupiter:/home/jupiter/maclarty/mut> mmc --make mut --grade asm_fast.gc
** Error making `mut'.
Mercury/os/mut_init.o(.text+0x458): In function `mercury_init':
: undefined reference to `<predicate 'main'/2 mode 0>'
Mercury/os/mut.o(.text+0x1a): In function `<predicate 'main'/2 mode 0>':
: undefined reference to `<predicate 'io.write_int'/3 mode 0>'
Mercury/os/mut.o(.text+0x22): In function `<predicate 'main'/2 mode 0>':
: undefined reference to `<predicate 'io.nl'/2 mode 0>'
collect2: ld returned 1 exit status
|Tags||No tags attached.|
That's happening because the .mh file that is built in the hlc.gc grade is not
replaced when the program is re-compiled in asm_fast.gc (since the timestamp
on the .m file won't have changed). The hlc and asm_fast versions of the
program use different C types in the mutable definition which is why it fails
The are already two solutions to this:
(1) do a --make mut.realclean before rebuilding the program in a different grade.
or, if you wish to support multiple grades simulatenously
(2) use --use-grade-subdirs
|The problem still occurs with --use-grade-subdirs in the original program. The test case I submitted does however work with --use-grade-subdirs. I'll see if I can create another test case that exhibits the problem when --use-grade-subdirs is enabled.|
The bug here is that the compiler doesn't consider .mh files to be grade
dependent when in fact they are because the types of the global variables
used to implement mutables will vary depending on whether the high-level
or low-level C backend is being used.
This can be fixed by writing both mutable declarations to the .mh
file and use #ifdef MR_HIGHLEVEL_CODE to conditionally include only
one of them.
(A alternative fix is to make the .mh files grade dependent but this is
more involved as it will invovle chaning the way that libraries
|Fix committed. See log message for r1.77 of compiler/make_hlds_passes.m for details.|
||File Added: mut.m|
|2008-03-13 17:30||juliensf||Note Added: 0000087|
||Note Added: 0000088|
|2008-03-15 01:25||juliensf||Note Added: 0000089|
|2008-03-15 01:25||juliensf||Status||new => assigned|
|2008-03-15 01:25||juliensf||Assigned To||=> juliensf|
|2008-03-27 23:42||juliensf||Status||assigned => resolved|
|2008-03-27 23:42||juliensf||Resolution||open => fixed|
|2008-03-27 23:42||juliensf||Note Added: 0000093|