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

Fix dynamic library lookup with remotely executed tools #16215

Closed
wants to merge 2 commits into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Sep 4, 2022

When a cc_binary tool is executed directly (e.g. in a genrule) with
remote execution, its dynamic dependencies are only available from the
solib directory in the runfiles directory. This commit adds an
additional rpath entry for this directory.

Since target names may contain commas and the newly added rpaths contain
target names, the -Xlinker compiler is now used everywhere instead of
the -Wl flag, which doesn't support commas in linker arguments.

@fmeum fmeum force-pushed the 14600-all-rpath-cases branch 2 times, most recently from 8da05de to b2adef0 Compare September 5, 2022 00:55
@fmeum fmeum changed the title WIP: Fix dynamic library lookup with remotely executed tools Fix dynamic library lookup with remotely executed tools Sep 5, 2022
@fmeum fmeum marked this pull request as ready for review September 5, 2022 00:56
@fmeum fmeum requested review from a team, lberki and oquenchil as code owners September 5, 2022 00:56
@fmeum
Copy link
Collaborator Author

fmeum commented Sep 5, 2022

@EdSchouten This is essentially your #14600 with an Integration test and support for commas. Could you verify that I got this right based on the changes in #16214?

@oquenchil Could you review after #16214?

@sgowroji sgowroji added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Sep 5, 2022
Copy link
Contributor

@EdSchouten EdSchouten left a comment

Choose a reason for hiding this comment

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

Thanks for addressing this!

@fmeum fmeum force-pushed the 14600-all-rpath-cases branch 2 times, most recently from dd4d64b to f4aeef0 Compare September 8, 2022 07:44
@fmeum
Copy link
Collaborator Author

fmeum commented Sep 8, 2022

@lberki This is the follow-up to #16214 that handles the remaining cases (including commas and --experimental_sibling_repository_layout) by switching to -Xlinkereverywhere. I don't think that-Wl` provides an escape character to escape commas with, so I found this to be the only way.

@fmeum fmeum force-pushed the 14600-all-rpath-cases branch 3 times, most recently from d6f84a8 to 9931d8d Compare September 8, 2022 10:23
Copy link
Contributor

@oquenchil oquenchil left a comment

Choose a reason for hiding this comment

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

LGTM

@oquenchil oquenchil added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Sep 9, 2022
@fmeum
Copy link
Collaborator Author

fmeum commented Sep 9, 2022

@oquenchil @sgowroji This should be merged separately after #16214 so that the former can be cherry-picked into 5.3.1.

@fmeum
Copy link
Collaborator Author

fmeum commented Sep 12, 2022

@sgowroji You can go ahead with the merge, #16214 has been merged and I rebased the PR.

@sgowroji
Copy link
Member

sgowroji commented Sep 12, 2022

@fmeum Thank you for very quick changes! Can you please fix the build kite failures.

@fmeum fmeum force-pushed the 14600-all-rpath-cases branch 2 times, most recently from 90ea36e to 470dd06 Compare September 12, 2022 13:16
@fmeum
Copy link
Collaborator Author

fmeum commented Sep 12, 2022

@sgowroji Pretty sure those were flakes. I restarted the pipeline.

@sgowroji sgowroji removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Sep 16, 2022
@lberki
Copy link
Contributor

lberki commented Oct 5, 2022

@meteorcloudy I'll add this to the list of issues for the 6.0 milestone to be considered as a requirement for 6.0 . I personally don't think this should block 6.0 (it's been delayed enough), but it's useful to keep track of the "nice to haves" for that release.

@buildbreaker2021
Copy link
Contributor

@fmeum The change from our side is not straightforward.

So our change which is required for the fix is instant(does not require a release to be picked up).
However the rest of the changes in the PR require a release.
Also the fix which I have in mind cannot work without the changes in the PR.

To sum it up:

  1. We release the fix with the PR - fix is picked up instantly the PR is not, so the fix without PR is breaking tests.
  2. We release fix first PR second - same problem as in 1.
  3. We release PR first and the fix second - this is the reason for the current rollback.

I am pretty sure there is a way around this, it is not just straightforward.

@buildbreaker2021
Copy link
Contributor

The solution which I currently have in mind, would require at least 1-2 weeks, depending on the internal Bazel release time.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 5, 2022

@buildbreaker2021 In case that would help, I'm happy to make my PR public domain (or whatever is needed) and have you integrate it in your fix CL so that you can merge both simultaneously without going through the import step.

@buildbreaker2021
Copy link
Contributor

I will ping the PR once we are ready for the merge - import step is fine from my side if you are fine with it.

aiuto pushed a commit to aiuto/bazel that referenced this pull request Oct 12, 2022
When a cc_binary tool is executed directly (e.g. in a genrule) with
remote execution, its dynamic dependencies are only available from the
solib directory in the runfiles directory. This commit adds an
additional rpath entry for this directory.

Since target names may contain commas and the newly added rpaths contain
target names, the `-Xlinker` compiler is now used everywhere instead of
the `-Wl` flag, which doesn't support commas in linker arguments.

Stacked on bazelbuild#16214

Closes bazelbuild#16215.

PiperOrigin-RevId: 474792702
Change-Id: I2bfa1fd77be83d7bfe54ba591af5cb0ad0e630fc
@buildbreaker2021
Copy link
Contributor

Hey @fmeum ,

During further testing I discovered that my fix(even though it fixed current issue) breaks something else.
So it would require more time commitment from my side compared to what I initially expected.

To unblock you and to keep the things moving I suggest the following solution:

  1. Could you add an incompatible flag like this: https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java#L62-L69 ?
    Maybe that is not a right file for the flag to live in, this is just an example. So the flag will serve as a switch between your PR behavior vs old behavior. This flag will also make it easier to fix breakages from our side.
  2. You can set the flag to True, so that changes in this PR are picked up by Bazel, and assuming it does not break anyone, it should be fine. I will flip the flag to False internally so that we still use the old implementation until I find a proper fix.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 13, 2022

@buildbreaker2021 I pushed a new commit that gates the change behind a flag that defaults to true.

@buildbreaker2021 buildbreaker2021 added the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Oct 13, 2022
@fmeum
Copy link
Collaborator Author

fmeum commented Oct 13, 2022

@buildbreaker2021 I forgot to carry the new flag over in getHost(). I force-pushed a new version, please import that one.

@buildbreaker2021
Copy link
Contributor

A quick update.

After seeing @fmeum 's latest commit I realized that going in a flag direction would be quite tedious, since on top of the flag we would need to add the logic which would split implementation in two branches etc.
I found some time on Friday and I think I fixed the underlying issue without adding the flag. So I rolled forward the initial PR without a flag - let's hope it sticks this time.

@fmeum fmeum deleted the 14600-all-rpath-cases branch October 17, 2022 13:31
@sgowroji sgowroji removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Oct 18, 2022
@meteorcloudy meteorcloudy removed this from the 6.0.0 nice to have milestone Jan 4, 2023
@meteorcloudy
Copy link
Member

I'm cleaning up the 6.0.0 nice to have label, do we still want to cherry pick this change into the next 6.x release? If so, feel free to mark it!

@fmeum
Copy link
Collaborator Author

fmeum commented Jan 4, 2023

This was merged before the baseline cut, so it's already in 6.0.0.

@meteorcloudy
Copy link
Member

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants