https://bugs.llvm.org/show_bug.cgi?id=37801
Bug ID: 37801
Summary: [clang-cl] Don't emit dllexport inline function
definitions from pch files
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: h...@chromium.org
CC: llvm-bugs@lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs