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

JDK-8317799 : AIX PPC64: FFI symbol lookup doesn't find symbols #16414

Closed
wants to merge 13 commits into from

Conversation

suchismith1993
Copy link
Contributor

@suchismith1993 suchismith1993 commented Oct 30, 2023

The math library in AIX specifically, is a static archive. Doing a -lm wont suffice, because when the symbols are looked up using dlsym or accessing native code through Java, it will lead to failures.
Hence we had to come up with a list of symbols to allow math library symbols to be accesible.
Also, there are parts of libc library that are static too, and hence those symbols also are present in this list.
Without this change, the StdLibTest and multiple other tests which make native function calls using FFI, fail with NoSuchElementException.

  1. Adding required compiler flags.
  2. Adding required symbols.

JBS-ISSUE : JDK-8317799


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-8317799: AIX PPC64: FFI symbol lookup doesn't find symbols (Sub-task - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16414

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Oct 30, 2023
@bridgekeeper
Copy link

bridgekeeper bot commented Oct 30, 2023

Hi @suchismith1993, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user suchismith1993" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link

openjdk bot commented Oct 30, 2023

@suchismith1993 The following labels will be automatically applied to this pull request:

  • build
  • core-libs

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

@openjdk openjdk bot added build build-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Oct 30, 2023
@suchismith1993
Copy link
Contributor Author

/covered

@bridgekeeper bridgekeeper bot added the oca-verify Needs verification of OCA signatory status label Oct 30, 2023
@bridgekeeper
Copy link

bridgekeeper bot commented Oct 30, 2023

Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@@ -213,8 +213,10 @@ $(eval $(call SetupJdkLibrary, BUILD_SYSLOOKUPLIB, \
CXXFLAGS := $(CXXFLAGS_JDKLIB), \
LDFLAGS := $(LDFLAGS_JDKLIB), \
LDFLAGS_linux := -Wl$(COMMA)--no-as-needed, \
LDFLAGS_aix := -brtl -bloadmap:/home/hotspot/openjdk/symbol.log -bE:/home/hotspot/tmp/all-libs/1.exp , \
Copy link
Contributor

Choose a reason for hiding this comment

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

These files need to get added somewhere. Maybe symbols could get added to make/data/hotspot-symbols/symbols-aix? Or to new files in the same directory (with aix in the file names)?
Also, please remove extra whitespaces.

TARGETS += $(BUILD_LIB_SIMD_SORT)
endif

################################################################################
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this was done by mistake. Please revert.





Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid changing lines which you don't need to modify! Is #include <math.h> really needed, here? If so, please protect it by #ifdef _AIX and add a comment explaining why.

@suchismith1993 suchismith1993 force-pushed the pull/16179 branch 9 times, most recently from 07effd7 to 4533b71 Compare November 6, 2023 17:31
Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

LGTM. You may want to replace the Copyright header of the new file. It was contributed by IBM.

@suchismith1993 suchismith1993 marked this pull request as ready for review November 8, 2023 16:18
Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

Still good. I suggest to remove the empty lines at the beginning.

@bridgekeeper bridgekeeper bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels Nov 8, 2023
@openjdk
Copy link

openjdk bot commented Nov 8, 2023

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

8317799: AIX PPC64: FFI symbol lookup doesn't find symbols

Reviewed-by: mdoerr, ihse, dholmes, jvernee

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 21 new commits pushed to 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TheRealMDoerr, @magicus, @dholmes-ora, @JornVernee) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 8, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 8, 2023

@magicus
Copy link
Member

magicus commented Nov 8, 2023

No, no... This is bad on several accounts.

@magicus
Copy link
Member

magicus commented Nov 8, 2023

First and foremost, the make/data/hotspot-symbols directory is, as the name says, for hotspot symbols. These are not hotspot symbols. If you really do need the file, then it needs to reside in a proper location.

Secondly: do you really need this file? It looks just like an enumeration of (a subset of?) standard library functions. This looks like a completely incorrect solution to the problem. How did you arrive at this list? What if in the future new functions are added to the standard library?

@magicus
Copy link
Member

magicus commented Nov 8, 2023

Also, please don't ever force push once you have published a PR. Now it makes Martin's comment just dangling in the air.

#include <stdlib.h>
#include <math.h>

// Simple dummy function so this library appears as a normal library to tooling.
Copy link
Member

Choose a reason for hiding this comment

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

I assume this comment should be on line 207 instead..?

@magicus
Copy link
Member

magicus commented Nov 21, 2023

This looks like a much saner solution than the original attempt.


char* syslookup() {
return "syslookup";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably not needed, either (see Windows version).

// Adding at least one #include removes unwanted warnings on some platforms.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are string.h and stdlib.h needed? I can't see them in the comments below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

string.h is needed for strlen. Let me check for stdlib.h by excluding it.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, a comment above strlen would help.

#include <stdlib.h>
#include <math.h>

// Addresses of functions to referenced using static linking.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "functions to referenced" mean? Typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be Referenced*. Is that the right comment ?

Copy link
Contributor

@TheRealMDoerr TheRealMDoerr 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 cleaning it up! LGTM.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

This is much more palatable and good to be consistent with what is done on Windows. Thank.

@JornVernee
Copy link
Member

Note that on Windows we also have a lookup mechanism on the Java side:

private enum WindowsFallbackSymbols {

On Windows we need to load the global array, and then grab functions from the array. Why isn't that needed on AIX? Is dlsym able to find the statically linked functions as well?

@suchismith1993
Copy link
Contributor Author

suchismith1993 commented Nov 22, 2023 via email

Co-authored-by: Amit Kumar <amitlocham09@icloud.com>
@suchismith1993
Copy link
Contributor Author

Thank you @JornVernee @magicus @dholmes-ora @TheRealMDoerr @erikj79
Thanks for enocuraging to work towards a better solution which enabled me to understand and explore windows code as well.

@suchismith1993
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Nov 22, 2023
@openjdk
Copy link

openjdk bot commented Nov 22, 2023

@suchismith1993
Your change (at version 7a68313) is now ready to be sponsored by a Committer.

@offamitkumar
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 22, 2023

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 22, 2023
@openjdk openjdk bot closed this Nov 22, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Nov 22, 2023
@openjdk
Copy link

openjdk bot commented Nov 22, 2023

@offamitkumar @suchismith1993 Pushed as commit 25cebe8.

💡 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 core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

8 participants