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

8326685: Linux builds not reproducible if two builds configured in different build folders #18009

Closed

Conversation

andrew-m-leonard
Copy link

@andrew-m-leonard andrew-m-leonard commented Feb 26, 2024

Adds Linux -fdebug-prefix-map'ing for SUPPORT_OUTPUTDIR and HOTSPOT_OUTPUTDIR when absolute paths are not allowed in the binaries, thus making the building of a JDK identically reproducible from different build directories.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8326685: Linux builds not reproducible if two builds configured in different build folders (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18009/head:pull/18009
$ git checkout pull/18009

Update a local copy of the PR:
$ git checkout pull/18009
$ git pull https://git.openjdk.org/jdk.git pull/18009/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18009

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18009.diff

Webrev

Link to Webrev Comment

…fferent build folders

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 26, 2024

👋 Welcome back aleonard! 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 the rfr Pull request is ready for review label Feb 26, 2024
@openjdk
Copy link

openjdk bot commented Feb 26, 2024

@andrew-m-leonard The following label will be automatically applied to this pull request:

  • build

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the build build-dev@openjdk.org label Feb 26, 2024
@mlbridge
Copy link

mlbridge bot commented Feb 26, 2024

Webrevs

@andrew-m-leonard
Copy link
Author

Tested locally on an aarch64 VM, with two build directories, build1 and build2. The resulting jdk image was identical.

Comment on lines 125 to 126
DEBUG_PREFIX_CFLAGS="$DEBUG_PREFIX_CFLAGS -fdebug-prefix-map=\$(SUPPORT_OUTPUTDIR)/="
DEBUG_PREFIX_CFLAGS="$DEBUG_PREFIX_CFLAGS -fdebug-prefix-map=\$(HOTSPOT_OUTPUTDIR)/="
Copy link
Member

Choose a reason for hiding this comment

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

This is only a problem if the build directory is located outside the workspace root. In the case where the build directory is inside the root, I think it would be preferable to stick to just the one prefix map, for consistent relative paths for all affected files. If the build directory is outside, like in your example, I would suggest adding just $(OUTPUTDIR)/= to both -fdebug-prefix-map and -fmacro-prefix-map for consistency. We don't seem to have a variable indicating if the OUTPUTDIR is inside WORKSPACE_ROOT or not, but we can add one in basic.m4 where the OUTPUTDIR is initialized. Then you can conditionally add the extra prefix maps based on that variable.

Copy link
Member

Choose a reason for hiding this comment

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

I have not thought this fully through, but just throwing out a question: would this work even if one build directory were inside the workspace root, and the other not?

Copy link
Member

Choose a reason for hiding this comment

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

Oh you are right, we should always add the OUTPUTDIR to both maps regardless of if it's internal to the WORKSPACE_ROOT or not. Paths relative to the OUTPUTDIR should be stable across builds in different output directories, but paths inside the OUTPUTDIR, expressed as relative to the WORKSPACE_ROOT will vary.

Copy link
Author

Choose a reason for hiding this comment

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

I have not thought this fully through, but just throwing out a question: would this work even if one build directory were inside the workspace root, and the other not?

Yes, I have tested that scenario as well, and does work. It was in fact the scenario in which I discovered the problem in the first place.

Copy link
Author

Choose a reason for hiding this comment

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

Oh you are right, we should always add the OUTPUTDIR to both maps regardless of if it's internal to the WORKSPACE_ROOT or not. Paths relative to the OUTPUTDIR should be stable across builds in different output directories, but paths inside the OUTPUTDIR, expressed as relative to the WORKSPACE_ROOT will vary.

@erikj79 @magicus Yes, it needs to always be present as you've pointed out the OUTPUTDIR when within the WORKSPACE will be eg.WORKSPACE/build/linux-aarch64-server-release/support and the standard WORKSPACE mapping will make that build/linux-aarch64-server-release/support, but a build dir outside will be simply <any_path>/support

Copy link
Member

Choose a reason for hiding this comment

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

Also, this mapping business is getting really convoluted. :-( I did not like it as it was, and this patch makes it even worse. I think we need to rewrite this to create some kind of dict/map, and then iterate over the map and apply -fdebug-prefix-map to all items in the map. Unfortunately, the data structures available in shell scripts is limited and will make this a bit tricky to pull off. :(

Copy link
Author

Choose a reason for hiding this comment

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

It seems correct to include the output dir in the remapping, but I have two objections/questions to the way you are doing it.

1. Why not just use OUTPUTDIR instead of the two specialized subdirs? That is simpler, more general and future-proof.

2. Why not expand the value of the OUTPUTDIR variable? I.e.
 DEBUG_PREFIX_CFLAGS="$DEBUG_PREFIX_CFLAGS -fdebug-prefix-map=$OUTPUTDIR/="

instead of trying to preserve it as a variable to be expanded in the make execution.

Ah thanks @magicus I hadn't seen that existed! that would simplify it, i'll try that now

Copy link
Author

Choose a reason for hiding this comment

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

Also, this mapping business is getting really convoluted. :-( I did not like it as it was, and this patch makes it even worse. I think we need to rewrite this to create some kind of dict/map, and then iterate over the map and apply -fdebug-prefix-map to all items in the map. Unfortunately, the data structures available in shell scripts is limited and will make this a bit tricky to pull off. :(

yeah, although that's not easy for example for the gcc include paths that we have to work out based on the users compiler paths, so it wouldn't be a simple dict

Copy link
Author

Choose a reason for hiding this comment

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

@magicus thank you for the tip, it works nicely, ready for re-review please

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me now, but please let Erik have a look as well before pushing.

…fferent build folders

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
…fferent build folders

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
@openjdk
Copy link

openjdk bot commented Feb 27, 2024

@andrew-m-leonard 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:

8326685: Linux builds not reproducible if two builds configured in different build folders

Reviewed-by: ihse, erikj

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 33 new commits pushed to the master branch:

  • 552411f: 8326824: Test: remove redundant test in compiler/vectorapi/reshape/utils/TestCastMethods.java
  • 9f0e7da: 8326638: Crash in PhaseIdealLoop::remix_address_expressions due to unexpected Region instead of Loop
  • 81b065a: 8326714: Make file-local functions static in src/java.base/unix/native/libjava/childproc.c
  • 4fcae1a: 8326722: Cleanup unnecessary forward declaration in collectedHeap.hpp
  • c5c866a: 8326219: applications/kitchensink/Kitchensink8H.java timed out
  • ac3ce2a: 8326583: Remove over-generalized DefineNativeToolchain solution
  • bceaed6: 8326406: Remove mapfile support from makefiles
  • 16d917a: 8313710: jcmd: typo in the documentation of JFR.start and JFR.dump
  • 60cbf29: 8325754: Dead AbstractQueuedSynchronizer$ConditionNodes survive minor garbage collections
  • da14aa4: 8017234: Hotspot should stop using mapfiles
  • ... and 23 more: https://git.openjdk.org/jdk/compare/bb6b04897b5d83dd89fc11074dd66af024f9c6fc...master

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 Pull request is ready to be integrated label Feb 27, 2024
@andrew-m-leonard
Copy link
Author

@erikj79 ready for re-review please

@andrew-m-leonard
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 28, 2024

Going to push as commit 3b90ddf.
Since your change was applied there have been 39 commits pushed to the master branch:

  • 9b1f1e5: 8326389: [test] improve assertEquals failure output
  • 6cad07c: 8325746: Refactor Loop Unswitching code
  • 4dd6c44: 8326529: JFR: Test for CompilerCompile events fails due to time out
  • 33f2382: 8325807: Shenandoah: Refactor full gc in preparation for generational mode changes
  • 419191c: 8325680: Uninitialised memory in deleteGSSCB of GSSLibStub.c:179
  • 349df0a: 8326726: Problem list Exhaustiveness.java due to 8326616
  • 552411f: 8326824: Test: remove redundant test in compiler/vectorapi/reshape/utils/TestCastMethods.java
  • 9f0e7da: 8326638: Crash in PhaseIdealLoop::remix_address_expressions due to unexpected Region instead of Loop
  • 81b065a: 8326714: Make file-local functions static in src/java.base/unix/native/libjava/childproc.c
  • 4fcae1a: 8326722: Cleanup unnecessary forward declaration in collectedHeap.hpp
  • ... and 29 more: https://git.openjdk.org/jdk/compare/bb6b04897b5d83dd89fc11074dd66af024f9c6fc...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 28, 2024
@openjdk openjdk bot closed this Feb 28, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 28, 2024
@openjdk
Copy link

openjdk bot commented Feb 28, 2024

@andrew-m-leonard Pushed as commit 3b90ddf.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants