<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Clang does not set /DEFAULTLIB:OLDNAMES when invoking link.exe on Windows"
href="https://bugs.llvm.org/show_bug.cgi?id=46886">46886</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang does not set /DEFAULTLIB:OLDNAMES when invoking link.exe on Windows
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>clay.Sweetser@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23787" name="attach_23787" title="Test case">attachment 23787</a> <a href="attachment.cgi?id=23787&action=edit" title="Test case">[details]</a></span>
Test case
When using Clang together with the Windows SDK, Clang doesn't set
"/DEFAULTLIB:OLDNAMES" when invoking "link.exe". This flag is required in order
to access various standard C functions ("_fdopen", "_atoi64") through their
"deprecated" names ("fdopen", "atoi64"). For comparison, "cl.exe" sets this
flag by default when invoking "link.exe", unless told not to (for example, by
passing "/NODEFAULTLIB".
If this option is not passed, programs that access the functions through their
alternate name will fail at link-time with an undefined reference error (at
least with Clang's default configuration, the function declarations appear to
always be defined).
>From a user perspective, this is highly confusing, since a casual internet
search doesn't reveal why such functions would throw linker errors. I was
tipped off by looking at the Mingw project's source code, since it seems to do
something similar.
Attached is a program that demonstrates the error. It will fail to compile when
run in a Clang+Windows SDK environment:
clang example.c
but succeed when run with "--for-linker=-DEFAULTLIB:OLDNAMES":
clang --for-linker=-DEFAULTLIB:OLDNAMES example.c</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>