[m-rev.] for review: align functions in trailing grades

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Jan 22 19:05:52 AEDT 2008


Estimated hours taken: 6
Branches: main

In trailing grades, pass flags to the C compiler that force it to align
functions on word boundaries.  For some architectures, and for some C compiler
optimisation settings, function addresses are not aligned and this breaks
function trailing when using tagged trail entries.

XXX this diff only fixes the problem for gcc, it's not clear what,
if anything, needs to be done for other C compilers.

configure.in:
 	s/COMPILER/C_COMPILER_TYPE/.  The former is ambiguous as
 	Mercury uses compilers for several languages.

 	Instantiate the value of C_COMPILER_TYPE in files generated
 	by the configure script.

 	Add an XXX comment about how the type of the C compiler
 	is determined.

 	Clean up a few things.

compiler/globals.m:
 	Define a type, c_compiler_type/0, that represents the type
 	of C compiler we are using.  (This type replaces the old
 	compiler_type/0 type from compile_target_code.m).

 	Add a new field to the globals structure that stores the
 	C compiler type.

 	Add access and utility procedures for the new field.

 	Delete some business with unique modes that used to be
 	required when the I/O globals field was unique.

compiler/options.m:
 	Simplify the implementation of `--c-compiler-type'.
 	Most of it is now handled by the globals module.

scripts/Mercury.config.in:
 	Define a new variable MERCURY_C_COMPILER_TYPE, whose value
 	is set by the configuration script.

 	Pass the C compiler type to the Mercury compiler.

compiler/compile_target_code.m:
scripts/mgnuc.in:
 	When in a trailing grade and using gcc as a C compiler align
 	functions on word boundaries in order to avoid problems
 	with function trailing.

 	Delete the unused type compiler_type/0.

tests/trailing/Mercury.options:
 	Remove a workaround for the function alignment problem.

Julien.

Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.513
diff -u -r1.513 configure.in
--- configure.in	22 Jan 2008 02:36:36 -0000	1.513
+++ configure.in	22 Jan 2008 07:58:07 -0000
@@ -3818,11 +3818,17 @@
  esac

  #-----------------------------------------------------------------------------#
-# Note that changes here may require changes in scripts/mgnuc.in.
+#
+# Note that changes here may require changes in scripts/mgnuc.in and
+# compiler/compile_target_code.m.
+#
+
+# XXX we should not just rely on pattern matching against the executable
+# name to determine the C compiler type.

  case "$CC" in
  	*gcc*)
-		COMPILER=gcc
+		C_COMPILER_TYPE=gcc
  		CFLAGS_FOR_ANSI="-ansi"

  		# For a full list of the other gcc warnings that we don't
@@ -3833,19 +3839,21 @@
  		CFLAGS_FOR_DEBUG="-g"
  		MCFLAGS_FOR_CC=
  		;;
+
  	*lcc*)
-		COMPILER=lcc
+		C_COMPILER_TYPE=lcc
  		CFLAGS_FOR_ANSI=

-		# turn off all warnings due to spurious warnings.
+		# Turn off all warnings due to spurious warnings.
  		CFLAGS_FOR_WARNINGS="-w"

  		CFLAGS_FOR_OPT=
  		CFLAGS_FOR_DEBUG="-g"
  		MCFLAGS_FOR_CC=
  		;;
+
  	*cl* | *CL*)
-		COMPILER=cl
+		C_COMPILER_TYPE=cl
  		CFLAGS_FOR_ANSI=
  		CFLAGS_FOR_WARNINGS=
  		CFLAGS_FOR_OPT=
@@ -3856,16 +3864,18 @@
  		# in the compiler.
  		MCFLAGS_FOR_CC="--max-jump-table-size 512"
  		;;
+
  	cc* | */cc*)
-		COMPILER=cc
+		C_COMPILER_TYPE=unknown
  		CFLAGS_FOR_ANSI=
  		CFLAGS_FOR_OPT="-O"
  		CFLAGS_FOR_WARNINGS=
  		CFLAGS_FOR_DEBUG="-g"
  		MCFLAGS_FOR_CC=
  		;;
+
  	*)
-		COMPILER=unknown
+		C_COMPILER_TYPE=unknown
  		CFLAGS_FOR_ANSI=
  		CFLAGS_FOR_OPT="-O"
  		CFLAGS_FOR_WARNINGS=
@@ -3876,11 +3886,12 @@

  CFLAGS_FOR_OPT="$CFLAGS_FOR_OPT $CFLAGS_FOR_NO_STRICT_ALIASING"

-AC_SUBST(CFLAGS_FOR_ANSI)
-AC_SUBST(CFLAGS_FOR_WARNINGS)
-AC_SUBST(CFLAGS_FOR_OPT)
-AC_SUBST(CFLAGS_FOR_DEBUG)
-AC_SUBST(MCFLAGS_FOR_CC)
+AC_SUBST([CFLAGS_FOR_ANSI])
+AC_SUBST([CFLAGS_FOR_WARNINGS])
+AC_SUBST([CFLAGS_FOR_OPT])
+AC_SUBST([CFLAGS_FOR_DEBUG])
+AC_SUBST([MCFLAGS_FOR_CC])
+AC_SUBST([C_COMPILER_TYPE])

  #-----------------------------------------------------------------------------#
  #
@@ -3890,7 +3901,7 @@
  # Note that changes here may require changes in scripts/ml.in.

  LD_STATIC_FLAGS=
-case "$COMPILER" in gcc|lcc)
+case "$C_COMPILER_TYPE" in gcc|lcc)
  	LD_STATIC_FLAGS=-static
  	;;
  esac
@@ -3902,7 +3913,7 @@
  		# boehm_gc/dyn_load.c.
  		# (We might eventually need similar treatment
  		# for other OSs too.)
-		case "$COMPILER" in
+		case "$C_COMPILER_TYPE" in
  		gcc)
  			LD_STATIC_FLAGS="-static -Wl-defsym -Wl_DYNAMIC=0"
  			;;
@@ -3910,7 +3921,7 @@
  			# for lcc 4.1, we need to use "-Wl,".
  			# for lcc 4.2, we need to use "-Wl" without the comma,
  			# like we do for gcc.
-			AC_MSG_CHECKING(whether lcc requires comma after -Wl)
+			AC_MSG_CHECKING([whether lcc requires comma after -Wl])
  			LD_STATIC_FLAGS="-static -Wl-defsym -Wl_DYNAMIC=0"
  			rm -f conftest*
  			echo "int main() { return 0; }" > conftest.c
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.124
diff -u -r1.124 compile_target_code.m
--- compiler/compile_target_code.m	23 Nov 2007 07:34:57 -0000	1.124
+++ compiler/compile_target_code.m	22 Jan 2008 07:58:07 -0000
@@ -345,12 +345,6 @@
  % WARNING: The code here duplicates the functionality of scripts/mgnuc.in.
  % Any changes there may also require changes here, and vice versa.

-:- type compiler_type
-    --->    gcc
-    ;       lcc
-    ;       cl
-    ;       unknown_compiler.
-
  compile_c_file(ErrorStream, PIC, ModuleName, Succeeded, !IO) :-
      module_name_to_file_name(ModuleName, ".c", yes, C_File, !IO),
      maybe_pic_object_file_extension(PIC, ObjExt, !IO),
@@ -626,10 +620,34 @@
      globals.io_lookup_bool_option(use_trail, UseTrail, !IO),
      (
          UseTrail = yes,
-        UseTrailOpt = "-DMR_USE_TRAIL "
+        UseTrailOpt = "-DMR_USE_TRAIL ",
+        % With tagged trail entries function trailing will not work unless the
+        % C functions stored on the trail are aligned on word boundaries (or a
+        % multiple thereof).  The assemblers on some systems, and some gcc
+        % optimisation settings, do not align functions, so we need to
+        % explicitly pass -falign-functions in trailing grades to ensure that
+        % C functions are appropriately aligned.
+        %
+        io_get_c_compiler_type(C_CompilerType, !IO),
+        (
+            C_CompilerType = cc_gcc,
+            globals.io_lookup_int_option(bytes_per_word, BytesPerWord, !IO),
+            C_FnAlignOpt = string.format("-falign-functions=%d ",
+                [i(BytesPerWord)])
+        ;
+            % XXX Check whether we need to do anything for these C compilers?
+            ( C_CompilerType = cc_lcc
+            ; C_CompilerType = cc_cl
+            ),
+            C_FnAlignOpt = ""
+        ;
+            C_CompilerType = cc_unknown,
+            C_FnAlignOpt = ""
+        )
      ;
          UseTrail = no,
-        UseTrailOpt = ""
+        UseTrailOpt = "",
+        C_FnAlignOpt = ""
      ),
      globals.io_lookup_bool_option(use_minimal_model_stack_copy,
          MinimalModelStackCopy, !IO),
@@ -795,6 +813,7 @@
          InlineAllocOpt,
          AnsiOpt, " ",
          AppleGCCRegWorkaroundOpt,
+        C_FnAlignOpt,
          WarningOpt, " ",
          CFLAGS,
          " -c ", C_File, " ",
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.86
diff -u -r1.86 globals.m
--- compiler/globals.m	5 Dec 2007 05:07:32 -0000	1.86
+++ compiler/globals.m	22 Jan 2008 07:58:07 -0000
@@ -120,6 +120,14 @@
      ;       norm_num_data_elems
      ;       norm_size_data_elems.

+    % For the C backends, what type of C compiler are we using?
+    % 
+:- type c_compiler_type
+    --->    cc_gcc
+    ;       cc_lcc
+    ;       cc_cl
+    ;       cc_unknown.
+
      % Map from module name to file name.
      %
  :- type source_file_map == map(module_name, string).
@@ -133,16 +141,18 @@
  :- pred convert_termination_norm(string::in, termination_norm::out) is semidet.
  :- pred convert_maybe_thread_safe(string::in, may_be_thread_safe::out)
      is semidet.
+:- pred convert_c_compiler_type(string::in, c_compiler_type::out)
+    is semidet.

  %-----------------------------------------------------------------------------%
  %
  % Access predicates for the `globals' structure
  %

