msys.dll: Don't pull user32.dll & friends just to detect whether right alt should be used as meta
I've discovered that every msys program pulls lots of dlls on startup.
In particular the following simple program
---- 8< ----
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello World\n");
exit(1);
}
---- 8< -----
when compiled with mingw compiler, executes almost instantly, but when
compiled with msys compiler and linked with msys.dll, starts
significantly longer - ~0.2 - 0.5 seconds depending on machine.
As Kirill K. Smirnov already found[1] the problem lies in that on
startup, msys.dll pulls in user32.dll and does lot's of "unnecessary
things". And the following test justifies it:
$ WINEDEBUG=loaddll wine xmsys.exe
trace:loaddll:load_builtin_dll Loaded L"KERNEL32.dll" at 0x7ed50000: builtin
trace:loaddll:load_native_dll Loaded L"Z:\\home\\kirr\\src\\tools\\git\\msysgit\\bin\\xmsys.exe" at 0x400000: native
trace:loaddll:load_native_dll Loaded L"Z:\\home\\kirr\\src\\tools\\git\\msysgit\\bin\\msys-1.0.dll" at 0x68000000: native
trace:loaddll:load_builtin_dll Loaded L"C:\\windows\\system32\\advapi32.dll" at 0x7e950000: builtin
trace:loaddll:load_builtin_dll Loaded L"C:\\windows\\system32\\gdi32.dll" at 0x7e780000: builtin
trace:loaddll:load_builtin_dll Loaded L"C:\\windows\\system32\\version.dll" at 0x7ef30000: builtin
trace:loaddll:load_builtin_dll Loaded L"C:\\windows\\system32\\user32.dll" at 0x7e820000: builtin
trace:loaddll:load_builtin_dll Loaded L"C:\\windows\\system32\\imm32.dll" at 0x7e410000: builtin
trace:loaddll:load_builtin_dll Loaded L"C:\\windows\\system32\\winex11.drv" at 0x7e5c0000: builtin
Investigating showed that msys.dll imports kernel32.dll only, but also
implements some form of lazy-import (see .../winsup/cygwin/autoload.cc)
for symbols from other dlls, with the intention (as I see it) not to
load other system dlls until needed.
But also, it turned out, that in order to see whether AltGr should be
used as META or not, on _every_ msys startup, we were calling
GetKeyboardLayout() which is from user32.dll OOPS...
Avoid that, and suddenly my test program runs significantly faster. It
still pulls in advapi32.dll - this can be investigated later...
[1] http://bugs.winehq.org/show_bug.cgi?id=13606#c8
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>