================
@@ -247,10 +247,35 @@ llvm::Constant 
*CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
       Name = Context.BuiltinInfo.getName(BuiltinID).substr(10);
   }
 
+  // If no standard library declaration was found in the AST (freestanding
+  // code calling builtins directly without headers), perform automatic
+  // resolution of MSVC CRT symbol names and DLL import attributes.
+  bool IsNoHeader = (D == GlobalDecl(FD));
+  if (IsNoHeader && getTriple().isWindowsMSVCEnvironment() &&
+      Name == "hypotf") {
+    // Map C99 float math functions to their MSVC CRT prefixed names on 
Windows.
+    // (Only hypotf needs mapping as it is not exported without prefix in UCRT
+    // on both x86 and x64).
+    Name = "_hypotf";
----------------
efriedma-quic wrote:

What choice do we have?  We can reject __builtin_hypotf on Windows, we can 
require the user to include math.h and redirect the builtin there, we can 
hardcode this mapping somewhere, or we can synthesize our own implementation.  
All of those options have downsides...

https://github.com/llvm/llvm-project/pull/207135
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to