-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Flang][driver] Do not emit -latomic on link line on Windows #164648
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
Conversation
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Michael Klemm (mjklemm) ChangesFlang on Windows added Full diff: https://github.com/llvm/llvm-project/pull/164648.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 3d5cac62afe01..b5496e6300ba9 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -851,8 +851,11 @@ void ToolChain::addFortranRuntimeLibs(const ArgList &Args,
options::OPT_fno_openmp, false)) {
Driver::OpenMPRuntimeKind OMPRuntime = getDriver().getOpenMPRuntime(Args);
ToolChain::RuntimeLibType RuntimeLib = GetRuntimeLibType(Args);
- if (OMPRuntime == Driver::OMPRT_OMP && RuntimeLib == ToolChain::RLT_Libgcc)
+ if ((OMPRuntime == Driver::OMPRT_OMP &&
+ RuntimeLib == ToolChain::RLT_Libgcc) &&
+ !getTriple().isKnownWindowsMSVCEnvironment()) {
CmdArgs.push_back("-latomic");
+ }
}
}
|
|
LGTM |
|
Am I right in thinking this is only for MinGW targets and not msvcrt ones? I.e. with a triple like Edit: Oddly, I do seem to be getting |
|
I do have Since LLVM may emit libgcc-style atomic calls, the only things that could provide them would be compiler-rt (or ucrt equivalents the are still unknown to LLVM: #134455). These are disabled by default, llvm-project/compiler-rt/lib/builtins/CMakeLists.txt Lines 232 to 234 in ece83ed
There also is an option to create an equivalent to libatomic: See previous discussion: https://discourse.llvm.org/t/atomics-on-windows/84329 |
|
I haven't done anything special to turn on atomic support in compiler-rt and I can build and run at least simple programs using omp atomic and get the expected results. Not sure where I'm getting the symbols from. Anyway, if this is just for lld-link lines we definitely shouldn't be adding this at all so LGTM! |
LLVM emits CPU instructions for supported cases. A call to a runtime function (should1) only happens as a fallback, e.g. when the number of bytes that needs to be atomically written is not a constant 1, 2, 4, or 8. msvc does not support Footnotes
|
Flang on Windows added
-latomicto the link line. This library does not exist on Windows and the linker gives a warning.