-:- pred globals_init(option_table::in, compilation_target::di, gc_method::di,
-    tags_method::di, termination_norm::di, termination_norm::di,
-    trace_level::di, trace_suppress_items::di,
-    may_be_thread_safe::di, globals::out) is det.
+:- pred globals_init(option_table::in, compilation_target::in, gc_method::in,
+    tags_method::in, termination_norm::in, termination_norm::in,
+    trace_level::in, trace_suppress_items::in,
+    may_be_thread_safe::in, c_compiler_type::in, globals::out) is det.

  :- pred get_options(globals::in, option_table::out) is det.
  :- pred get_target(globals::in, compilation_target::out) is det.
@@ -156,6 +166,7 @@
  :- pred get_trace_suppress(globals::in, trace_suppress_items::out) is det.
  :- pred get_source_file_map(globals::in, maybe(source_file_map)::out) is det.
  :- pred get_maybe_thread_safe(globals::in, may_be_thread_safe::out) is det.
+:- pred get_c_compiler_type(globals::in, c_compiler_type::out) is det.

  :- pred set_option(option::in, option_data::in, globals::in, globals::out)
      is det.
@@ -224,7 +235,7 @@
  :- pred globals_io_init(option_table::in, compilation_target::in,
      gc_method::in, tags_method::in, termination_norm::in,
      termination_norm::in, trace_level::in, trace_suppress_items::in,
-    may_be_thread_safe::in, io::di, io::uo) is det.
+    may_be_thread_safe::in, c_compiler_type::in, io::di, io::uo) is det.

  :- pred io_get_target(compilation_target::out, io::di, io::uo) is det.
  :- pred io_get_backend_foreign_languages(list(foreign_language)::out,
@@ -243,9 +254,12 @@

  :- pred io_get_trace_suppress(trace_suppress_items::out, io::di, io::uo)
      is det.
+
  :- pred io_get_maybe_thread_safe(may_be_thread_safe::out, io::di, io::uo)
      is det.

+:- pred io_get_c_compiler_type(c_compiler_type::out, io::di, io::uo) is det.
+
  :- pred io_get_extra_error_info(bool::out, io::di, io::uo) is det.

      % This is semipure because it is called in a context in which the I/O
@@ -342,6 +356,11 @@
  convert_maybe_thread_safe("yes", yes).
  convert_maybe_thread_safe("no",  no).

+convert_c_compiler_type("gcc",      cc_gcc).
+convert_c_compiler_type("lcc",      cc_lcc).
+convert_c_compiler_type("cl",       cc_cl).
+convert_c_compiler_type("unknown",  cc_unknown).
+
  compilation_target_string(target_c)    = "C".
  compilation_target_string(target_il)   = "IL".
  compilation_target_string(target_java) = "Java".
@@ -382,7 +401,8 @@
                  trace_suppress_items    :: trace_suppress_items,
                  source_file_map         :: maybe(source_file_map),
                  have_printed_usage      :: bool,
-                may_be_thread_safe      :: bool
+                may_be_thread_safe      :: bool,
+                c_compiler_type         :: c_compiler_type
              ).

  :- mutable(globals, univ, univ(0), ground,
@@ -409,10 +429,10 @@

  globals_init(Options, Target, GC_Method, TagsMethod,
          TerminationNorm, Termination2Norm, TraceLevel, TraceSuppress,
-        MaybeThreadSafe,
-    globals(Options, Target, GC_Method, TagsMethod,
+        MaybeThreadSafe, C_CompilerType, Globals) :-
+    Globals = globals(Options, Target, GC_Method, TagsMethod,
          TerminationNorm, Termination2Norm, TraceLevel, TraceSuppress,
-        no, no, MaybeThreadSafe)).
+        no, no, MaybeThreadSafe, C_CompilerType).

  get_options(Globals, Globals ^ options).
  get_target(Globals, Globals ^ target).
