Skip to content

Commit

Permalink
Remove the RM_C mmake variable, which controlled whether the intermed…
Browse files Browse the repository at this point in the history
…iate

Estimated hours taken: 0.5
Branches: main

Remove the RM_C mmake variable, which controlled whether the intermediate
`.c' files were removed (now they never are).

The implementation was buggy (it didn't work with parallel makes), and
made it difficult to avoid always recompiling the `.c' file with smart
recompilation.

Mmake.common.in:
configure.in:
README.AIX:
bindist/bindist.build_vars.in:
bindist/bindist.configure.in:
scripts/Mmake.vars.in:
scripts/Mmake.rules:
compiler/modules.m:
tools/bootcheck:
tools/binary_step:
*/Mmakefile:
	Remove references to RM_C, DEFAULT_RM_C and LIBRARY_RM_C.

compiler/modules.m:
	The `.o' and `.pic_o' file now depends only on the `.c' file,
	not on everthing the `.c' file depends on. The extra dependencies
	were only needed because the intermediate `.c' file could
	be removed by RM_C. This change is needed to avoid recompiling
	unchanged `.c' files with smart recompilation.
  • Loading branch information
Simon Taylor committed May 18, 2001
1 parent 9ad41dc commit 319df48
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 184 deletions.
7 changes: 0 additions & 7 deletions Mmake.common.in
Expand Up @@ -51,13 +51,6 @@ CFLAGS_FOR_PIC = @CFLAGS_FOR_PIC@
# just reuse the .o files.
EXT_FOR_PIC_OBJECTS = @EXT_FOR_PIC_OBJECTS@

# Set LIBRARY_RM_C as `:' if EXT_FOR_PIC_OBJECTS is `pic_o', or `rm'
# otherwise. This is used to ensure that in cases when we're building
# both `.o' and `.pic_o' files, we don't remove the intermediate `.c' files.
# This avoids compiling things to C twice, and also avoids problems when
# bootstrapping from the source distribution.
LIBRARY_RM_C = @LIBRARY_RM_C@

# This specifies the path to the so_locations file (or its equivalent),
# which is used by the linker to help it to map different shared objects
# to different virtual memory addresses at static link time, so as to avoid
Expand Down
11 changes: 2 additions & 9 deletions README.AIX
Expand Up @@ -21,14 +21,7 @@ in resolving them.
This works around a fixed limit on the size of the TOC (Table of Contents)
in the RS/6000 object file format.

2. Also add the following line to Mmake.params:

RM_C=:

This prevents the intermediate C files from being removed,
which will make it easier to debug things later.

3. Follow the instructions in the INSTALL file.
2. Follow the instructions in the INSTALL file.

The last version of Mercury which was known to work on AIX was
Mercury 0.6 -- actually a version just prior to 0.6, namely
Expand All @@ -39,7 +32,7 @@ For that version, following the steps above would result in
an error message from the assembler, so the following additional
step was needed.

4. Change directory to the `compiler' directory, and run the command
3. Change directory to the `compiler' directory, and run the command

sh ../scripts/rs6000_hack

Expand Down
1 change: 0 additions & 1 deletion bindist/bindist.build_vars.in
Expand Up @@ -33,7 +33,6 @@ CFLAGS_FOR_PIC="@CFLAGS_FOR_PIC@"
SHARED_LIBS='@SHARED_LIBS@'
SHARED_LIBS_SH='@SHARED_LIBS_SH@'
HAVE_DELAY_SLOT="@HAVE_DELAY_SLOT@"
DEFAULT_RM_C="@DEFAULT_RM_C@"
ERROR_UNDEFINED="@ERROR_UNDEFINED@"
ALLOW_UNDEFINED="@ALLOW_UNDEFINED@"
DL_LIBRARY="@DL_LIBRARY@"
Expand Down
1 change: 0 additions & 1 deletion bindist/bindist.configure.in
Expand Up @@ -61,7 +61,6 @@ AC_SUBST(EXT_FOR_PIC_OBJECTS)
AC_SUBST(EXT_FOR_SHARED_LIB)
AC_SUBST(SHARED_LIBS)
AC_SUBST(HAVE_DELAY_SLOT)
AC_SUBST(DEFAULT_RM_C)
AC_SUBST(ALLOW_UNDEFINED)
AC_SUBST(ERROR_UNDEFINED)
AC_SUBST(DL_LIBRARY)
Expand Down
6 changes: 0 additions & 6 deletions browser/Mmakefile
Expand Up @@ -24,12 +24,6 @@ VPATH=$(LIBRARY_DIR)

#-----------------------------------------------------------------------------#

# If we're going to generate both `.o' files and `.pic_o' files, then
# don't remove the intermediate `.c' files.
RM_C = $(LIBRARY_RM_C)

#-----------------------------------------------------------------------------#

# Specify which compilers to use to compile the library.
# Don't change these without good reason - if you want to
# do a temporary change, change ../Mmake.params.
Expand Down
77 changes: 23 additions & 54 deletions compiler/modules.m
Expand Up @@ -1710,8 +1710,6 @@
AsmFileName, " ",
PicAsmFileName, " ",
ErrFileName, " ",
PicObjFileName, " ",
ObjFileName, " ",
SplitObjPattern, " ",
RLOFileName, " ",
ILFileName, " : ",
Expand Down Expand Up @@ -1745,8 +1743,6 @@
CFileName, " ",
TransOptDateFileName, " ",
ErrFileName, " ",
PicObjFileName, " ",
ObjFileName, " ",
SplitObjPattern, " :"
]),

Expand Down Expand Up @@ -1775,8 +1771,6 @@
"\n\n",
CFileName, " ",
ErrFileName, " ",
PicObjFileName, " ",
ObjFileName, " ",
SplitObjPattern, " :"
]),
write_dependencies_list(TransOptDeps,
Expand Down Expand Up @@ -1931,28 +1925,6 @@
"\trm -f ", CFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
"$< > ", ErrFileName, " 2>&1\n",
"ifneq ($(RM_C),:)\n",
ObjFileName, " : ", SourceFileName, "\n",
"\t$(MMAKE_MAKE_CMD) $(MFLAGS) ",
"MC=""$(MC)"" ",
"ALL_MCFLAGS=""$(ALL_MCFLAGS)"" ",
"ALL_GRADEFLAGS=""$(ALL_GRADEFLAGS)"" ",
CFileName, "\n",
"\t$(MGNUC) $(ALL_GRADEFLAGS) ",
"$(ALL_MGNUCFLAGS) -c ", CFileName,
" -o $@\n",
"\t$(RM_C) ", CFileName, "\n",
PicObjFileName, " : ", SourceFileName, "\n",
"\t$(MMAKE_MAKE_CMD) $(MFLAGS) ",
"MC=""$(MC)"" ",
"ALL_MCFLAGS=""$(ALL_MCFLAGS)"" ",
"ALL_GRADEFLAGS=""$(ALL_GRADEFLAGS)"" ",
CFileName, "\n",
"\t$(MGNUC) $(ALL_GRADEFLAGS) ",
"$(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) ",
"\\\n",
"\t\t-c ", CFileName, " -o $@\n",
"endif # RM_C != :\n",
"ifeq ($(TARGET_ASM),yes)\n",
AsmFileName, " : ", SourceFileName, "\n",
"\trm -f ", AsmFileName, "\n",
Expand Down Expand Up @@ -2754,6 +2726,24 @@
write_extra_link_dependencies_list(ExtraLinkObjs, ".$O", DepStream),
io__write_string(DepStream, "\n"),

%
% $(foo.cs_or_ss) contains the names of the generated intermediate
% files between `.m' and `.o' files. This is used in foo.dep
% to make sure the intermediate files are generated before the
% object files, so that errors are reported as soon as possible.
%
% If TARGET_ASM=yes, we define $(foo.cs_or_ss) to be $(foo.ss),
% otherwise it is defined to be $(foo.cs).
%
io__write_strings(DepStream, [
"ifeq ($(TARGET_ASM),yes)\n",
MakeVarName, ".cs_or_ss =$(", MakeVarName, ".ss)\n",
"else\n",
MakeVarName, ".cs_or_ss =$(", MakeVarName, ".cs)\n",
"endif\n\n"
]),


io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".rlos = "),
write_compact_dependencies_list(Modules, "$(rlos_subdir)", ".rlo",
Expand Down Expand Up @@ -2992,35 +2982,14 @@
% rather than first spending time compiling C files to .$O,
% which could be a waste of time if the program contains errors.
%
% But we can only do this if we don't remove the .c files,
% i.e. if RM_C=:
% So we define $(foo.maybe_cs) here and use it in the rules below.
% This needs to be defined here in the .dep file rather than
% in the .dv file since it depends on the setting of the $(RM_C) file
% which can be overridden by the user's Mmakefile.
%
% When compiling to assembler, we want to do the same kind of
% thing, for the same reason, but with the `.s' files rather
% than the `.c' files. So if TARGET_ASM=yes, we define
% $(foo.maybe_cs) to be $(foo.ss).
% XXX The name `.maybe_cs' is a bit misleading in this case.
% Perhaps we should change it.
% than the `.c' files.
%
module_name_to_file_name(SourceModuleName, "", no, ExeFileName),
io__write_strings(DepStream, [
"ifeq ($(TARGET_ASM),yes)\n",
MakeVarName, ".maybe_cs=$(", MakeVarName, ".ss)\n",
"else\n",
" ifeq ($(RM_C),:)\n",
MakeVarName, ".maybe_cs=$(", MakeVarName, ".cs)\n",
" else\n",
MakeVarName, ".maybe_cs=\n",
" endif\n\n",
"endif\n\n"
]),

module_name_to_file_name(SourceModuleName, "", no, ExeFileName),
io__write_strings(DepStream, [
ExeFileName, " : $(", MakeVarName, ".maybe_cs) ",
ExeFileName, " : $(", MakeVarName, ".cs_or_ss) ",
"$(", MakeVarName, ".os) ",
InitObjFileName, " $(MLOBJS) ", All_MLLibsDepString,
"\n",
Expand Down Expand Up @@ -3084,7 +3053,7 @@
]),

io__write_strings(DepStream, [
SharedLibFileName, " : $(", MakeVarName, ".maybe_cs) ",
SharedLibFileName, " : $(", MakeVarName, ".cs_or_ss) ",
"$(", MakeVarName, ".pic_os) ",
"$(MLPICOBJS) ", All_MLLibsDepString, "\n",
"\t$(ML) --make-shared-lib $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) ",
Expand All @@ -3094,7 +3063,7 @@
]),

io__write_strings(DepStream, [
LibFileName, " : $(", MakeVarName, ".maybe_cs) ",
LibFileName, " : $(", MakeVarName, ".cs_or_ss) ",
"$(", MakeVarName, ".os) $(MLOBJS)\n",
"\trm -f ", LibFileName, "\n",
"\t$(AR) $(ALL_ARFLAGS) $(AR_LIBFILE_OPT)", LibFileName, " ",
Expand Down
29 changes: 0 additions & 29 deletions configure.in
Expand Up @@ -2412,33 +2412,6 @@ case "$host" in
;;
esac

#
# This sets the default value of RM_C, which should be either `rm' to
# remove the intermediate C files, or `:' to keep them.
#
# If RM_C is set to `rm', then unfortunately Mmake needs to invoke
# make recursively, and this causes several problems:
# (1) it causes performance problems, particularly on MS-Windows
# (2) it can break parallel makes, because there are race
# conditions involved when you invoke make recursively
# in a parallel make
#
# Therefore by default we currently keep the intermediate C files.
#
DEFAULT_RM_C=:

case $EXT_FOR_PIC_OBJECTS in
o)
LIBRARY_RM_C=$DEFAULT_RM_C
;;
*)
# If we're going to be building both `.pic_o' files
# and `.o' files, then we should not remove the generated `.c'
# files in the library directory after building the `.o' files.
LIBRARY_RM_C=:
;;
esac

#-----------------------------------------------------------------------------#

case "$host" in
Expand Down Expand Up @@ -2467,8 +2440,6 @@ AC_SUBST(EXT_FOR_EXE)
AC_SUBST(USE_DLLS)
AC_SUBST(SHARED_LIBS)
AC_SUBST(SHARED_LIBS_SH)
AC_SUBST(DEFAULT_RM_C)
AC_SUBST(LIBRARY_RM_C)
if test $USE_DLLS = "yes"; then
AC_DEFINE(USE_DLLS)
fi
Expand Down
2 changes: 0 additions & 2 deletions extras/graphics/mercury_opengl/Mmakefile
@@ -1,6 +1,4 @@

#RM_C=:

MAIN_TARGET = all

MLOBJS = togl.o
Expand Down
2 changes: 0 additions & 2 deletions extras/morphine/non-regression-tests/Mmakefile
Expand Up @@ -6,8 +6,6 @@ main_target: check
# This file is copied from the Mercury tests repository
include ./Mmake.common


RM_C=:
#-----------------------------------------------------------------------------#

MORPHINE = ../scripts/morphine --no-banner
Expand Down
1 change: 0 additions & 1 deletion extras/trailed_update/Mmakefile
Expand Up @@ -7,7 +7,6 @@
GRADEFLAGS += --use-trail

# enable C debugging
RM_C = :
MGNUCFLAGS = -g
MLFLAGS = -g

Expand Down
1 change: 0 additions & 1 deletion extras/trailed_update/samples/Mmakefile
Expand Up @@ -13,7 +13,6 @@ MCFLAGS = --infer-all

# Enable C debugging
CFLAGS=-g
RM_C=:
MLFLAGS=-g

# Link in the trailed_update library from ..
Expand Down
1 change: 0 additions & 1 deletion extras/trailed_update/tests/Mmakefile
Expand Up @@ -12,7 +12,6 @@ GRADEFLAGS += --use-trail
MCFLAGS = --infer-all

MGNUCFLAGS=-g -I..
RM_C=:
MLFLAGS=-g

# Link in the trailed_update library from ..
Expand Down
6 changes: 0 additions & 6 deletions library/Mmakefile
Expand Up @@ -34,12 +34,6 @@ MCFLAGS-set_ordlist += $(TYPE_SPEC_FLAGS)

#-----------------------------------------------------------------------------#

# If we're going to generate both `.$O' files and `.pic_o' files, then
# don't remove the intermediate `.c' files.
RM_C = $(LIBRARY_RM_C)

#-----------------------------------------------------------------------------#

# Specify which options to use to compile the library.
# Don't change these without good reason - if you want to
# do a temporary change, change ../Mmake.params.
Expand Down
6 changes: 0 additions & 6 deletions runtime/Mmakefile
Expand Up @@ -342,12 +342,6 @@ install_lib: lib$(RT_LIB_NAME).$A lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB) \

