RFR: 8328157: Move C[XX]FLAGS_JDK[LIB/EXE] to JdkNativeCompilation.gmk [v3]

Magnus Ihse Bursie ihse at openjdk.org
Fri Mar 15 12:52:38 UTC 2024


On Fri, 15 Mar 2024 12:39:03 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> make/modules/jdk.jpackage/Lib.gmk line 63:
>> 
>>> 61:     CXXFLAGS_FILTER_OUT := -MD, \
>>> 62:     CXXFLAGS := $(JPACKAGE_APPLAUNCHER_INCLUDES), \
>>> 63:     CFLAGS := $(JPACKAGE_APPLAUNCHER_INCLUDES), \
>> 
>> This removed `-MD`, but I don't see it adding `-MT`.
>
> You are correct, this is missing in several places. 
> 
> I got curious on how this could still end up making no difference in the resulting binary, and I ended up in a deep google rabbit hole. My understanding is that `/MT` is in effect default, but Microsoft does not say that. Instead, they say that setting `/MT` makes the library link with `libcmt.lib` (and define `_MT`), but not setting any of `/MT` or `/MD` will result in your code linking with `libcmt.lib` by default... So if you don't look for the `_MT` define, there is no difference in the output. 
> 
> Nevertheless, we should have the option for clarity of what we mean.

Actually, it **is** the default! I found it now: "/LD implies /MT unless you explicitly specify /MD." https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170

Microsoft could certainly step up the game wrt their documentation. :-/

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18301#discussion_r1526242203


More information about the build-dev mailing list