From 22840901fd44b64d4abe7f06b27a95ddd588e37d Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Tue, 9 Nov 1999 01:45:43 +0000 Subject: [PATCH] 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. --- compiler/handle_options.m | 45 ++--- runtime/mercury_conf_param.h | 1 - runtime/mercury_grade.h | 10 +- scripts/c2init.in | 64 +++--- scripts/final_grade_options.sh-subr | 8 +- scripts/init_grade_options.sh-subr | 35 +++- scripts/mgnuc.in | 168 ++++++++-------- scripts/ml.in | 163 ++++++++------- scripts/parse_grade_options.sh-subr | 294 +++++++++++++++------------- 9 files changed, 414 insertions(+), 374 deletions(-) diff --git a/compiler/handle_options.m b/compiler/handle_options.m index e6a292994..27b15336a 100644 --- a/compiler/handle_options.m +++ b/compiler/handle_options.m @@ -573,15 +573,14 @@ long_usage --> % grade of the library, etc for linking (and installation). :- type grade_component ---> gcc_ext % gcc extensions -- see grade_component_table + ; par % parallelism / multithreading ; gc % the kind of GC to use ; prof % what profiling options to use ; trail % whether or not to use trailing ; 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 (position independent code)? + ; trace % tracing/debugging options . convert_grade_option(GradeString, Options0, Options) :- @@ -658,11 +657,9 @@ compute_grade_components(Options, GradeComponents) :- :- pred grade_component_table(string, grade_component, list(pair(option, option_data))). :- 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. - % Args method components -grade_component_table("sa", args, [args - string("simple")]). - % GCC-hack components grade_component_table("none", gcc_ext, [asm_labels - 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), gcc_non_local_gotos - bool(yes), gcc_global_registers - bool(yes)]). + % Parallelism/multithreading components. +grade_component_table("par", par, [parallel - bool(yes)]). + % GC components grade_component_table("gc", gc, [gc - string("conservative")]). 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 grade_component_table("prof", prof, [profile_time - 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_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 grade_component_table("debug", trace, [stack_trace - bool(yes), require_tracing - bool(yes)]). grade_component_table("trace", trace, [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)]). - % 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). :- 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)). :- mode grade_start_values(out) is multi. -grade_start_values(args - string("compact")). grade_start_values(asm_labels - bool(no)). grade_start_values(gcc_non_local_gotos - 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(pic_reg - bool(no)). +grade_start_values(gc - string("none")). grade_start_values(profile_deep - bool(no)). grade_start_values(profile_time - bool(no)). grade_start_values(profile_calls - 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_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)). :- mode split_grade_string(in, out) is semidet. diff --git a/runtime/mercury_conf_param.h b/runtime/mercury_conf_param.h index 227c095f5..579a3a9b4 100644 --- a/runtime/mercury_conf_param.h +++ b/runtime/mercury_conf_param.h @@ -54,7 +54,6 @@ ** --gcc-asm-labels ** --gc conservative ** --gc accurate [not yet working] -** --args compact ** --no-type-layout ** --unboxed-float ** --use-trail diff --git a/runtime/mercury_grade.h b/runtime/mercury_grade.h index 4a9212a09..5409af713 100644 --- a/runtime/mercury_grade.h +++ b/runtime/mercury_grade.h @@ -10,13 +10,16 @@ ** This is used to get the linker to ensure that different object files ** were compiled with consistent grades. ** -** Any condition compilation macros that affect link compatibility -** should be included here. -** For documentation on the meaning of these macros, see +** Any condition compilation macros that affect link compatibility should be +** included here. For documentation on the meaning of these macros, see ** runtime/mercury_conf_param.h. ** ** 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/final_grade_options.sh-subr +** scripts/mgnuc.in ** scripts/ml.in ** compiler/handle_options.m ** compiler/mercury_compile.m @@ -87,6 +90,7 @@ #else #define MR_GRADE_PART_3 MR_GRADE_PART_2 #endif + #ifdef CONSERVATIVE_GC #define MR_GRADE_PART_4 MR_PASTE2(MR_GRADE_PART_3, _gc) #elif defined(NATIVE_GC) diff --git a/scripts/c2init.in b/scripts/c2init.in index 32435fbd0..26f77503a 100755 --- a/scripts/c2init.in +++ b/scripts/c2init.in @@ -12,6 +12,30 @@ # 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 # message, so if you change the help message, don't forget to check # that the manpage still looks OK. @@ -53,49 +77,13 @@ Options: hand-coded C code with \`INIT' comments, rather than containing only C code that was automatically generated by the Mercury compiler.) - -s , --grade - --asm-labels - --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. + +$grade_usage Environment variables: 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 case "$1" in -a|--aditi) diff --git a/scripts/final_grade_options.sh-subr b/scripts/final_grade_options.sh-subr index 83b050a0b..a200dc9a4 100644 --- a/scripts/final_grade_options.sh-subr +++ b/scripts/final_grade_options.sh-subr @@ -6,11 +6,17 @@ # # final_grade_options.sh-subr: # 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 # 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. +# #---------------------------------------------------------------------------# # diff --git a/scripts/init_grade_options.sh-subr b/scripts/init_grade_options.sh-subr index 747ac563e..5b9a27541 100644 --- a/scripts/init_grade_options.sh-subr +++ b/scripts/init_grade_options.sh-subr @@ -6,16 +6,46 @@ # # init_grade_options.sh-subr: # 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 # 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 + --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 non_local_gotos=true global_regs=true +thread_safe=false gc_method=conservative profile_time=false profile_calls=false @@ -23,10 +53,9 @@ profile_memory=false profile_deep=false use_trail=false use_minimal_model=false +pic_reg=false stack_trace=false require_tracing=false -low_level_debug=false -thread_safe=false case $# in 0) set - "--grade $DEFAULT_GRADE" ;; diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in index c72223e94..53f736b1d 100644 --- a/scripts/mgnuc.in +++ b/scripts/mgnuc.in @@ -9,46 +9,7 @@ # IMPORTANT: the manpage is produced automatically from this help # message, so if you change the help message, don't forget to check # that the manpage still looks OK. -Help="\ -Name: mgnuc - Mercury front-end to GNU C -Usage: mgnuc [] [-- ] 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 - --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 *** # *** changes to compiler/mercury_compile.m *** @@ -116,6 +77,42 @@ c_optimize=true # include the file `init_grade_options.sh-subr' @INIT_GRADE_OPTIONS@ +Help="\ +Name: mgnuc - Mercury front-end to GNU C +Usage: mgnuc [] [-- ] 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 case "$1" in -h|--help|"-?") @@ -194,12 +191,34 @@ done @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 # 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 true) ASM_OPTS="-DUSE_ASM_LABELS" ;; false) ASM_OPTS="" ;; @@ -215,29 +234,25 @@ case $global_regs in false) REG_OPTS="" ;; esac -case $stack_trace in - true) STACK_TRACE_OPTS="-DMR_STACK_TRACE" ;; - false) STACK_TRACE_OPTS="" ;; -esac +case $thread_safe in + true) + case $FULLARCH in + *solaris*) THREAD_OPTS="-DMR_THREAD_SAFE -DSOLARIS_THREADS \ + -D_SOLARIS_PTHREADS -D_REENTRANT" + ;; -case $require_tracing in - true) TRACE_OPTS="-DMR_REQUIRE_TRACING" ;; - false) TRACE_OPTS="" ;; -esac + *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="" + ;; -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="" ;; + *) THREAD_OPTS="" + ;; + esac ;; + false) THREAD_OPTS="" ;; esac case $gc_method in @@ -271,32 +286,21 @@ case $use_minimal_model in false) MINIMAL_MODEL_OPTS="" ;; 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 true) PICREG_OPTS="-DPIC_REG" ;; false) PICREG_OPTS="" ;; 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" # check that special grades are only used with gcc diff --git a/scripts/ml.in b/scripts/ml.in index 0b1969e13..5ad0d1733 100644 --- a/scripts/ml.in +++ b/scripts/ml.in @@ -14,6 +14,70 @@ # # 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="\ Name: ml - Mercury Linker Usage: ml [] [-- ] files... @@ -84,86 +148,7 @@ Debugging options: -g, --c-debug, --no-strip Do not strip C debugging information. -Grade options: - -s , --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@ +$grade_usage" while : ; do case "$1" in @@ -374,6 +359,10 @@ case $asm_labels in true) GRADE="asm_$GRADE" ;; false) ;; esac +case $thread_safe in + true) GRADE="$GRADE.par" ;; + false) ;; +esac case $gc_method in conservative) GRADE="$GRADE.gc" ;; accurate) GRADE="$GRADE.agc" ;; @@ -395,16 +384,22 @@ case $use_trail in true) GRADE="$GRADE.tr" ;; false) ;; 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 true,true) GRADE="$GRADE.debug" ;; false,true) GRADE="$GRADE.trace" ;; true,false) GRADE="$GRADE.strce" ;; false,false) ;; esac -case $thread_safe in - true) GRADE="$GRADE.par" ;; - false) ;; -esac case "$GRADE" in *.gc.prof*) diff --git a/scripts/parse_grade_options.sh-subr b/scripts/parse_grade_options.sh-subr index 06ecbaba1..0db3c1810 100644 --- a/scripts/parse_grade_options.sh-subr +++ b/scripts/parse_grade_options.sh-subr @@ -6,11 +6,17 @@ # # parse_grade_options.sh-subr: # 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. # +# 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) @@ -28,26 +34,6 @@ --no-gcc-global-registers) 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) shift case "$1" in @@ -119,6 +105,24 @@ --no-pic-reg) 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) shift grade="$1"; @@ -126,123 +130,139 @@ # Convert a grade to a set of options. # # IMPORTANT: any changes to the handling of grades here - # may also require changes to - # runtime/mercury_grade.h - # compiler/handle_options.m - # scripts/ml.in + # may also require changes to all the files indicated by + # runtime/mercury_grade.h. - asm_labels=false - non_local_gotos=false - global_regs=false - gc_method=none - profile_time=false - profile_calls=false - profile_memory=false - use_trail=false - use_minimal_model=false - stack_trace=false - require_tracing=false - low_level_debug=false - thread_safe=false + asm_labels=false + non_local_gotos=false + global_regs=false + thread_safe=false + gc_method=none + profile_time=false + profile_calls=false + profile_memory=false + profile_deep=false + use_trail=false + use_minimal_model=false + pic_reg=false + stack_trace=false + require_tracing=false - grade_pieces=`echo $grade | tr '.' ' '` - for grade_piece in $grade_pieces - do - case "$grade_piece" in - debug) - stack_trace=true - require_tracing=true - ;; -# The following alternatives have been omitted since -# they're not very useful and would probably just confuse people. -# trace) -# stack_trace=false -# require_tracing=true -# ;; -# strce) -# stack_trace=true -# require_tracing=false -# ;; - tr) use_trail=true - ;; - mm) use_minimal_model=true - ;; - memprof) - profile_time=false - profile_calls=true - profile_memory=true - profile_deep=false - ;; - prof) - profile_time=true - profile_calls=true - profile_memory=false - profile_deep=false - ;; - proftime) - profile_time=true - profile_calls=false - profile_memory=false - profile_deep=false - ;; - profcalls) - profile_time=false - profile_calls=true - profile_memory=false - profile_deep=false - ;; - profall) - profile_time=true - profile_calls=true - profile_memory=true - profile_deep=false - ;; - profdeep) - profile_time=true - profile_calls=false - profile_memory=false - profile_deep=true - ;; - agc) gc_method=accurate - ;; - gc) gc_method=conservative - ;; - nogc) gc_method=none - ;; - par) thread_safe=true - ;; - asm_fast) - asm_labels=true - non_local_gotos=true - global_regs=true - ;; - asm_jump) - asm_labels=true - non_local_gotos=true - ;; - fast) - asm_labels=false - non_local_gotos=true - global_regs=true - ;; - jump) - asm_labels=false - non_local_gotos=true - global_regs=false - ;; - reg) - asm_labels=false - non_local_gotos=false - global_regs=true - ;; - none) - asm_labels=false - non_local_gotos=false - global_regs=false - ;; - esac - done - ;; + grade_pieces=`echo $grade | tr '.' ' '` + for grade_piece in $grade_pieces + do + case "$grade_piece" in + asm_fast) + asm_labels=true + non_local_gotos=true + global_regs=true + ;; + asm_jump) + asm_labels=true + non_local_gotos=true + global_regs=false + ;; + fast) + asm_labels=false + non_local_gotos=true + global_regs=true + ;; + jump) + asm_labels=false + non_local_gotos=true + global_regs=false + ;; + reg) + asm_labels=false + non_local_gotos=false + global_regs=true + ;; + none) + asm_labels=false + non_local_gotos=false + global_regs=false + ;; + + par) + thread_safe=true + ;; + + agc) + gc_method=accurate + ;; + gc) + gc_method=conservative + ;; + nogc) + gc_method=none + ;; + + memprof) + profile_time=false + profile_calls=true + profile_memory=true + profile_deep=false + ;; + prof) + profile_time=true + profile_calls=true + profile_memory=false + profile_deep=false + ;; + proftime) + profile_time=true + profile_calls=false + profile_memory=false + profile_deep=false + ;; + profcalls) + profile_time=false + profile_calls=true + profile_memory=false + profile_deep=false + ;; + profall) + profile_time=true + profile_calls=true + profile_memory=true + profile_deep=false + ;; + profdeep) + profile_time=true + profile_calls=false + profile_memory=false + profile_deep=true + ;; + + tr) + use_trail=true + ;; + + mm) + use_minimal_model=true + ;; + + picreg) + pic_reg=true + ;; + +# 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*) grade="` expr $1 : '-s\(.*\)' `"