endif


#-----------------------------------------------------------------------------#

# prevent Mmake from removing C files
RM_C=:

#-----------------------------------------------------------------------------#

clean_local: clean_o clean_check
Expand Down
2 changes: 0 additions & 2 deletions samples/c_interface/c_calls_mercury/Mmakefile
Expand Up @@ -28,5 +28,3 @@ clean_local:
rm -f c_main.o mercury_lib.h

#-----------------------------------------------------------------------------#

RM_C=:
3 changes: 0 additions & 3 deletions samples/c_interface/cplusplus_calls_mercury/Mmakefile
Expand Up @@ -30,9 +30,6 @@ CXXFLAGS=-g
MGNUCFLAGS=-g
MLFLAGS=-g

# tell Mmake not to remove the `.c' files, so we can look at them (e.g. in gdb)
RM_C=:

# tell the Mercury linker to link in cpp_main.o and mercury_lib.o
MLLIBS=cpp_main.o mercury_lib.o

Expand Down
3 changes: 0 additions & 3 deletions samples/c_interface/simpler_c_calls_mercury/Mmakefile
Expand Up @@ -23,9 +23,6 @@ MGNUCFLAGS=-g
# not a main program
C2INITFLAGS=--library

# keep the `.c' files around, for debugging
RM_C=:

