Bug 186944 - Adjust WEBCORE_EXPORT annotations for LTO
Summary: Adjust WEBCORE_EXPORT annotations for LTO
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Rollin
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-06-22 15:40 PDT by Keith Rollin
Modified: 2018-07-18 14:37 PDT (History)
9 users (show)

See Also:


Attachments
Patch (21.60 KB, patch)
2018-06-22 15:43 PDT, Keith Rollin
no flags Details | Formatted Diff | Diff
Patch (24.99 KB, patch)
2018-06-25 17:32 PDT, Keith Rollin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Rollin 2018-06-22 15:40:22 PDT
Adjust a number of places that result in WebKit's 'check-for-weak-vtables-and-externals' script reporting weak external symbols:

    ERROR: WebCore has a weak external symbol in it (/Volumes/Data/dev/webkit/OpenSource/WebKitBuild/Release/WebCore.framework/Versions/A/WebCore)
    ERROR: A weak external symbol is generated when a symbol is defined in multiple compilation units and is also marked as being exported from the library.
    ERROR: A common cause of weak external symbols is when an inline function is listed in the linker export file.
    ...

These cases are caused by inline methods being marked with WTF_EXPORT (or related macro) or with an inline function being in a class marked as such, and when enabling LTO builds.

For the most part, address these by removing the WEBCORE_EXPORT annotation from inline methods. In some cases, move the implementation out-of-line because it's the class that has the WEBCORE_EXPORT on it and removing the annotation from the class would be too disruptive. Finally, in other cases, move the implementation out-of-line because check-for-weak-vtables-and-externals still complains when keeping the implementation inline and removing the annotation; this seems to typically (but not always) happen with destructors.
Comment 1 Radar WebKit Bug Importer 2018-06-22 15:40:34 PDT
<rdar://problem/41384880>
Comment 2 Keith Rollin 2018-06-22 15:43:53 PDT
Created attachment 343380 [details]
Patch
Comment 3 EWS Watchlist 2018-06-22 15:48:20 PDT
Attachment 343380 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.h:53:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
Total errors found: 1 in 17 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Keith Rollin 2018-06-22 16:59:22 PDT
That warning can be ignored for now. LTO builds succeed despite it.
Comment 5 David Kilzer (:ddkilzer) 2018-06-25 13:18:35 PDT
Comment on attachment 343380 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=343380&action=review

r=me

> Source/WebCore/ChangeLog:29
> +        For the most part, address these by removing the WEBCORE_EXPORT
> +        annotation from inline methods. In some cases, move the implementation
> +        out-of-line because it's the class that has the WEBCORE_EXPORT on it
> +        and removing the annotation from the class would be too disruptive.
> +        Finally, in other cases, move the implementation out-of-line because
> +        check-for-weak-vtables-and-externals still complains when keeping the
> +        implementation inline and removing the annotation; this seems to
> +        typically (but not always) happen with destructors.

Moving destructors out-of-line can save disk space in the binary as well!

> Source/WebCore/workers/service/server/SWServer.h:72
> -        WEBCORE_EXPORT virtual ~Connection() { }
> +        virtual ~Connection() { }

This can be changed to:

        virtual ~Connection() = default;
Comment 6 David Kilzer (:ddkilzer) 2018-06-25 13:20:18 PDT
(In reply to Keith Rollin from comment #4)
> That warning can be ignored for now. LTO builds succeed despite it.

ERROR: Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.h:53:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
Total errors found: 1 in 17 files

Why not just fix it?  It's clearly wrong.  Please fix.
Comment 7 Keith Rollin 2018-06-25 17:31:17 PDT
OK. I've made the requested changes.
Comment 8 Keith Rollin 2018-06-25 17:32:26 PDT
Created attachment 343565 [details]
Patch
Comment 9 WebKit Commit Bot 2018-06-25 19:05:42 PDT
Comment on attachment 343565 [details]
Patch

Clearing flags on attachment: 343565

Committed r233189: <https://trac.webkit.org/changeset/233189>
Comment 10 WebKit Commit Bot 2018-06-25 19:05:43 PDT
All reviewed patches have been landed.  Closing bug.