Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8275405: Linking error for classes with lambda template parameters and virtual functions #6030

Closed

Conversation

stefank
Copy link
Member

@stefank stefank commented Oct 20, 2021

We encountered the following linking error when trying to build Generational ZGC on Windows:

jvm.exp : error LNK2001: unresolved external symbol "const ZBasicOopIterateClosure<class <lambda_9767402e468f9fc654281195f9700e48> >::`vftable'" (??_7?$ZBasicOopIterateClosure@V<lambda_9767402e468f9fc654281195f9700e48>@@@@6B@)

I narrowed this down to a simple reproducer, which doesn't link when built through the HotSpot build system:

#include <functional>
std::function<void()> = [](){};

I found that we have a line in our make files that filters out symbols that contain the string vftable (though it checks the mangled name, so a bit hard to find):

else ifeq ($(call isTargetOs, windows), true)
  DUMP_SYMBOLS_CMD := $(DUMPBIN) -symbols *.obj
  FILTER_SYMBOLS_AWK_SCRIPT := \
      '{ \
        if ($$7 ~ /??_7.*@@6B@/ && $$7 !~ /type_info/) print $$7; \
      }'

The following line prints the vftable symbol if it doesn't contain the string 'type_info':
if ($$7 ~ /??_7.*@@6b@/ && $$7 !~ /type_info/) print $$7;

The printed values are added to a list of symbols that get filtered out of the mapfile, which is then passed to the linker.

I can get the code to link if I add a second exception for vftable symbols containing the string 'lambda':
if ($$7 ~ /??_7.*@@6b@/ && $$7 !~ /type_info/ && $$7 !~ /lambda/) print $$7;

I did an additional experiment where I completely removed this filtering of vftable symbols. When I did that the linker complained that we used more than 64K symbols.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8275405: Linking error for classes with lambda template parameters and virtual functions

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6030/head:pull/6030
$ git checkout pull/6030

Update a local copy of the PR:
$ git checkout pull/6030
$ git pull https://git.openjdk.java.net/jdk pull/6030/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6030

View PR using the GUI difftool:
$ git pr show -t 6030

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6030.diff

@stefank
Copy link
Member Author

@stefank stefank commented Oct 20, 2021

/label hotspot build

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Oct 20, 2021

👋 Welcome back stefank! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added rfr hotspot build labels Oct 20, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 20, 2021

@stefank
The hotspot label was successfully added.

The build label was successfully added.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 20, 2021

Webrevs

Copy link
Member

@magicus magicus left a comment

Looks good to me.

# number of exported symbols below that limit.
#
# Some usages of C++ lambdas require the vftable symbol of classes that use
# the lambda type as a template parameter. The usage of those classes wont
Copy link
Member

@magicus magicus Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# the lambda type as a template parameter. The usage of those classes wont
# the lambda type as a template parameter. The usage of those classes won't

@openjdk
Copy link

@openjdk openjdk bot commented Oct 20, 2021

@stefank This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8275405: Linking error for classes with lambda template parameters and virtual functions

Reviewed-by: ihse, pliden

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 5 new commits pushed to the master branch:

  • a91a0a5: 8233724: Remove -Wc++14-compat warning suppression in operator_new.cpp
  • 1271fbf: 8248584: Enable CHECK_UNHANDLED_OOPS for Windows fastdebug builds
  • 135cf3c: 8275439: Remove PrintVtableStats
  • 50a5723: 8274910: Compile in G1 evacuation failure injection code based on define
  • 5454a76: 8275273: Add missing HtmlStyle documentation

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Oct 20, 2021
pliden
pliden approved these changes Oct 20, 2021
Copy link
Contributor

@pliden pliden left a comment

Looks good to me!

@stefank
Copy link
Member Author

@stefank stefank commented Oct 21, 2021

Thanks for reviewing!
/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Oct 21, 2021

Going to push as commit 09f5235.
Since your change was applied there have been 17 commits pushed to the master branch:

  • a120937: 8274988: G1: refine G1SegmentedArrayAllocOptions and G1CardSetAllocOptions
  • c7a80e6: 8275607: G1: G1CardSetAllocator::drop_all needs to call G1SegmentedArray::drop_all
  • af7c56b: 8275167: x86 intrinsic for unsignedMultiplyHigh
  • cea3f01: 8275666: serviceability/jvmti/GetObjectSizeClass.java shouldn't have vm.flagless
  • d1e3ca4: 8233558: [TESTBUG] WindowOwnedByEmbeddedFrameTest.java fails on macos
  • 913f928: 8273507: Convert test/jdk/java/nio/channels/Channels/TransferTo.java to TestNG test
  • 0021a2f: 8275449: Add linux-aarch64-zero build profile
  • 46b5bfb: 8233648: [TESTBUG] DefaultMenuBarTest.java failing on macos
  • bbc6061: 8272614: Unused parameters in MethodHandleNatives linking methods
  • 7e28bdd: 8275055: Improve HeapRegionRemSet::split_card()
  • ... and 7 more: https://git.openjdk.java.net/jdk/compare/bd0bed71e55f0bb8b4619495c79184f94c0701fb...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Oct 21, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Oct 21, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 21, 2021

@stefank Pushed as commit 09f5235.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@stefank stefank deleted the 8275405_lambda_vftable_sybmols branch Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build hotspot integrated
3 participants