在 2022-11-20 20:53, Pali Rohár 写道:
Hello! I would like to propose a new parameter for gcc: -mcrtdll= to
allow specifying against which Windows C Runtime library should be
binary linked. On Windows there are more crt libraries and currently gcc
links to libmsvcrt.a which is in most cases symlink to libmsvcrt-os.a
(but can be changed, e.g. during mingw-w64 building). mingw-w64 project
already builds import .a library for every crt dll library (from the old
crtdll.dll up to the new ucrtbase.dll), so it is ready for usage. Simple
patch for gcc which implements -mcrtdll parameter is below. Note that on
internet are other very similar patches for -mcrtdll= parameters and
some are parts of custom mingw32 / mingw-w64 gcc builds. What do you
think? Could gcc have "official" support for -mcrtdll= parameter?



It's not enough to just link against the desired library, you will also have to define `__MSVCRT_VERSION__` accordingly (for UCRT it should be defined as `0xE00` i.e. 14.0).

The current status of such mechanism is that both the macro `__MSVCRT_VERSION__` and the library 'libmsvcrt.a' are determined when building mingw-w64, configurable by `--with-default-msvcrt=`, so they always match.


[1] https://sourceforge.net/p/mingw-w64/mailman/message/36030072/




--
Best regards,
LIU Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to