[m-rev.] diff: fix problems with MSVC and mmc --make

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Sep 16 00:58:12 AEST 2011


Branches: 11.07, main

Fix problems with mmc --make and Visual C.

compiler/compiler_target_code.m:
 	The "-o" option has been deprecated in Visual C, and we need to
 	use "-Fe" to name executables.

 	Fix an incomplete comment.

configure.in:
 	Use the dash form for MS linker options rather than the forward
 	slash form.  (The latter don't work with the MSYS shell.)

Julien.

Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.590
diff -u -r1.590 configure.in
--- configure.in	15 Sep 2011 13:28:13 -0000	1.590
+++ configure.in	15 Sep 2011 14:44:23 -0000
@@ -1030,7 +1030,7 @@
      OBJ_SUFFIX="obj"
      LIB_SUFFIX="lib"
      LIB_PREFIX="lib"
-    LIB_LIBPATH="/LIBPATH:"
+    LIB_LIBPATH="-LIBPATH:"
      LINK_LIB=""
      LINK_LIB_SUFFIX=".lib"
      LINK_OPT_SEP="-link"
@@ -1038,10 +1038,10 @@
      OBJFILE_OPT="-Fo"
      AR="lib"
      ARFLAGS=""
-    AR_LIBFILE_OPT="/OUT:"
+    AR_LIBFILE_OPT="-OUT:"

-    LDFLAGS_FOR_DEBUG="/DEBUG"
-    LD_LIBFLAGS_FOR_DEBUG="/DEBUG"
+    LDFLAGS_FOR_DEBUG="-DEBUG"
+    LD_LIBFLAGS_FOR_DEBUG="-DEBUG"
      LD_STRIP_FLAG=

      USING_MICROSOFT_CL_COMPILER="yes"
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.173
diff -u -r1.173 compile_target_code.m
--- compiler/compile_target_code.m	9 Aug 2011 11:00:55 -0000	1.173
+++ compiler/compile_target_code.m	15 Sep 2011 14:51:29 -0000
@@ -1961,9 +1961,9 @@
              RestrictedCommandLine),
          (
              % If we have a restricted command line then it's possible
-            % that following link command will call sub-commands its self
+            % that following link command will call sub-commands itself
              % and thus overflow the command line, so in this case
-            % we first create an archive of all of the 
+            % we first create an archive of all of the object files.
              %
              RestrictedCommandLine = yes,
              io.make_temp(TmpFile, !IO),
@@ -1986,6 +1986,7 @@
              % Note that LDFlags may contain `-l' options so it should come
              % after Objects.
              globals.lookup_string_option(Globals, CommandOpt, Command),
+            get_linker_output_option(Globals, LinkTargetType, OutputOpt),
              string.append_list([
                      Command, " ",
                      StaticOpts, " ",
@@ -1993,7 +1994,7 @@
                      UndefOpt, " ",
                      ThreadOpts, " ",
                      TraceOpts, " ",
-                    " -o ", quote_arg(OutputFileName), " ",
+                    OutputOpt, quote_arg(OutputFileName), " ",
                      Objects, " ",
                      LinkOptSep, " ",
                      LinkLibraryDirectories, " ",
@@ -2479,6 +2480,37 @@
          SharedLibExt),
      Supported = (if LibExt \= SharedLibExt then yes else no).

+:- pred get_linker_output_option(globals::in, linked_target_type::in,
+    string::out) is det.
+
+get_linker_output_option(Globals, LinkTargetType, OutputOpt) :-
+    get_c_compiler_type(Globals, C_CompilerType),
+    % XXX we should allow the user to override the compiler's choice of
+    % output option here.
+    % NOTE: the spacing around the value of OutputOpt here is important.
+    % Any changes should be reflected in predicate link_exe_or_shared_lib/9.
+    (
+        C_CompilerType = cc_cl(_),
+        ( if LinkTargetType = executable then
+            % NOTE: -Fe _must not_ be separated from its argument by any
+            % whitspace; the lack of a trailing space in the following
+            % is deliberate.
+            OutputOpt = " -Fe"
+          else
+            % XXX This is almost certainly wrong, but we don't currently
+            % support building shared libraries with mmc on Windows
+            % anyway.
+            OutputOpt = " -o "
+        )
+    ;
+        ( C_CompilerType = cc_gcc(_, _, _)
+        ; C_CompilerType = cc_clang(_)
+        ; C_CompilerType = cc_lcc
+        ; C_CompilerType = cc_unknown
+        ),
+        OutputOpt = " -o "
+    ).
+
  %-----------------------------------------------------------------------------%

  :- pred process_link_library(globals::in, list(dir_name)::in, string::in,

--------------------------------------------------------------------------
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