X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FLinker.c;h=3735a2e558cd370597b7043a226e17cc6a48139f;hb=a200038f469418fef77d863dc3d1cd0125ec1e82;hp=a9c145b6e8e4150d7376affcf48553efb6a991cc;hpb=908203dc6a2f9fcbe819aef5b7a9d2196661b929;p=ghc-hetmet.git diff --git a/rts/Linker.c b/rts/Linker.c index a9c145b..3735a2e 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); @@ -1086,6 +1091,14 @@ addDLL( char *dll_name ) opened_dlls = o_dll; return NULL; + +error: + stgFree(buf); + sysErrorBelch(dll_name); + + /* LoadLibrary failed; return a ptr to the error msg. */ + return "addDLL: could not load DLL"; + # else barf("addDLL: not implemented on this platform"); # endif