[m-rev.] diff: Fix some linking issues with MSVC.
Paul Bone
paul at bone.id.au
Wed Feb 18 11:57:03 AEDT 2015
Branches: version-14_01-branch, master
---
Fix some linking issues with MSVC.
compiler/file_names.m:
Linking a program with other Mercury libraries (using -ml) was borken
because Mercury didn't recognize .lib files as libraries and therefore
searched for them in an incorrect location.
compiler/compile_target_code.m:
MSVC doesn't support the -l option for linking with .dll files. Instead
a corresponding .lib file should appear on the command line without an
"-l" prefix.
---
compiler/compile_target_code.m | 16 ++++++++++++++--
compiler/file_names.m | 3 ++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
index 105af59..1add76b 100644
--- a/compiler/compile_target_code.m
+++ b/compiler/compile_target_code.m
@@ -2720,8 +2720,20 @@ process_link_library(Globals, MercuryLibDirs, LibName, LinkerOpt, !Succeeded,
; Target = target_x86_64
),
globals.lookup_string_option(Globals, mercury_linkage, MercuryLinkage),
- LinkOpt = "-l",
- LibSuffix = ""
+ globals.get_c_compiler_type(Globals, CCompilerType),
+ (
+ ( CCompilerType = cc_gcc(_, _, _)
+ ; CCompilerType = cc_clang(_)
+ ; CCompilerType = cc_lcc
+ ; CCompilerType = cc_unknown
+ ),
+ LinkOpt = "-l",
+ LibSuffix = ""
+ ;
+ CCompilerType = cc_cl(_),
+ LinkOpt = "",
+ LibSuffix = ".lib"
+ )
;
Target = target_csharp,
MercuryLinkage = "shared",
diff --git a/compiler/file_names.m b/compiler/file_names.m
index 9724662..cb4bcd2 100644
--- a/compiler/file_names.m
+++ b/compiler/file_names.m
@@ -291,12 +291,13 @@ choose_file_name(Globals, _ModuleName, BaseParentDirs, BaseName, Ext,
( Ext = ""
; Ext = ".bat"
; Ext = ".exe"
- ; Ext = ".dll"
% Library files.
; Ext = ".a"
; Ext = ".$A"
+ ; Ext = ".lib"
; Ext = ".so"
+ ; Ext = ".dll"
; Ext = ".dylib"
; Ext = ".$(EXT_FOR_SHARED_LIB)"
; Ext = ".jar"
--
2.1.4
More information about the reviews
mailing list