@@ -424,6 +444,7 @@
  get_trace_suppress(Globals, Globals ^ trace_suppress_items).
  get_source_file_map(Globals, Globals ^ source_file_map).
  get_maybe_thread_safe(Globals, Globals ^ may_be_thread_safe).
+get_c_compiler_type(Globals, Globals ^ c_compiler_type).

  get_backend_foreign_languages(Globals, ForeignLangs) :-
      lookup_accumulating_option(Globals, backend_foreign_languages, LangStrs),
@@ -620,18 +641,11 @@
  %-----------------------------------------------------------------------------%

  globals_io_init(Options, Target, GC_Method, TagsMethod, TerminationNorm,
-        Termination2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !IO) :-
-    copy(Target, Target1),
-    copy(GC_Method, GC_Method1),
-    copy(TagsMethod, TagsMethod1),
-    copy(TerminationNorm, TerminationNorm1),
-    copy(Termination2Norm, Termination2Norm1),
-    copy(TraceLevel, TraceLevel1),
-    copy(TraceSuppress, TraceSuppress1),
-    copy(MaybeThreadSafe, MaybeThreadSafe1),
-    globals_init(Options, Target1, GC_Method1, TagsMethod1,
-        TerminationNorm1, Termination2Norm1, TraceLevel1,
-        TraceSuppress1, MaybeThreadSafe1, Globals),
+        Termination2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe,
+        C_CompilerType, !IO) :-
+    globals_init(Options, Target, GC_Method, TagsMethod,
+        TerminationNorm, Termination2Norm, TraceLevel,
+        TraceSuppress, MaybeThreadSafe, C_CompilerType, Globals),
      io_set_globals(Globals, !IO),
      getopt_io.lookup_bool_option(Options, solver_type_auto_init,
          AutoInitSupported),
