<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-cl] Don't emit dllexport inline function definitions from pch files"
href="https://bugs.llvm.org/show_bug.cgi?id=37801">37801</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[clang-cl] Don't emit dllexport inline function definitions from pch files
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hans@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The definitions will already be present in the .obj file generated when
building the PCH. Not emitting them again saves a lot of compile time.
For example,
header.h
#ifndef HEADER_H
#define HEADER_H
inline int __declspec(dllexport) foo() {
return 42;
}
#endif
precompiled_header.h
#include "header.h"
precompiled_header.cc
// No include needed; the include is forced with /FI.
a.cc
#include "header.h"
int __declspec(dllexport) bar() {
return 1;
}
To build the PCH file:
cl /c precompiled_header.cc /FIprecompiled_header.h /Ycprecompiled_header.h
/Fppch.pch
Note how the definition of foo() is emitted into precompiled_header.obj:
dumpbin /directives precompiled_header.obj | grep EXPORT
/EXPORT:?foo@@YAHXZ
To use the PCH when compiling a.cc:
cl /c a.cc /FIprecompiled_header.h /Yuprecompiled_header.h /Fppch.pch
Note how the definition of foo() is *not* emitted into a.obj:
dumpbin /directives a.obj | grep EXPORT
/EXPORT:?bar@@YAHXZ
If we had not used the PCH, foo() would have been emitted:
cl /c a.cc && dumpbin /directives a.obj | grep EXPORT
/EXPORT:?foo@@YAHXZ
/EXPORT:?bar@@YAHXZ
clang-cl does not do this optimization, and always emits foo() even if it came
from the PCH.</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>