Skip to content

Don't /LTCG CRT initializers#2314

Merged
StephanTLavavej merged 1 commit intomicrosoft:mainfrom
CaseyCarter:dll_build_fix
Nov 13, 2021
Merged

Don't /LTCG CRT initializers#2314
StephanTLavavej merged 1 commit intomicrosoft:mainfrom
CaseyCarter:dll_build_fix

Conversation

@CaseyCarter
Copy link
Contributor

@CaseyCarter CaseyCarter commented Nov 1, 2021

Fixes #2311

I verified the fix manually; open to suggestions for test coverage.

@CaseyCarter CaseyCarter added the build Related to the build system label Nov 1, 2021
@CaseyCarter CaseyCarter requested a review from a team as a code owner November 1, 2021 21:21
Copy link
Contributor

@AlexGuteniev AlexGuteniev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After TryAcquireSRWLockExclusive is impoerted statically due to Vista drop, the only way to observe the difference would be __crtGetSystemTimePreciseAsFileTime, which affects system_clock::now() granularity. I don't think we need a test for it.

@StephanTLavavej
Copy link
Member

I have manually verified the fix.

// cl /EHsc /nologo /W4 /MD /Zi /Fdmeow.pdb meow.cpp
#include <cstdio>
#include <mutex>
using namespace std;

int main() {
    mutex mut;
    puts("BEFORE");
    mut.lock();
    puts("DURING");
    mut.unlock();
    puts("AFTER");
}

Before this PR, stepping into mut.lock() eventually calls:

msvcp140_oss.dll!Concurrency::details::stl_critical_section_vista::lock()

After this PR, it calls:

msvcp140_oss.dll!Concurrency::details::stl_critical_section_win7::lock()

@StephanTLavavej StephanTLavavej self-assigned this Nov 12, 2021
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit f89fb6d into microsoft:main Nov 13, 2021
@StephanTLavavej
Copy link
Member

Thanks @AlexGuteniev for finding and @CaseyCarter for fixing this lurking bug! 🐞 🛠️ 😸

@CaseyCarter CaseyCarter deleted the dll_build_fix branch November 14, 2021 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Related to the build system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

STL: /MD version does not load dynamic imports

4 participants