Skip to content

Conversation

@JoKern65
Copy link
Contributor

@JoKern65 JoKern65 commented Jan 27, 2025

The clang compiler which we use since jdk21 pollutes the burned-in library search paths of the generated executables.
e.g. a dump -X64 -H ... /jdk-23.0.1+11-jre/lib/libnio.so

amongst others produces the following lines

                    ***Import File Strings***

INDEX PATH BASE MEMBER
0 /opt/IBM/openxlC/17.1.1/../../../../usr/lpp/xlC/lib:/opt/IBM/openxlC/17.1.1/lib:/opt/IBM/openxlC/17.1.1/bin/../../../../../usr/lpp/xlC/lib:/usr/opt/zlibNX/lib:/opt/freeware/lib/pthread:/opt/freeware/lib:/usr/lib

The long string is the burned in library search path which will be used after searching with LIBPATH envvar.
You see there are some compiler paths which customers will not have; also /opt/freeware is unwanted.
A proper executable should only have the burned in default search path
/usr/lib:lib

To ensure this we want to call the linker with the flag
-fuse-ld=our-wrapper-script-cleaning-LIBPATH- and-calling-original-ld-afterwards
This script we want to deliver in make/scripts/aix/ld.sh
just containing
#!/bin/bash
unset LIBPATH
exec /usr/bin/ld "$@"
return $?


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-8348663: [AIX] clang pollutes the burned-in library search paths of the generated executables (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23313

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 27, 2025

👋 Welcome back jkern! 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
Copy link

openjdk bot commented Jan 27, 2025

@JoKern65 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:

8348663: [AIX] clang pollutes the burned-in library search paths of the generated executables

Reviewed-by: ihse, clanger, mbaesken

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

  • d985b31: 8342096: Popup menus that request focus are not shown on Linux with Wayland
  • cbe9ec5: 8348905: Add support to specify the JDK for compiling Jtreg tests
  • 6b581d2: 8347997: assert(false) failed: EA: missing memory path
  • 4662363: 8348687: [BACKOUT] C2: Non-fluid StringBuilder pattern bails out in OptoStringConcat
  • d266ca9: 8348752: Enable -XX:+AOTClassLinking by default when -XX:AOTMode is specified
  • cbc89a7: 8348898: Remove unused OctalDigits to clean up code
  • 96fefed: 8319850: PrintInlining should print which methods are late inlines
  • 51cce6e: 8318577: Windows Look-and-Feel JProgressBarUI does not render correctly on 2x UI scale
  • 6bfae3a: 8333386: TestAbortOnVMOperationTimeout test fails for client VM
  • f98d9a3: 8348870: Eliminate array bound checks in DecimalDigits
  • ... and 36 more: https://git.openjdk.org/jdk/compare/afcc2b03afc77f730300e1d92471466d56ed75fb...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 changed the title JDK-8348663: [AIX] clang pollutes the burned-in library search paths of the generated executables 8348663: [AIX] clang pollutes the burned-in library search paths of the generated executables Jan 27, 2025
@openjdk
Copy link

openjdk bot commented Jan 27, 2025

@JoKern65 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 Jan 27, 2025
@JoKern65
Copy link
Contributor Author

@magicus Hi Magnus, I'm faced with the problem that I cannot check in an executable script. On the other side the compilers -fuse_ld parameter needs an executable script. Is there a way to circumvent this.
The only fallback I'm aware of would be to keep the script local and just commit a configure parameter which provides the path to the local script setting then -fuse-ld accordingly.
Are there other solutions possible?

@magicus
Copy link
Member

magicus commented Jan 29, 2025

This look like a very hacky workaround overall. Can't you just unset LIBPATH in spec.gmk? Or just before linking? Is this a documented behavior of the linker on AIX, or a bug?

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 29, 2025
@mlbridge
Copy link

mlbridge bot commented Jan 29, 2025

Webrevs

@JoKern65
Copy link
Contributor Author

Unfortunately, there is no other way. The LIBPATH envvar during our build is already unset. The compiler itself, when called as the Linker is setting some paths into LIBPATH before he calls the real Linker by himself. This is the only way to get rid of the unwanted burned in paths. This was an advice from IBM to do so as a standard trick.
I now checked in the script without x-Bit. Then during configure call it is copied to the build directory, where the x-Bit is set. -fuse-ld= Parameter points now to this copied version.
If you are reluctant with this solution, we additionally can make it dependent from a new configure flag which we would set and nobody else.
By the way, if we try to address this as a possible bug and this is very unlikely accepted by IBM, it will take at least half a year to get a change. And because this would change the behavior of the compiler I'm pretty sure this will only be included in a new Compiler not yet shipped.

@magicus
Copy link
Member

magicus commented Jan 29, 2025

I still think you should report it as a bug, but I accept that we need to have a workaround in the meantime (or forever, if it doesn't get fixed).

However, you need to shape up the patch a bit first.

  • $OUTPUTDIR points to the current configure dir, use that instead.
  • You should use the detected versions of cp and chmod as $CP and $CMHOD.
  • You should not copy files in flags-ldflags.m4, that parts needs to find a better home.
  • The return $? part in the script is useless since exec will make the ld process replace the shell script.

@magicus
Copy link
Member

magicus commented Jan 29, 2025

I'm not sure what is a better place. Perhaps BASIC_POST_CONFIG_OUTPUT where we copy/chmod other files, even if this one is not strictly necessary to do late in the configure process.

@JoKern65
Copy link
Contributor Author

I followed all of Magnus proposals:
I used $OUTPUTDIR instead of ${TOPDIR}/build/${CONF_NAME}.
I replaced cp and chmod by $CP and $CMHOD.
I moved the copy and mode bit change from flags-ldflags.m4 to BASIC_POST_CONFIG_OUTPUT in basic.m4 .
I removed the useless return $? from my script.

# Copy the linker wrapper script for AIX' clang and make it executable
if test "x$TOOLCHAIN_TYPE" = xclang && test "x$OPENJDK_TARGET_OS" = xaix &&
test -e "${TOPDIR}/make/scripts/aix/ld.sh"; then
Copy link
Member

Choose a reason for hiding this comment

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

You can assume that checked-in files exist and do not need to test for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

# Copy the linker wrapper script for AIX' clang and make it executable
if test "x$TOOLCHAIN_TYPE" = xclang && test "x$OPENJDK_TARGET_OS" = xaix &&
test -e "${TOPDIR}/make/scripts/aix/ld.sh"; then
$CP -f "${TOPDIR}/make/scripts/aix/ld.sh" "$OUTPUTDIR/ld.sh"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$CP -f "${TOPDIR}/make/scripts/aix/ld.sh" "$OUTPUTDIR/ld.sh"
$CP -f "$TOPDIR/make/scripts/aix/ld.sh" "$OUTPUTDIR/ld.sh"

We normally prefer to use $ without {} unless they are necessary, but in some parts of the code the ${} style is prevalent for historical reasons, and in those places it is better to keep with that style. But for code like this, you should stick to the {}-less style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

# Make the compare script executable
$CHMOD +x $OUTPUTDIR/compare.sh
# Copy the linker wrapper script for AIX' clang and make it executable
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Copy the linker wrapper script for AIX' clang and make it executable
# Copy the linker wrapper script for clang on AIX and make it executable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@magicus
Copy link
Member

magicus commented Jan 29, 2025

Just one comment fix and then this is okay. Also please verify that the latest version still works on AIX.

@JoKern65
Copy link
Contributor Author

All done and also latest version still works on AIX.

Copy link
Member

@magicus magicus left a comment

Choose a reason for hiding this comment

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

Looks good now. Thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 29, 2025
@RealCLanger
Copy link
Contributor

Looks good to me, too. However, you should update the copyright years in the modified files and also add a license header in the newly added script (like in other .sh files in that directory but with SAP copyright).

@JoKern65
Copy link
Contributor Author

Copyrights modified/added.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jan 29, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 29, 2025
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

You can leave out Oracle here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jan 29, 2025
Copy link
Contributor

@RealCLanger RealCLanger left a comment

Choose a reason for hiding this comment

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

Close to perfect. 😄

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 29, 2025
@JoKern65
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 30, 2025

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

  • 14136f8: 8347564: ZGC: Crash in DependencyContext::clean_unloading_dependents
  • 04c24f1: 8347779: sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java fails with Unable to deduce type of thread from address
  • d985b31: 8342096: Popup menus that request focus are not shown on Linux with Wayland
  • cbe9ec5: 8348905: Add support to specify the JDK for compiling Jtreg tests
  • 6b581d2: 8347997: assert(false) failed: EA: missing memory path
  • 4662363: 8348687: [BACKOUT] C2: Non-fluid StringBuilder pattern bails out in OptoStringConcat
  • d266ca9: 8348752: Enable -XX:+AOTClassLinking by default when -XX:AOTMode is specified
  • cbc89a7: 8348898: Remove unused OctalDigits to clean up code
  • 96fefed: 8319850: PrintInlining should print which methods are late inlines
  • 51cce6e: 8318577: Windows Look-and-Feel JProgressBarUI does not render correctly on 2x UI scale
  • ... and 38 more: https://git.openjdk.org/jdk/compare/afcc2b03afc77f730300e1d92471466d56ed75fb...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 30, 2025

@JoKern65 Pushed as commit e0c2cb4.

💡 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.

4 participants