Skip to content

Don't /LTCG CRT initializers - #2314

Merged
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
CaseyCarter:dll_build_fix
Nov 13, 2021
Merged

Don't /LTCG CRT initializers#2314
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
CaseyCarter:dll_build_fix

Conversation

@CaseyCarter

@CaseyCarter Casey Carter (CaseyCarter) commented Nov 1, 2021

Copy link
Copy Markdown
Contributor

Fixes #2311

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

@CaseyCarter Casey Carter (CaseyCarter) added the build Related to the build system label Nov 1, 2021
@CaseyCarter
Casey Carter (CaseyCarter) requested a review from a team as a code owner November 1, 2021 21:21
Comment thread stl/CMakeLists.txt

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

Copy link
Copy Markdown
Member

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

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit f89fb6d into microsoft:main Nov 13, 2021
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks Alex Guteniev (@AlexGuteniev) for finding and Casey Carter (@CaseyCarter) for fixing this lurking bug! 🐞 🛠️ 😸

@CaseyCarter
Casey Carter (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