Fix the bug with initialisers/finalisers in libraries not being called ( and

Estimated hours taken: 7
Branches: main, release

Fix the bug with initialisers/finalisers in libraries not being called ( and
as consequence also fixes the bug with mutables not being given their correct
initial value).  The problem was that the directives necessary to call them
were not being included in the libraries' .init file.

The fix is to add a new mode of operation to mkinit that given a list of
.c files that make up some Mercury library, constructs the .init file for
that library.  In particular, it now constructs the .init file so that
it contains any REQUIRED_{INIT,FINAL} directives needed by the library.
The new mode of operation is invoked when mkinit is given the `-k' option.

Modify the build systems (i.e. mmake and mmc --make) to conform to the
above change.

compiler/modules.m:
	Change the rule mmake uses to build .init files so that it calls
	mkinit -k on all the .c files generated for the library.

scripts/Mmake.vars.in:
	Add a new mmake variable MKLIBINIT.  This is the program used to
	create .init files.  (It will nearly always be mkinit.)

compiler/compile_target_code.m:
	Change how .init files are built.  We now have to call mkinit -k to
	scan all of the .c files to write out the correct set of INIT,
	REQUIRED_INIT and REQUIRED_FINAL directives.  The code here is
	that used by mmc --make for creating the .init files.

compiler/make.program_target.m:
	Build the .init file after building the .c files, since building
	it before will no longer work.
This commit is contained in:
Julien Fischer
2006-05-21 06:22:59 +00:00
parent a2de6b0516
commit faa18a15bd
4 changed files with 71 additions and 52 deletions

View File

@@ -358,6 +358,10 @@ MLLIBS =
EXTRA_MLLIBS =
LIB_MLLIBS = $(patsubst %,-l%,$(ALL_EXTRA_LIBRARIES))
# Program used to create the .init file for a library.
# This is usually just mkinit invoked with the `-k' option.
MKLIBINIT = mkinit -k
# These only have an effect with `mmc --make'.
LINKAGE = shared
MERCURY_LINKAGE = @DEFAULT_LINKAGE@