在 2022/10/20 03:53, Bernhard Reutner-Fischer 写道:

which has kernel32 twice, which might not be ideal for the speed of linking?
I'm not familiar with the content of ntdll so cannot judge if you'd put that in
MCFGTHREAD_SPEC and drop kernel32 there, though, and put the whole
MCFG spec simply before the kernel32 in the REAL_LIBGCC_SPEC.

i.e.
+#define MCFGTHREAD_SPEC  " -lmcfgthread -lntdll "
...
+   -lmoldname -lmingwex -lmsvcrt " MCFGTHREAD_SPEC " -lkernel32 "

I hope this is constructive.
thanks,

NTDLL is the user-mode syscall library i.e. it mainly provides syscalls as 
functions.

Putting `-lmcfgthread` before `-lkernel32` was what I did in the beginning. However, I had an impression that NTDLL and KERNEL32 may both export some functions (I believe this is no longer the case now). Since MSVCRT in mingw-w64 is not a 'pure' import library and contains some functions that we implement on top of KERNEL32, the ideal solution would be

   ```
   #define MCFGTHREAD_SPEC  " -lmcfgthread "
   #define MCFGTHREAD_NTDLL_SPEC  " -lntdll "
     ...
   -lmsvcrt " MCFGTHREAD_SPEC " -lkernel32 " MCFGTHREAD_NTDLL_SPEC
   ```

(NTDLL is only necessary when linking against the shared library.)

The committed patch inserted MCFGTHREAD after KERNEL32 for simplicity, but if you do think we had better not repeat KERNEL32 twice, I can propose another patch.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to