-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[clang][MinGW] Implement -mcrtdll option to switch crt choice #149469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Keno
wants to merge
2
commits into
llvm:main
Choose a base branch
from
JuliaLang:kf/mcrtdll
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4705,6 +4705,44 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, | |
} | ||
} | ||
|
||
// Process MinGW -mcrtdll option | ||
if (Arg *A = Args.getLastArg(OPT_mcrtdll_EQ)) { | ||
Opts.MinGWCRTDll = | ||
llvm::StringSwitch<enum LangOptions::WindowsCRTDLLVersion>( | ||
A->getValue()) | ||
.StartsWithLower("crtdll", | ||
LangOptions::WindowsCRTDLLVersion::CRTDLL) | ||
.StartsWithLower("msvcrt10", | ||
LangOptions::WindowsCRTDLLVersion::MSVCRT10) | ||
.StartsWithLower("msvcrt20", | ||
LangOptions::WindowsCRTDLLVersion::MSVCRT20) | ||
.StartsWithLower("msvcrt40", | ||
LangOptions::WindowsCRTDLLVersion::MSVCRT40) | ||
.StartsWithLower("msvcr40", | ||
LangOptions::WindowsCRTDLLVersion::MSVCRT40) | ||
.StartsWithLower("msvcrtd", | ||
LangOptions::WindowsCRTDLLVersion::MSVCRTD) | ||
.StartsWithLower("msvcr70", | ||
LangOptions::WindowsCRTDLLVersion::MSVCR70) | ||
.StartsWithLower("msvcr71", | ||
LangOptions::WindowsCRTDLLVersion::MSVCR71) | ||
.StartsWithLower("msvcr80", | ||
LangOptions::WindowsCRTDLLVersion::MSVCR80) | ||
.StartsWithLower("msvcr90", | ||
LangOptions::WindowsCRTDLLVersion::MSVCR90) | ||
.StartsWithLower("msvcr100", | ||
LangOptions::WindowsCRTDLLVersion::MSVCR100) | ||
.StartsWithLower("msvcr110", | ||
LangOptions::WindowsCRTDLLVersion::MSVCR110) | ||
.StartsWithLower("msvcr120", | ||
LangOptions::WindowsCRTDLLVersion::MSVCR120) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're missing a case (and enum) for |
||
.StartsWithLower("ucrt", LangOptions::WindowsCRTDLLVersion::UCRT) | ||
.Default(LangOptions::WindowsCRTDLLVersion::CRTDLL_Default); | ||
if (Opts.MinGWCRTDll == LangOptions::WindowsCRTDLLVersion::CRTDLL_Default) { | ||
Diags.Report(diag::err_unknown_crtdll) << A->getValue(); | ||
} | ||
} | ||
|
||
return Diags.getNumErrors() == NumErrorsBefore; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// RUN: %clang -v --target=x86_64-w64-mingw32 -### %s 2>&1 | FileCheck -check-prefix=DEFAULT %s | ||
// RUN: %clang -v --target=x86_64-w64-mingw32 -mcrtdll=msvcr90 -### %s 2>&1 | FileCheck -check-prefix=MSVCR90 %s | ||
// RUN: %clang -v --target=x86_64-w64-mingw32 -mcrtdll=msvcr90_suffix -### %s 2>&1 | FileCheck -check-prefix=MSVCR90_SUFFIX %s | ||
// RUN: %clang -v --target=x86_64-w64-mingw32 -mcrtdll=ucrt -### %s 2>&1 | FileCheck -check-prefix=UCRT %s | ||
// RUN: %clang -v --target=x86_64-w64-mingw32 -mcrtdll=ucrtbase -### %s 2>&1 | FileCheck -check-prefix=UCRTBASE %s | ||
|
||
// RUN: %clang -dM -E --target=x86_64-w64-mingw32 %s 2>&1 | FileCheck -check-prefix=DEFINE_DEFAULT %s | ||
// RUN: %clang -dM -E --target=x86_64-w64-mingw32 -mcrtdll=msvcr90 %s 2>&1 | FileCheck -check-prefix=DEFINE_MSVCR90 %s | ||
// RUN: %clang -dM -E --target=x86_64-w64-mingw32 -mcrtdll=msvcr90_suffix %s 2>&1 | FileCheck -check-prefix=DEFINE_MSVCR90 %s | ||
// RUN: %clang -dM -E --target=x86_64-w64-mingw32 -mcrtdll=ucrt %s 2>&1 | FileCheck -check-prefix=DEFINE_UCRT %s | ||
// RUN: %clang -dM -E --target=x86_64-w64-mingw32 -mcrtdll=ucrtbase %s 2>&1 | FileCheck -check-prefix=DEFINE_UCRT %s | ||
// RUN: not %clang -dM -E --target=x86_64-w64-mingw32 -mcrtdll=bad %s 2>&1 | FileCheck -check-prefix=BAD %s | ||
|
||
// DEFAULT: "-lmingwex" "-lmsvcrt" | ||
// DEFINE_DEFAULT: #define __MSVCRT__ | ||
// MSVCR90: "-lmingwex" "-lmsvcr90" | ||
// DEFINE_MSVCR90: #define __MSVCRT_VERSION__ 0x900 | ||
// DEFINE_MSVCR90: #define __MSVCRT__ | ||
// MSVCR90-NOT: "-lmsvcrt" | ||
// MSVCR90_SUFFIX: "-lmingwex" "-lmsvcr90_suffix" | ||
// MSVCR90_SUFFIX-NOT: "-lmsvcrt" | ||
// UCRT: "-lmingwex" "-lucrt" | ||
// DEFINE_UCRT: #define _UCRT | ||
// DEFINE_UCRT-NOT: #define __MSVCRT_VERSION__ | ||
// UCRT-NOT: "-lmsvcrt" | ||
// UCRTBASE: "-lmingwex" "-lucrtbase" | ||
// UCRTBASE-NOT: "-lmsvcrt" | ||
// DEFINE_CRTDLL: #define __CRTDLL__ | ||
// DEFINE_CRTDLL-NOT: #define __MSVCRT__ | ||
// BAD: error: unknown Windows/MinGW C runtime library 'bad' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo,
__MSVCRT_VERSION__
with two trailing underscores.