summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-09-03 10:49:51 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-09-03 10:49:51 +0000
commitb9110541efb85f9489b1f9a0c95445419e61d86d (patch)
tree1e01111460edc9c11b8f5a833ac048457dc4e279 /rts/Linker.c
parent5cb8bd3a80ce9a53e78d9f9773a4cf7797fefcf2 (diff)
downloadhaskell-b9110541efb85f9489b1f9a0c95445419e61d86d.tar.gz
Windows: print an error message in addDLL
Also, look for libXXX.dll in addition to XXX.dll (see #1883, this isn't really a proper fix, but it'll help in some cases). And I tidied up the error message for a DLL load failure, though it's still a bit of a mess because addDLL is supposed to return a (static) string with the error message, but this isn't possible on Windows.
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index a9c145b6e8..26d671e6e9 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1066,14 +1066,19 @@ addDLL( char *dll_name )
sprintf(buf, "%s.DLL", dll_name);
instance = LoadLibrary(buf);
if (instance == NULL) {
- sprintf(buf, "%s.DRV", dll_name); // KAA: allow loading of drivers (like winspool.drv)
- instance = LoadLibrary(buf);
- if (instance == NULL) {
- stgFree(buf);
-
- /* LoadLibrary failed; return a ptr to the error msg. */
- return "addDLL: unknown error";
- }
+ if (GetLastError() != ERROR_MOD_NOT_FOUND) goto error;
+ // KAA: allow loading of drivers (like winspool.drv)
+ sprintf(buf, "%s.DRV", dll_name);
+ instance = LoadLibrary(buf);
+ if (instance == NULL) {
+ if (GetLastError() != ERROR_MOD_NOT_FOUND) goto error;
+ // #1883: allow loading of unix-style libfoo.dll DLLs
+ sprintf(buf, "lib%s.DLL", dll_name);
+ instance = LoadLibrary(buf);
+ if (instance == NULL) {
+ goto error;
+ }
+ }
}
stgFree(buf);
@@ -1089,6 +1094,13 @@ addDLL( char *dll_name )
# else
barf("addDLL: not implemented on this platform");
# endif
+
+error:
+ stgFree(buf);
+ sysErrorBelch(dll_name);
+
+ /* LoadLibrary failed; return a ptr to the error msg. */
+ return "addDLL: could not load DLL";
}
/* -----------------------------------------------------------------------------