#-----------------------------------------------------------------------------#

c_main.o: mercury_lib.h c_main.c
Expand Down
3 changes: 0 additions & 3 deletions samples/c_interface/simpler_cplusplus_calls_mercury/Mmakefile
Expand Up @@ -35,9 +35,6 @@ MLFLAGS=-g
# not a main program
C2INITFLAGS=--library

# tell Mmake not to remove the `.c' files, so we can look at them (e.g. in gdb)
RM_C=:

OBJECTS = cpp_main.o mercury_lib_init.o $(mercury_lib.os)

#-----------------------------------------------------------------------------#
Expand Down
23 changes: 0 additions & 23 deletions scripts/Mmake.rules
Expand Up @@ -224,29 +224,6 @@ $(os_subdir)%.dll : %.il
$(MS_ILASM) $(ALL_MS_ILASMFLAGS) /dll /quiet /OUT=$@ $<
endif

# If we are removing the .c files, we need to tell Make that we're
# generating the .$O files directly from the .m files, but
# in order to avoid remaking the .c files if they're already there,
# we need to invoke mmake recursively for each .c file.
# This can be pretty inefficient.

ifneq ($(RM_C),:)

$(os_subdir)%.$O : %.m
$(MMAKE_MAKE_CMD) $(MFLAGS) MC="$(MC)" ALL_MCFLAGS="$(ALL_MCFLAGS)" \
ALL_GRADEFLAGS="$(ALL_GRADEFLAGS)" $(cs_subdir)$*.c
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $(cs_subdir)$*.c \
$(OBJFILE_OPT)$@
$(RM_C) $(cs_subdir)$*.c

$(os_subdir)%.pic_o : %.m
$(MMAKE_MAKE_CMD) $(MFLAGS) MC="$(MC)" ALL_MCFLAGS="$(ALL_MCFLAGS)" \
ALL_GRADEFLAGS="$(ALL_GRADEFLAGS)" $(cs_subdir)$*.c
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
-c $(cs_subdir)$*.c $(OBJFILE_OPT)$@

endif # RM_C != :

# For --split-c-files, we generate the .$O files directly from the .m files.
# (One reason for this is that there's no easy of telling Make how many
# `.$O' files it should make, since the number of them depends on what's
Expand Down
5 changes: 0 additions & 5 deletions scripts/Mmake.vars.in
Expand Up @@ -256,11 +256,6 @@ EXT_FOR_PIC_OBJECTS = @EXT_FOR_PIC_OBJECTS@
# shared libraries.
EXT_FOR_SHARED_LIB = @EXT_FOR_SHARED_LIB@

# Set `RM_C' to `:' if you want to keep the intermediate `.c' files,
# or to `rm' if you want Mmake to remove them. Beware that RM_C=rm
# causes some potential race conditions if you use parallel make.
RM_C = @DEFAULT_RM_C@

# lists of targets that depend on $(MLOBJS) and $(MLPICOBJS)
MLOBJS_DEPS =
MLPICOBJS_DEPS =
Expand Down

0 comments on commit 319df48

Please sign in to comment.