2024-11-23 19:14 AEDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000052mercuryBugpublic2008-03-27 23:42
Reportermaclarty 
Assigned Tojuliensf 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000052: rebuilding a program with a mutable in a different grade causes invalid c to be generated
DescriptionCompile 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
Making Mercury/int3s/mut.int3
Making Mercury/ints/mut.int
Making Mercury/cs/mut.c
Making Mercury/os/mut.o
Making mut
jupiter:/home/jupiter/maclarty/mut> ./mut
1
jupiter:/home/jupiter/maclarty/mut> mmc --make mut --grade asm_fast.gc
Making mut
** 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
TagsNo tags attached.
Attached Files
  • ? file icon mut.m (247 bytes) 2008-03-13 17:07

-Relationships
+Relationships

-Notes

~0000087

juliensf (administrator)

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
to compile.

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

~0000088

maclarty (developer)

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.

~0000089

juliensf (administrator)

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
are installed.)

~0000093

juliensf (administrator)

Fix committed. See log message for r1.77 of compiler/make_hlds_passes.m for details.
+Notes

-Issue History
Date Modified Username Field Change
2008-03-13 17:07 maclarty New Issue
2008-03-13 17:07 maclarty File Added: mut.m
2008-03-13 17:30 juliensf Note Added: 0000087
2008-03-14 12:08 maclarty 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
+Issue History