[llvm-bugs] [Bug 41394] New: Clang_cl precompiled headers causes missing symbols

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 5 07:35:36 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41394

            Bug ID: 41394
           Summary: Clang_cl precompiled headers causes missing symbols
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: linux at carewolf.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

With the latest clang_cl 8.0 we have tried reenabling using precompiled headers
for clang_cl on Windows with Qt.

Unfortunately it doesn't work and causes very long list of undefined symbols at
link time. All the missing symbols reported as referenced from PCH object file.
The symbols can be both from in and outside of the library, almost all inline
templated methods such as various forms of basic_string<T> methods.

There are several ways to work around the issue, most avoiding linking with PCH
object file:
1) Not linking in the pch object file and doing a debug build
2) Not linking in the pch object file and compiling all other files with
/Zc:dllexportInlines-
3) Not linking in the pch object file and compiling all other files with
-Xclang -building-pch-with-obj
4) Manually instantiating ALL templated classes possibly used by inline methods
(e.g. template class std::basic_string<char>). Note this is not necessary with
any other compiler.

They first three work-arounds all achieve the same goal of making the methods
generated in the PCH object file redundant, making linking with the buggy
object file unnecessary.

The issue simply appears to be that templated inline methods are partially
generated, but the template instantiations they need are not. Likely the
generated methods should been discarded unless used by another file in the
library.

In general it seems the far easiest to use a similar strategy as on non-windows
platform and let the normal object files generate the inline symbols they need,
even if that generates them more than necessary.

I have tried making a few simple cases, but the issue resists reproduction with
small examples and appears to require a larger library before it triggers.

Tell me if you need more information.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190405/6b5e521a/attachment-0001.html>


More information about the llvm-bugs mailing list