@@ -669,6 +683,10 @@
      io_get_globals(Globals, !IO),
      get_maybe_thread_safe(Globals, MaybeThreadSafe).

+io_get_c_compiler_type(C_CompilerType, !IO) :-
+    io_get_globals(Globals, !IO),
+    get_c_compiler_type(Globals,  C_CompilerType).
+
  io_get_extra_error_info(ExtraErrorInfo, !IO) :-
      get_extra_error_info(ExtraErrorInfo, !IO).

Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.316
diff -u -r1.316 handle_options.m
--- compiler/handle_options.m	15 Jan 2008 05:45:46 -0000	1.316
+++ compiler/handle_options.m	22 Jan 2008 07:58:07 -0000
@@ -187,12 +187,13 @@
  postprocess_options(ok(OptionTable0), Errors, !IO) :-
      check_option_values(OptionTable0, OptionTable, Target, GC_Method,
          TagsMethod, TermNorm, Term2Norm, TraceLevel, TraceSuppress,
-        MaybeThreadSafe, [], CheckErrors),
+        MaybeThreadSafe, C_CompilerType, [], CheckErrors),
      (
          CheckErrors = [],
          postprocess_options_2(OptionTable, Target, GC_Method,
              TagsMethod, TermNorm, Term2Norm, TraceLevel,
-            TraceSuppress, MaybeThreadSafe, [], Errors, !IO)
+            TraceSuppress, MaybeThreadSafe, C_CompilerType,
+            [], Errors, !IO)
      ;
          CheckErrors = [_ | _],
          Errors = CheckErrors
@@ -202,11 +203,12 @@
      compilation_target::out, gc_method::out, tags_method::out,
      termination_norm::out, termination_norm::out, trace_level::out,
      trace_suppress_items::out, may_be_thread_safe::out,
+    c_compiler_type::out,
      list(string)::in, list(string)::out) is det.

  check_option_values(!OptionTable, Target, GC_Method, TagsMethod,
          TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe,
-        !Errors) :-
+        C_CompilerType, !Errors) :-
      map.lookup(!.OptionTable, target, Target0),
      (
          Target0 = string(TargetStr),
@@ -340,8 +342,20 @@
          svmap.set(dump_hlds_options, string(DumpOptions), !OptionTable)
      ;
          add_error("Invalid argument to option `--hlds-dump-alias'.", !Errors)
-    ).
-
+    ),
+    map.lookup(!.OptionTable, c_compiler_type, C_CompilerType0),
+    (
+        C_CompilerType0 = string(C_CompilerTypeStr),
+        convert_c_compiler_type(C_CompilerTypeStr, C_CompilerTypePrime)
+    ->
+        C_CompilerType = C_CompilerTypePrime
+    ;
+        C_CompilerType = cc_unknown,   % dummy
+        add_error("Invalid argument to option " ++
+            "`--c-compiler-type'\n\t(must be" ++
+            "`gcc', `lcc', `cl, or `unknown').", !Errors)
+    ). 
+
  :- pred add_error(string::in, list(string)::in, list(string)::out) is det.

  add_error(Error, Errors0, Errors) :-
@@ -354,14 +368,15 @@
  :- pred postprocess_options_2(option_table::in, compilation_target::in,
      gc_method::in, tags_method::in, termination_norm::in,
      termination_norm::in, trace_level::in, trace_suppress_items::in,
-    may_be_thread_safe::in, list(string)::in, list(string)::out,
-    io::di, io::uo) is det.
+    may_be_thread_safe::in, c_compiler_type::in,
+    list(string)::in, list(string)::out, io::di, io::uo) is det.

  postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0,
          TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe,
-        !Errors, !IO) :-
+        C_CompilerType, !Errors, !IO) :-
      globals_io_init(OptionTable0, Target, GC_Method, TagsMethod0,
-        TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !IO),
+        TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe,
+        C_CompilerType, !IO),

      some [!Globals] (
          globals.io_get_globals(!:Globals, !IO),
@@ -403,10 +418,10 @@
              globals.lookup_int_option(!.Globals, num_tag_bits, NumTagBits0)
          ),

-        % if --tags low but --num-tag-bits not specified,
+        % If --tags low but --num-tag-bits not specified,
          % use the autoconf-determined value for --num-tag-bits
          % (the autoconf-determined value is passed from the `mc' script
-        % using the undocumented --conf-low-tag-bits option)
+        % using the undocumented --conf-low-tag-bits option).
          (
              TagsMethod0 = tags_low,
              NumTagBits0 = -1
@@ -417,8 +432,8 @@
              NumTagBits1 = NumTagBits0
          ),

-        % if --num-tag-bits negative or unspecified, issue a warning
-        % and assume --num-tag-bits 0
+        % If --num-tag-bits negative or unspecified, issue a warning
+        % and assume --num-tag-bits 0.
          ( NumTagBits1 < 0 ->
              io.progname_base("mercury_compile", ProgName, !IO),
              report_warning(ProgName, !IO),
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.609
diff -u -r1.609 options.m
--- compiler/options.m	22 Jan 2008 02:50:45 -0000	1.609
+++ compiler/options.m	22 Jan 2008 07:58:08 -0000
@@ -711,7 +711,6 @@
      ;       object_file_extension
      ;       pic_object_file_extension
      ;       link_with_pic_object_file_extension
-    ;       c_compiler_type_special
      ;       c_compiler_type

      % Java
@@ -1504,7 +1503,6 @@
      object_file_extension               -   string(".o"),
      pic_object_file_extension           -   string(".o"),
      link_with_pic_object_file_extension -   string(".o"),
-    c_compiler_type_special             -   string_special,
      c_compiler_type                     -   string("gcc"),
                                          % The `mmc' script will override the
                                          % default with a value determined at
@@ -2351,7 +2349,7 @@
  long_option("pic-object-file-extension", pic_object_file_extension).
  long_option("link-with-pic-object-file-extension",
                      link_with_pic_object_file_extension).
-long_option("c-compiler-type",      c_compiler_type_special).
+long_option("c-compiler-type",      c_compiler_type).


  long_option("java-compiler",        java_compiler).
@@ -2730,13 +2728,6 @@
          Result = error("argument of `--mercury-linkage' should be either " ++
              """shared"" or ""static"".")
      ).
-special_handler(c_compiler_type_special, string(Flag), OptionTable0, Result) :-
-    ( ( Flag = "gcc" ; Flag = "lcc" ; Flag = "cl" ; Flag = "unknown" ) ->
-        Result = ok(OptionTable0 ^ elem(c_compiler_type) := string(Flag))
-    ;
-        Result = error("argument of `--c-compiler-type' should be one of " ++
-            """gcc"", ""lcc"", ""cl"" or ""unknown"".")
-    ).

  %-----------------------------------------------------------------------------%

Index: scripts/Mercury.config.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/Mercury.config.in,v
retrieving revision 1.19
diff -u -r1.19 Mercury.config.in
--- scripts/Mercury.config.in	8 Nov 2007 06:13:23 -0000	1.19
+++ scripts/Mercury.config.in	22 Jan 2008 07:58:08 -0000
@@ -23,6 +23,7 @@
  MERCURY_DEFAULT_OPT_LEVEL=-O2
  MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@
  MERCURY_C_COMPILER=@CC@
+MERCURY_C_COMPILER_TYPE=@C_COMPILER_TYPE@
  MERCURY_MATH_LIB=@MATH_LIB@
  MERCURY_JAVA_COMPILER=@JAVAC@
  MERCURY_JAVA_INTERPRETER=@JAVA_INTERPRETER@
@@ -51,6 +52,7 @@
  		@ALL_LOCAL_C_INCL_DIR_MMC_OPTS@ \
  		@ALL_LOCAL_C_LIB_DIR_MMC_OPTS@ \
  		--cc "$(MERCURY_C_COMPILER)" \
+		--c-compiler-type "$(MERCURY_C_COMPILER_TYPE)" \
  		--java-compiler "$(MERCURY_JAVA_COMPILER)" \
  		--java-interpreter "$(MERCURY_JAVA_INTERPRETER)" \
  		--csharp-compiler "$(MERCURY_CSHARP_COMPILER)" \
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.123
diff -u -r1.123 mgnuc.in
--- scripts/mgnuc.in	24 Oct 2007 09:21:18 -0000	1.123
+++ scripts/mgnuc.in	22 Jan 2008 07:58:08 -0000
@@ -26,6 +26,7 @@
  CFLAGS_FOR_THREADS="@CFLAGS_FOR_THREADS@"
  CFLAGS_FOR_NO_STRICT_ALIASING="@CFLAGS_FOR_NO_STRICT_ALIASING@"
  AS="@AS@"
+BYTES_PER_WORD="@BYTES_PER_WORD@"

  case "$CC" in
      *gcc*)
@@ -350,8 +351,18 @@
  esac

  case $use_trail in
-    true)           TRAIL_OPTS="-DMR_USE_TRAIL" ;;
-    false)          TRAIL_OPTS="" ;;
+    true)
+        TRAIL_OPTS="-DMR_USE_TRAIL"
+        case $COMPILER in
+            gcc)    FN_ALIGN_OPTS="-falign-functions=$BYTES_PER_WORD" ;;
+            *)      FN_ALIGN_OPTS="" ;;
+        esac
+        ;;
+
+    false)
+        TRAIL_OPTS=""
+        FN_ALIGN_OPTS=""
+    ;;
  esac

  case $use_minimal_model_stack_copy,$use_minimal_model_own_stacks in
@@ -630,6 +641,7 @@
      $PICREG_OPTS\
      $ARCH_OPTS\
      $ARG_OPTS\
+    $FN_ALIGN_OPTS\
      $INVISIBLE_OPTS"

  case $verbose in true)
Index: tests/trailing/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/trailing/Mercury.options,v
retrieving revision 1.3
diff -u -r1.3 Mercury.options
--- tests/trailing/Mercury.options	21 Jan 2008 03:01:10 -0000	1.3
+++ tests/trailing/Mercury.options	22 Jan 2008 07:58:09 -0000
@@ -3,11 +3,3 @@
  #
  MCFLAGS-tu_test1 = --analyse-trail-usage
  MCFLAGS-tu_test2 = --analyse-trail-usage
-
-# Note that function trailng (or at least the tagged variant thereof)
-# require that the address of functions stored on the trail is word aligned.
-# Certain, gcc optimisation settings can disable this, e.g. the ones implied
-# by the .ll_debug grades, so we need to re-enable it here.
-# (We align the function on 64-bit boundaries so that these test work
-# on either 32 or 64-bit machines.)
-EXTRA_CFLAGS = -falign-functions=8

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list