Fix potential problems with the way we were handling grade components: the

Estimated hours taken: 5

Fix potential problems with the way we were handling grade components: the
places that know about grade components were not being kept totally in sync.
This change fixes previous damage and aims to prevent future damage.

The file runtime/mercury_grade.h contains a list of all the files in the
compiler that know about grade components. All these files now process the
grade components in the same order, so that they can be checked for consistency
more easily.

runtime/mercury_grade.h:
	Add the list.

runtime/mercury_conf_param.h:
	Remove a comment about an obsolete grade component.

scripts/init_grade_options.sh-subr:
	Remove initializations of variables that do not correspond to grade
	components, add missing initializations of shell variables that do
	correspond to grade components, and concentrate the grade options
	component of usage messages here, to prevent double maintenance.

	Update list of user scripts.

scripts/final_grade_options.sh-subr:
	Add missing initializations in processing the --grade superoption.

	Standardize the order of processing options, and the indentation.

	Update list of user scripts.

scripts/c2init.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

scripts/mgnuc.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

	Standardize the order of processing grade options, and separate the
	processing of grade options and non-grade options.

scripts/ml.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

	Standardize the order of processing grade options. Process some missing
	ones.

compiler/handle_options.m:
	Standardize the order of processing grade options.

	Remove code to handle an obsolete grade component.
This commit is contained in:
Zoltan Somogyi
1999-11-09 01:45:43 +00:00
parent 5e4953485c
commit 22840901fd
9 changed files with 414 additions and 374 deletions

View File

@@ -573,15 +573,14 @@ long_usage -->
% grade of the library, etc for linking (and installation). % grade of the library, etc for linking (and installation).
:- type grade_component :- type grade_component
---> gcc_ext % gcc extensions -- see grade_component_table ---> gcc_ext % gcc extensions -- see grade_component_table
; par % parallelism / multithreading
; gc % the kind of GC to use ; gc % the kind of GC to use
; prof % what profiling options to use ; prof % what profiling options to use
; trail % whether or not to use trailing ; trail % whether or not to use trailing
; minimal_model % whether we set up for minimal model tabling ; minimal_model % whether we set up for minimal model tabling
; args % argument passing convention
; trace % tracing/debugging options
; par % parallelism / multithreading
; pic % Do we need to reserve a register for ; pic % Do we need to reserve a register for
% PIC (position independent code)? % PIC (position independent code)?
; trace % tracing/debugging options
. .
convert_grade_option(GradeString, Options0, Options) :- convert_grade_option(GradeString, Options0, Options) :-
@@ -658,11 +657,9 @@ compute_grade_components(Options, GradeComponents) :-
:- pred grade_component_table(string, grade_component, :- pred grade_component_table(string, grade_component,
list(pair(option, option_data))). list(pair(option, option_data))).
:- mode grade_component_table(in, out, out) is semidet. :- mode grade_component_table(in, out, out) is semidet.
:- mode grade_component_table(out, in, out) is multi.
:- mode grade_component_table(out, out, out) is multi. :- mode grade_component_table(out, out, out) is multi.
% Args method components
grade_component_table("sa", args, [args - string("simple")]).
% GCC-hack components % GCC-hack components
grade_component_table("none", gcc_ext, [asm_labels - bool(no), grade_component_table("none", gcc_ext, [asm_labels - bool(no),
gcc_non_local_gotos - bool(no), gcc_global_registers - bool(no)]). gcc_non_local_gotos - bool(no), gcc_global_registers - bool(no)]).
@@ -677,16 +674,13 @@ grade_component_table("fast", gcc_ext, [asm_labels - bool(no),
grade_component_table("asm_fast", gcc_ext, [asm_labels - bool(yes), grade_component_table("asm_fast", gcc_ext, [asm_labels - bool(yes),
gcc_non_local_gotos - bool(yes), gcc_global_registers - bool(yes)]). gcc_non_local_gotos - bool(yes), gcc_global_registers - bool(yes)]).
% Parallelism/multithreading components.
grade_component_table("par", par, [parallel - bool(yes)]).
% GC components % GC components
grade_component_table("gc", gc, [gc - string("conservative")]). grade_component_table("gc", gc, [gc - string("conservative")]).
grade_component_table("agc", gc, [gc - string("accurate")]). grade_component_table("agc", gc, [gc - string("accurate")]).
% Parallelism/MT components.
grade_component_table("par", par, [parallel - bool(yes)]).
% Pic reg components
grade_component_table("picreg", pic, [pic_reg - bool(yes)]).
% Profiling components % Profiling components
grade_component_table("prof", prof, [profile_time - bool(yes), grade_component_table("prof", prof, [profile_time - bool(yes),
profile_deep - bool(no), profile_calls - bool(yes), profile_deep - bool(no), profile_calls - bool(yes),
@@ -707,21 +701,23 @@ grade_component_table("profall", prof, [profile_time - bool(yes),
profile_deep - bool(no), profile_calls - bool(yes), profile_deep - bool(no), profile_calls - bool(yes),
profile_memory - bool(yes)]). profile_memory - bool(yes)]).
% Trailing components
grade_component_table("tr", trail, [use_trail - bool(yes)]).
% Mimimal model tabling components
grade_component_table("mm", minimal_model, [use_minimal_model - bool(yes)]).
% Pic reg components
grade_component_table("picreg", pic, [pic_reg - bool(yes)]).
% Debugging/Tracing components % Debugging/Tracing components
grade_component_table("debug", trace, grade_component_table("debug", trace,
[stack_trace - bool(yes), require_tracing - bool(yes)]). [stack_trace - bool(yes), require_tracing - bool(yes)]).
grade_component_table("trace", trace, grade_component_table("trace", trace,
[stack_trace - bool(no), require_tracing - bool(yes)]). [stack_trace - bool(no), require_tracing - bool(yes)]).
grade_component_table("strace", trace, grade_component_table("strce", trace,
[stack_trace - bool(yes), require_tracing - bool(no)]). [stack_trace - bool(yes), require_tracing - bool(no)]).
% Trailing components
grade_component_table("tr", trail, [use_trail - bool(yes)]).
% Mimimal model tabling components
grade_component_table("mm", minimal_model,
[use_minimal_model - bool(yes)]).
:- pred reset_grade_options(option_table, option_table). :- pred reset_grade_options(option_table, option_table).
:- mode reset_grade_options(in, out) is det. :- mode reset_grade_options(in, out) is det.
@@ -735,21 +731,20 @@ reset_grade_options(Options0, Options) :-
:- pred grade_start_values(pair(option, option_data)). :- pred grade_start_values(pair(option, option_data)).
:- mode grade_start_values(out) is multi. :- mode grade_start_values(out) is multi.
grade_start_values(args - string("compact")).
grade_start_values(asm_labels - bool(no)). grade_start_values(asm_labels - bool(no)).
grade_start_values(gcc_non_local_gotos - bool(no)). grade_start_values(gcc_non_local_gotos - bool(no)).
grade_start_values(gcc_global_registers - bool(no)). grade_start_values(gcc_global_registers - bool(no)).
grade_start_values(gc - string("none")).
grade_start_values(parallel - bool(no)). grade_start_values(parallel - bool(no)).
grade_start_values(pic_reg - bool(no)). grade_start_values(gc - string("none")).
grade_start_values(profile_deep - bool(no)). grade_start_values(profile_deep - bool(no)).
grade_start_values(profile_time - bool(no)). grade_start_values(profile_time - bool(no)).
grade_start_values(profile_calls - bool(no)). grade_start_values(profile_calls - bool(no)).
grade_start_values(profile_memory - bool(no)). grade_start_values(profile_memory - bool(no)).
grade_start_values(stack_trace - bool(no)).
grade_start_values(require_tracing - bool(no)).
grade_start_values(use_trail - bool(no)). grade_start_values(use_trail - bool(no)).
grade_start_values(use_minimal_model - bool(no)). grade_start_values(use_minimal_model - bool(no)).
grade_start_values(pic_reg - bool(no)).
grade_start_values(stack_trace - bool(no)).
grade_start_values(require_tracing - bool(no)).
:- pred split_grade_string(string, list(string)). :- pred split_grade_string(string, list(string)).
:- mode split_grade_string(in, out) is semidet. :- mode split_grade_string(in, out) is semidet.

View File

@@ -54,7 +54,6 @@
** --gcc-asm-labels ** --gcc-asm-labels
** --gc conservative ** --gc conservative
** --gc accurate [not yet working] ** --gc accurate [not yet working]
** --args compact
** --no-type-layout ** --no-type-layout
** --unboxed-float ** --unboxed-float
** --use-trail ** --use-trail

View File

@@ -10,13 +10,16 @@
** This is used to get the linker to ensure that different object files ** This is used to get the linker to ensure that different object files
** were compiled with consistent grades. ** were compiled with consistent grades.
** **
** Any condition compilation macros that affect link compatibility ** Any condition compilation macros that affect link compatibility should be
** should be included here. ** included here. For documentation on the meaning of these macros, see
** For documentation on the meaning of these macros, see
** runtime/mercury_conf_param.h. ** runtime/mercury_conf_param.h.
** **
** IMPORTANT: any changes here may also require changes to ** IMPORTANT: any changes here may also require changes to
** runtime/mercury_conf_param.h
** scripts/init_grade_options.sh-subr
** scripts/parse_grade_options.sh-subr ** scripts/parse_grade_options.sh-subr
** scripts/final_grade_options.sh-subr
** scripts/mgnuc.in
** scripts/ml.in ** scripts/ml.in
** compiler/handle_options.m ** compiler/handle_options.m
** compiler/mercury_compile.m ** compiler/mercury_compile.m
@@ -87,6 +90,7 @@
#else #else
#define MR_GRADE_PART_3 MR_GRADE_PART_2 #define MR_GRADE_PART_3 MR_GRADE_PART_2
#endif #endif
#ifdef CONSERVATIVE_GC #ifdef CONSERVATIVE_GC
#define MR_GRADE_PART_4 MR_PASTE2(MR_GRADE_PART_3, _gc) #define MR_GRADE_PART_4 MR_PASTE2(MR_GRADE_PART_3, _gc)
#elif defined(NATIVE_GC) #elif defined(NATIVE_GC)

View File

@@ -12,6 +12,30 @@
# Type `c2init --help' for usage message. # Type `c2init --help' for usage message.
# #
# If you change these, you will also need to change Mmake.common.in,
# scripts/ml.in, tools/bootcheck, tools/binary, tools/binary_step and
# tools/linear.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
MERCURY_MOD_LIB_DIR=${MERCURY_MOD_LIB_DIR=@LIBDIR@/modules}
MKINIT=${MERCURY_MKINIT=mkinit}
# maximum number of calls to put in a single function
maxcalls=40
defentry=mercury__main_2_0
init_opt=""
trace_opt=""
library_opt=""
extra_inits_opt=""
aditi_opt=""
extra_init_dirs=""
# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@
# IMPORTANT: the manpage is produced automatically from this help # IMPORTANT: the manpage is produced automatically from this help
# message, so if you change the help message, don't forget to check # message, so if you change the help message, don't forget to check
# that the manpage still looks OK. # that the manpage still looks OK.
@@ -53,49 +77,13 @@ Options:
hand-coded C code with \`INIT' comments, rather than hand-coded C code with \`INIT' comments, rather than
containing only C code that was automatically generated containing only C code that was automatically generated
by the Mercury compiler.) by the Mercury compiler.)
-s <grade>, --grade <grade>
--asm-labels $grade_usage
--gcc-non-local-gotos
--gcc-global-registers
--gc {conservative, accurate, none}
-p, --profiling
--profile-calls
--profile-time
--profile-memory
--debug
--use-trail
--pic-reg
See the documentation in the \"Invocation\" section
of the Mercury User's Guide.
Environment variables: Environment variables:
MERCURY_MOD_LIB_DIR, MERCURY_MOD_LIB_MODS, MERCURY_MKINIT. MERCURY_MOD_LIB_DIR, MERCURY_MOD_LIB_MODS, MERCURY_MKINIT.
" "
# If you change these, you will also need to change Mmake.common.in,
# scripts/ml.in, tools/bootcheck, tools/binary, tools/binary_step and
# tools/linear.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
MERCURY_MOD_LIB_DIR=${MERCURY_MOD_LIB_DIR=@LIBDIR@/modules}
MKINIT=${MERCURY_MKINIT=mkinit}
# maximum number of calls to put in a single function
maxcalls=40
defentry=mercury__main_2_0
init_opt=""
trace_opt=""
library_opt=""
extra_inits_opt=""
aditi_opt=""
extra_init_dirs=""
# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@
while true; do while true; do
case "$1" in case "$1" in
-a|--aditi) -a|--aditi)

View File

@@ -6,11 +6,17 @@
# #
# final_grade_options.sh-subr: # final_grade_options.sh-subr:
# An `sh' subroutine for handling implications between grade-related # An `sh' subroutine for handling implications between grade-related
# options. Used by the `ml' and `mgnuc' scripts. # options. Used by the `ml', `mgnuc' and `c2init' scripts.
# #
# The code here should be inserted after a script's option-parsing # The code here should be inserted after a script's option-parsing
# loop. # loop.
# #
# IMPORTANT: any changes to the handling of grades here may also require
# changes to compiler/handle_options.m.
#
# This file should only use the shell variables initialized by
# init_grade_options.sh-subr.
#
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
# #

View File

@@ -6,16 +6,46 @@
# #
# init_grade_options.sh-subr: # init_grade_options.sh-subr:
# An `sh' subroutine for initializing grade-related options. # An `sh' subroutine for initializing grade-related options.
# Used by the `ml' and `mgnuc' scripts. # Used by the `ml', `mgnuc' and `c2init' scripts.
# #
# The code here should be inserted before a script's option-parsing # The code here should be inserted before a script's option-parsing
# loop. The invoking script must define a DEFAULT_GRADE option. # loop. The invoking script must define a DEFAULT_GRADE option.
# #
# IMPORTANT: any changes to the handling of grades here may also require
# changes to all the files indicated by runtime/mercury_grade.h.
#
# This file must initialize all the shell variables used by
# parse_grade_options.sh-subr, and must list all the options processed in
# parse_grade_options.sh-subr.
#
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
grade_usage="\
Grade options:
-s <grade>, --grade <grade>
--asm-labels
--gcc-non-local-gotos
--gcc-global-registers
--parallel
--gc {conservative, accurate, none}
-p, --profiling
--profile-calls
--profile-time
--profile-memory
--use-trail
--use-minimal-model
--pic-reg
--no-stack-trace
--debug
See the documentation in the \"Invocation\" section
of the Mercury User's Guide."
# --profile-deep is not yet documented because it is not yet implemented
asm_labels=true asm_labels=true
non_local_gotos=true non_local_gotos=true
global_regs=true global_regs=true
thread_safe=false
gc_method=conservative gc_method=conservative
profile_time=false profile_time=false
profile_calls=false profile_calls=false
@@ -23,10 +53,9 @@ profile_memory=false
profile_deep=false profile_deep=false
use_trail=false use_trail=false
use_minimal_model=false use_minimal_model=false
pic_reg=false
stack_trace=false stack_trace=false
require_tracing=false require_tracing=false
low_level_debug=false
thread_safe=false
case $# in case $# in
0) set - "--grade $DEFAULT_GRADE" ;; 0) set - "--grade $DEFAULT_GRADE" ;;

View File

@@ -9,46 +9,7 @@
# IMPORTANT: the manpage is produced automatically from this help # IMPORTANT: the manpage is produced automatically from this help
# message, so if you change the help message, don't forget to check # message, so if you change the help message, don't forget to check
# that the manpage still looks OK. # that the manpage still looks OK.
Help="\
Name: mgnuc - Mercury front-end to GNU C
Usage: mgnuc [<options>] [-- <gcc options>] files...
Options:
-v, --verbose
Echo gcc command before executing it.
--no-ansi
Don't pass \`-ansi' to gcc.
--no-check
Don't enable any of gcc's warnings.
-s <grade>, --grade <grade>
--asm-labels
--gcc-non-local-gotos
--gcc-global-registers
--gc {conservative, accurate, none}
-p, --profiling
--profile-calls
--profile-time
--profile-memory
--debug
--low-level-debug
-g, --c-debug
--no-c-optimize
--use-trail
--pic-reg
--inline-alloc
--split-c-files
See the documentation in the \"Invocation\" section
of the Mercury User's Guide.
Description:
This runs gcc with the appropriate options for compiling Mercury
programs.
Normally it invokes gcc in ANSI mode with almost all warnings enabled,
but this can be changed using the \`--no-ansi' or \`--no-check'
options.
Environment variables:
MERCURY_C_INCL_DIR, MERCURY_ALL_C_INCL_DIRS, MERCURY_DEFAULT_GRADE.
"
# ************************************************************************* # *************************************************************************
# *** IMPORTANT NOTE: any changes to this file may also require similar *** # *** IMPORTANT NOTE: any changes to this file may also require similar ***
# *** changes to compiler/mercury_compile.m *** # *** changes to compiler/mercury_compile.m ***
@@ -116,6 +77,42 @@ c_optimize=true
# include the file `init_grade_options.sh-subr' # include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@ @INIT_GRADE_OPTIONS@
Help="\
Name: mgnuc - Mercury front-end to GNU C
Usage: mgnuc [<options>] [-- <gcc options>] files...
Options:
-v, --verbose
Echo gcc command before executing it.
--no-ansi
Don't pass \`-ansi' to gcc.
--no-check
Don't enable any of gcc's warnings.
--low-level-debug
Enable low-level debugging of the C code. Useful only
for Mercury system developers.
-g, --c-debug
Generate object files that can debugged with C debuggers
such as gdb.
--no-c-optimize
Disable optimization by the C compiler.
--inline-alloc
Inline calls to the memory allocator.
--split-c-files
This option must be specified if the argument C files were
generated by the Mercury compiler with --split-c-files.
$grade_usage
Description:
This runs gcc with the appropriate options for compiling Mercury
programs.
Normally it invokes gcc in ANSI mode with almost all warnings enabled,
but this can be changed using the \`--no-ansi' or \`--no-check'
options.
Environment variables:
MERCURY_C_INCL_DIR, MERCURY_ALL_C_INCL_DIRS, MERCURY_DEFAULT_GRADE.
"
while : ; do while : ; do
case "$1" in case "$1" in
-h|--help|"-?") -h|--help|"-?")
@@ -194,12 +191,34 @@ done
@FINAL_GRADE_OPTIONS@ @FINAL_GRADE_OPTIONS@
# #
# convert mgnuc options into gcc options # convert non-grade mgnuc options into gcc options
# #
# IMPORTANT: any changes here will require similar changes to # IMPORTANT: any changes here will require similar changes to
# compiler/mercury_compile.m. # compiler/mercury_compile.m.
# #
case $c_debug in
true) C_DEBUG_OPTS="-g" ;;
false) C_DEBUG_OPTS="" ;;
esac
case $c_optimize in
true) ;;
false) OPT_OPTS="" ;;
esac
case $low_level_debug in
true) LLDEBUG_OPTS="-DMR_LOWLEVEL_DEBUG" ;;
false) LLDEBUG_OPTS="" ;;
esac
#
# convert grade mgnuc options into gcc options
#
# IMPORTANT: any changes here may require similar changes to all the files
# mentioned in runtime/mercury_grade.h.
#
case $asm_labels in case $asm_labels in
true) ASM_OPTS="-DUSE_ASM_LABELS" ;; true) ASM_OPTS="-DUSE_ASM_LABELS" ;;
false) ASM_OPTS="" ;; false) ASM_OPTS="" ;;
@@ -215,29 +234,25 @@ case $global_regs in
false) REG_OPTS="" ;; false) REG_OPTS="" ;;
esac esac
case $stack_trace in case $thread_safe in
true) STACK_TRACE_OPTS="-DMR_STACK_TRACE" ;; true)
false) STACK_TRACE_OPTS="" ;; case $FULLARCH in
esac *solaris*) THREAD_OPTS="-DMR_THREAD_SAFE -DSOLARIS_THREADS \
-D_SOLARIS_PTHREADS -D_REENTRANT"
;;
case $require_tracing in *linux*) THREAD_OPTS="-DMR_THREAD_SAFE -DLINUX_THREADS \
true) TRACE_OPTS="-DMR_REQUIRE_TRACING" ;; -D_THREAD_SAFE -D_REENTRANT"
false) TRACE_OPTS="" ;; # Don't use -ansi under Linux or we get
esac # parse errors at sigset_t in the pthreads
# headers.
ANSI_OPTS=""
;;
case $c_debug in *) THREAD_OPTS=""
true) C_DEBUG_OPTS="-g" ;; ;;
false) C_DEBUG_OPTS="" ;; esac ;;
esac false) THREAD_OPTS="" ;;
case $c_optimize in
true) ;;
false) OPT_OPTS="" ;;
esac
case $low_level_debug in
true) LLDEBUG_OPTS="-DMR_LOWLEVEL_DEBUG" ;;
false) LLDEBUG_OPTS="" ;;
esac esac
case $gc_method in case $gc_method in
@@ -271,32 +286,21 @@ case $use_minimal_model in
false) MINIMAL_MODEL_OPTS="" ;; false) MINIMAL_MODEL_OPTS="" ;;
esac esac
case $thread_safe in
true)
case $FULLARCH in
*solaris*) THREAD_OPTS="-DMR_THREAD_SAFE -DSOLARIS_THREADS \
-D_SOLARIS_PTHREADS -D_REENTRANT"
;;
*linux*) THREAD_OPTS="-DMR_THREAD_SAFE -DLINUX_THREADS \
-D_THREAD_SAFE -D_REENTRANT"
# Don't use -ansi under Linux or we get
# parse errors at sigset_t in the pthreads
# headers.
ANSI_OPTS=""
;;
*) THREAD_OPTS=""
;;
esac ;;
false) THREAD_OPTS="" ;;
esac
case $pic_reg in case $pic_reg in
true) PICREG_OPTS="-DPIC_REG" ;; true) PICREG_OPTS="-DPIC_REG" ;;
false) PICREG_OPTS="" ;; false) PICREG_OPTS="" ;;
esac esac
case $stack_trace in
true) STACK_TRACE_OPTS="-DMR_STACK_TRACE" ;;
false) STACK_TRACE_OPTS="" ;;
esac
case $require_tracing in
true) TRACE_OPTS="-DMR_REQUIRE_TRACING" ;;
false) TRACE_OPTS="" ;;
esac
GRADE_OPTS="$ASM_OPTS $GOTO_OPTS $REG_OPTS" GRADE_OPTS="$ASM_OPTS $GOTO_OPTS $REG_OPTS"
# check that special grades are only used with gcc # check that special grades are only used with gcc

View File

@@ -14,6 +14,70 @@
# #
# Environment variables: MERCURY_C_LIB_DIR, MERCURY_DEFAULT_GRADE, ... # Environment variables: MERCURY_C_LIB_DIR, MERCURY_DEFAULT_GRADE, ...
FULLARCH=@FULLARCH@
NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@}
DEFAULT_LIBDIR=@LIBDIR@/lib
LIBDIR=${MERCURY_C_LIB_DIR=$DEFAULT_LIBDIR}
DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@}
# DEMANGLER=${MERCURY_DEMANGLER=@LIBDIR@/bin/@FULLARCH@/mdemangle}
DEMANGLER=${MERCURY_DEMANGLER=mdemangle}
CC=${MERCURY_C_COMPILER="@CC@"}
MKFIFO=${MERCURY_MKFIFO="@MKFIFO@"}
ERROR_UNDEFINED="@ERROR_UNDEFINED@"
ALLOW_UNDEFINED="@ALLOW_UNDEFINED@"
EXE_RPATH_OPT=${MERCURY_EXE_RPATH_OPT="@EXE_RPATH_OPT@"}
EXE_RPATH_SEP=${MERCURY_EXE_RPATH_SEP="@EXE_RPATH_SEP@"}
EXT_FOR_SHARED_LIB=${MERCURY_EXT_FOR_SHARED_LIB="@EXT_FOR_SHARED_LIB@"}
LINK_SHARED_OBJ=${MERCURY_LINK_SHARED_OBJ="@LINK_SHARED_OBJ@"}
SHLIB_RPATH_OPT=${MERCURY_SHLIB_RPATH_OPT="@SHLIB_RPATH_OPT@"}
SHLIB_RPATH_SEP=${MERCURY_SHLIB_RPATH_SEP="@SHLIB_RPATH_SEP@"}
SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS@"}
TMPDIR=${TMPDIR=/tmp}
# On some systems (Solaris for exemple), we need libraries to be able to
# use sockets. The name of the needed libraries is determined by autoconf
# and passed through this variable.
SOCKET_LIBRARY="@SOCKET_LIBRARY@"
NSL_LIBRARY="@NSL_LIBRARY@"
# Likewise for -ldl (libdl.so), which is often needed for dlopen() etc.
DL_LIBRARY="@DL_LIBRARY@"
# Likewise for -lreadline -l{termcap,curses,ncurses}
READLINE_LIBRARIES="@READLINE_LIBRARIES@"
# If you change these, you will also need to change Mmake.common.in,
# scripts/c2init.in, tools/bootcheck, tools/binary, tools/binary_step
# and tools/linear.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
verbose=false
allow_undefined=false
trace=false
readline=true
case $FULLARCH in
*-win95|*-winnt|*-win32|*-cygwin32|*-cygwin)
# `gcc -s' is broken in gnu-win32
strip=false
;;
*)
strip=true
;;
esac
mercury_libs=default
all_libs=default
demangle=true
MAYBE_STATIC_OPT=""
make_shared_lib=false
leave_shlib_dirs_relative=false
user_shlib_dirs=""
# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@
Help="\ Help="\
Name: ml - Mercury Linker Name: ml - Mercury Linker
Usage: ml [<ml options>] [-- <gcc options>] files... Usage: ml [<ml options>] [-- <gcc options>] files...
@@ -84,86 +148,7 @@ Debugging options:
-g, --c-debug, --no-strip -g, --c-debug, --no-strip
Do not strip C debugging information. Do not strip C debugging information.
Grade options: $grade_usage"
-s <grade>, --grade <grade>
--asm-labels
--gcc-non-local-gotos
--gcc-global-registers
--gc {conservative, accurate, none}
-p, --profiling
--profile-calls
--profile-time
--profile-memory
--debug
--low-level-debug
--use-trail
--pic-reg
See the documentation in the \"Invocation\" section
of the Mercury User's Guide."
FULLARCH=@FULLARCH@
NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@}
DEFAULT_LIBDIR=@LIBDIR@/lib
LIBDIR=${MERCURY_C_LIB_DIR=$DEFAULT_LIBDIR}
DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@}
# DEMANGLER=${MERCURY_DEMANGLER=@LIBDIR@/bin/@FULLARCH@/mdemangle}
DEMANGLER=${MERCURY_DEMANGLER=mdemangle}
CC=${MERCURY_C_COMPILER="@CC@"}
MKFIFO=${MERCURY_MKFIFO="@MKFIFO@"}
ERROR_UNDEFINED="@ERROR_UNDEFINED@"
ALLOW_UNDEFINED="@ALLOW_UNDEFINED@"
EXE_RPATH_OPT=${MERCURY_EXE_RPATH_OPT="@EXE_RPATH_OPT@"}
EXE_RPATH_SEP=${MERCURY_EXE_RPATH_SEP="@EXE_RPATH_SEP@"}
EXT_FOR_SHARED_LIB=${MERCURY_EXT_FOR_SHARED_LIB="@EXT_FOR_SHARED_LIB@"}
LINK_SHARED_OBJ=${MERCURY_LINK_SHARED_OBJ="@LINK_SHARED_OBJ@"}
SHLIB_RPATH_OPT=${MERCURY_SHLIB_RPATH_OPT="@SHLIB_RPATH_OPT@"}
SHLIB_RPATH_SEP=${MERCURY_SHLIB_RPATH_SEP="@SHLIB_RPATH_SEP@"}
SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS@"}
TMPDIR=${TMPDIR=/tmp}
# On some systems (Solaris for exemple), we need libraries to be able to
# use sockets. The name of the needed libraries is determined by autoconf
# and passed through this variable.
SOCKET_LIBRARY="@SOCKET_LIBRARY@"
NSL_LIBRARY="@NSL_LIBRARY@"
# Likewise for -ldl (libdl.so), which is often needed for dlopen() etc.
DL_LIBRARY="@DL_LIBRARY@"
# Likewise for -lreadline -l{termcap,curses,ncurses}
READLINE_LIBRARIES="@READLINE_LIBRARIES@"
# If you change these, you will also need to change Mmake.common.in,
# scripts/c2init.in, tools/bootcheck, tools/binary, tools/binary_step
# and tools/linear.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser
verbose=false
allow_undefined=false
trace=false
readline=true
case $FULLARCH in
*-win95|*-winnt|*-win32|*-cygwin32|*-cygwin)
# `gcc -s' is broken in gnu-win32
strip=false
;;
*)
strip=true
;;
esac
mercury_libs=default
all_libs=default
demangle=true
MAYBE_STATIC_OPT=""
make_shared_lib=false
leave_shlib_dirs_relative=false
user_shlib_dirs=""
# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@
while : ; do while : ; do
case "$1" in case "$1" in
@@ -374,6 +359,10 @@ case $asm_labels in
true) GRADE="asm_$GRADE" ;; true) GRADE="asm_$GRADE" ;;
false) ;; false) ;;
esac esac
case $thread_safe in
true) GRADE="$GRADE.par" ;;
false) ;;
esac
case $gc_method in case $gc_method in
conservative) GRADE="$GRADE.gc" ;; conservative) GRADE="$GRADE.gc" ;;
accurate) GRADE="$GRADE.agc" ;; accurate) GRADE="$GRADE.agc" ;;
@@ -395,16 +384,22 @@ case $use_trail in
true) GRADE="$GRADE.tr" ;; true) GRADE="$GRADE.tr" ;;
false) ;; false) ;;
esac esac
case $use_minimal_model in
true) GRADE="$GRADE.mm" ;;
false) ;;
esac
# We ignore the value of $picreg in computing the name of the grade
# that we will use as a directory name below.
# case $picreg in
# true) GRADE="$GRADE.picreg" ;;
# false) ;;
# esac
case $stack_trace,$require_tracing in case $stack_trace,$require_tracing in
true,true) GRADE="$GRADE.debug" ;; true,true) GRADE="$GRADE.debug" ;;
false,true) GRADE="$GRADE.trace" ;; false,true) GRADE="$GRADE.trace" ;;
true,false) GRADE="$GRADE.strce" ;; true,false) GRADE="$GRADE.strce" ;;
false,false) ;; false,false) ;;
esac esac
case $thread_safe in
true) GRADE="$GRADE.par" ;;
false) ;;
esac
case "$GRADE" in case "$GRADE" in
*.gc.prof*) *.gc.prof*)

View File

@@ -6,11 +6,17 @@
# #
# parse_grade_options.sh-subr: # parse_grade_options.sh-subr:
# An `sh' subroutine for parsing grade-related options. # An `sh' subroutine for parsing grade-related options.
# Used by the `ml' and `mgnuc' scripts. # Used by the `ml', `mgnuc' and `c2init' scripts.
# #
# The code here should be inserted in the case statement in a scripts # The code here should be inserted in the case statement in a script's
# option-parsing loop. # option-parsing loop.
# #
# IMPORTANT: any changes to the handling of grades here may also require
# changes to all the files indicated by runtime/mercury_grade.h.
#
# This file should handle the setting of all the shell variables defined by
# init_grade_options.sh-subr.
#
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
--asm-labels) --asm-labels)
@@ -28,26 +34,6 @@
--no-gcc-global-registers) --no-gcc-global-registers)
global_regs=false ;; global_regs=false ;;
--debug)
stack_trace=true
require_tracing=true
;;
--no-debug)
stack_trace=false
require_tracing=false
;;
# The following more fine-grained options have been omitted
# since they are not very useful and would probably only
# confuse people.
# --stack-trace)
# stack_trace=true ;;
# --no-stack-trace)
# stack_trace=false ;;
# --require-tracing)
# require_tracing=true ;;
# --no-require-tracing)
# require_tracing=false ;;
--gc) --gc)
shift shift
case "$1" in case "$1" in
@@ -119,6 +105,24 @@
--no-pic-reg) --no-pic-reg)
pic_reg=false ;; pic_reg=false ;;
# The following more fine-grained options have been omitted
# since they are not very useful and would probably only confuse people.
# --stack-trace)
# stack_trace=true ;;
# --no-stack-trace)
# stack_trace=false ;;
# --require-tracing)
# require_tracing=true ;;
# --no-require-tracing)
# require_tracing=false ;;
--debug)
stack_trace=true
require_tracing=true ;;
--no-debug)
stack_trace=false
require_tracing=false ;;
-s|--grade) -s|--grade)
shift shift
grade="$1"; grade="$1";
@@ -126,123 +130,139 @@
# Convert a grade to a set of options. # Convert a grade to a set of options.
# #
# IMPORTANT: any changes to the handling of grades here # IMPORTANT: any changes to the handling of grades here
# may also require changes to # may also require changes to all the files indicated by
# runtime/mercury_grade.h # runtime/mercury_grade.h.
# compiler/handle_options.m
# scripts/ml.in
asm_labels=false asm_labels=false
non_local_gotos=false non_local_gotos=false
global_regs=false global_regs=false
gc_method=none thread_safe=false
profile_time=false gc_method=none
profile_calls=false profile_time=false
profile_memory=false profile_calls=false
use_trail=false profile_memory=false
use_minimal_model=false profile_deep=false
stack_trace=false use_trail=false
require_tracing=false use_minimal_model=false
low_level_debug=false pic_reg=false
thread_safe=false stack_trace=false
require_tracing=false
grade_pieces=`echo $grade | tr '.' ' '` grade_pieces=`echo $grade | tr '.' ' '`
for grade_piece in $grade_pieces for grade_piece in $grade_pieces
do do
case "$grade_piece" in case "$grade_piece" in
debug) asm_fast)
stack_trace=true asm_labels=true
require_tracing=true non_local_gotos=true
;; global_regs=true
# The following alternatives have been omitted since ;;
# they're not very useful and would probably just confuse people. asm_jump)
# trace) asm_labels=true
# stack_trace=false non_local_gotos=true
# require_tracing=true global_regs=false
# ;; ;;
# strce) fast)
# stack_trace=true asm_labels=false
# require_tracing=false non_local_gotos=true
# ;; global_regs=true
tr) use_trail=true ;;
;; jump)
mm) use_minimal_model=true asm_labels=false
;; non_local_gotos=true
memprof) global_regs=false
profile_time=false ;;
profile_calls=true reg)
profile_memory=true asm_labels=false
profile_deep=false non_local_gotos=false
;; global_regs=true
prof) ;;
profile_time=true none)
profile_calls=true asm_labels=false
profile_memory=false non_local_gotos=false
profile_deep=false global_regs=false
;; ;;
proftime)
profile_time=true par)
profile_calls=false thread_safe=true
profile_memory=false ;;
profile_deep=false
;; agc)
profcalls) gc_method=accurate
profile_time=false ;;
profile_calls=true gc)
profile_memory=false gc_method=conservative
profile_deep=false ;;
;; nogc)
profall) gc_method=none
profile_time=true ;;
profile_calls=true
profile_memory=true memprof)
profile_deep=false profile_time=false
;; profile_calls=true
profdeep) profile_memory=true
profile_time=true profile_deep=false
profile_calls=false ;;
profile_memory=false prof)
profile_deep=true profile_time=true
;; profile_calls=true
agc) gc_method=accurate profile_memory=false
;; profile_deep=false
gc) gc_method=conservative ;;
;; proftime)
nogc) gc_method=none profile_time=true
;; profile_calls=false
par) thread_safe=true profile_memory=false
;; profile_deep=false
asm_fast) ;;
asm_labels=true profcalls)
non_local_gotos=true profile_time=false
global_regs=true profile_calls=true
;; profile_memory=false
asm_jump) profile_deep=false
asm_labels=true ;;
non_local_gotos=true profall)
;; profile_time=true
fast) profile_calls=true
asm_labels=false profile_memory=true
non_local_gotos=true profile_deep=false
global_regs=true ;;
;; profdeep)
jump) profile_time=true
asm_labels=false profile_calls=false
non_local_gotos=true profile_memory=false
global_regs=false profile_deep=true
;; ;;
reg)
asm_labels=false tr)
non_local_gotos=false use_trail=true
global_regs=true ;;
;;
none) mm)
asm_labels=false use_minimal_model=true
non_local_gotos=false ;;
global_regs=false
;; picreg)
esac pic_reg=true
done ;;
;;
# The following more fine-grained options have been omitted
# since they are not very useful and would probably only confuse people.
# trace)
# stack_trace=false
# require_tracing=true
#
# strce)
# stack_trace=true
# require_tracing=false
debug)
stack_trace=true
require_tracing=true
;;
esac
done
;;
-s*) -s*)
grade="` expr $1 : '-s\(.*\)' `" grade="` expr $1 : '-s\(.*\)' `"