Skip to content

configury: use javac vs javah whenever possible. #5001

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

Merged
merged 2 commits into from
Apr 6, 2018

Conversation

ggouaillardet
Copy link
Contributor

javah has been removed from Java 10, so use javac -h instead
(that is already usable in Java 8)

Refs. #5000

Signed-off-by: Gilles Gouaillardet [email protected]

@ggouaillardet
Copy link
Contributor Author

@hppritcha @bwbarrett FYI, this PR might break JDK older than 8.

@kawashima-fj
Copy link
Member

@hppritcha @bwbarrett @jsquyres This change is required to support recently-released OpenJDK 10. But it causes a make-time error with OpenJDK 7 and older. JDK 7 was released in 2011. This problem appears only in the non-default --enable-mpi-java build. Supported JDK versions are described in README.JAVA.txt Can I merge it to master (and release branches)?

Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

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

Works for me.

@hppritcha
Copy link
Member

looks good to me. jenkins 32bit builds still not happy but that has nothing to do with this PR.

@hppritcha hppritcha added the NEWS label Apr 2, 2018
@open-mpi open-mpi deleted a comment from ibm-ompi Apr 2, 2018
@jjhursey
Copy link
Member

jjhursey commented Apr 2, 2018

bot:ibm:gnu:retest

@bwbarrett
Copy link
Member

bot:ompi:retest

Brian broke the 32bit builds...

@hppritcha
Copy link
Member

@kawashima-fj have you tried to build the java bindings with java 7? I vaguely recall that some more recent additions to the bindings prevent compiling with java7. Can you check this?

@kawashima-fj
Copy link
Member

@hppritcha Yes, I tried it.

Without this PR:

  • OpenJDK 7 on CentOS 6.9: can build and run

With this PR:

  • OpenJDK 7 on CentOS 6.9: cannot build Open MPI (make-time error)
  • OpenJDK 8 on CentOS 7.4: can build and run
  • OpenJDK 9 on CentOS 7.4: can build and run
  • OpenJDK 10 on CentOS 7.4: can build and run

I confirmed the following things on x86_64.

  • Open MPI can be built with --enable-mpi-java
  • examples/Ring.java can be built by mpijavac
  • examples/Ring.java can be run by mpiexec

A possible related issue is #3705/#4121. I will recall it...

@RandomDSdevel
Copy link
Contributor

     As I mentioned here on the developer mailing list, I'll rebase an attempt to fix how Open mPI's build process handles finding JDK tools on OS X/macOS that I'm working on (still only locally at the moment, but it will become a PR soon) against this after it's merged.

@ggouaillardet
Copy link
Contributor Author

let me know if we want to support JDK < 8.
In this case, I will also check javah -version is working and use some macros to handle the legacy case

@bwbarrett
Copy link
Member

For 3.0 and 3.1, we definitely want to keep supporting Java 7, because otherwise we'd have a fairly major backwards compatibility problem. I think 4.0 (aka master) is an open question.

@ggouaillardet ggouaillardet changed the title configury: replace javah with javac -h configury: use javac -h when javah cannot be used. Apr 3, 2018
@ggouaillardet
Copy link
Contributor Author

@bwbarrett I reworked this PR so tries javah first, and then fallback to javac -h.
Not ideal imho, but much simpler than doing it the other way around.

@kawashima-fj
Copy link
Member

@ggouaillardet If you have JDK 8 in /usr/bin and JDK 10 in another directory specified in --with-jdk-dir, Open MPI make fails with Could not find class file for 'mpi.MPI' error.

In this case, $JDK10/bin/javac is set in JAVAC and /usr/bin/javah is set in JAVAH. JDK 10 javac generates *.class. JDK 8 javah tries to generates *.h from *.class but it cannot because JDK 8 cannot read *.class generated by JDK 10 (class file version incompatibility).

@ggouaillardet
Copy link
Contributor Author

Good point, I will think about a solution.

@ggouaillardet
Copy link
Contributor Author

@kawashima-fj it should be good now

  • first, try javac -h
  • if fails, then ensure javah is available

@ggouaillardet ggouaillardet changed the title configury: use javac -h when javah cannot be used. configury: use javac -h when possible. Apr 4, 2018
@kawashima-fj
Copy link
Member

@ggouaillardet I confirmed almost successful build & run with OpenJDK 7/8/9/10 and javah is used only with OpenJDK 7. But I sometimes see an error when I use parallel make.

$ cd build/ompi/mpi/java/java
$ make -j32
  JAVAC    mpi_MPI.h
  JAVAC    mpi_Comm.h
  JAVAC    mpi_Count.h
  JAVAC    mpi_CartParms.h
  JAVAC    mpi_Datatype.h
  JAVAC    mpi_CartComm.h
  JAVAC    mpi_Constant.h
  JAVAC    mpi_Errhandler.h
  JAVAC    mpi_File.h
  JAVAC    mpi_GraphComm.h
  JAVAC    mpi_GraphParms.h
  JAVAC    mpi_Group.h
  JAVAC    mpi_Info.h
  JAVAC    mpi_Op.h
  JAVAC    mpi_Intercomm.h
  JAVAC    mpi_Intracomm.h
  JAVAC    mpi_Message.h
  JAVAC    mpi_Prequest.h
  JAVAC    mpi_ShiftParms.h
  JAVAC    mpi_Request.h
  JAVAC    mpi_Status.h
  JAVAC    mpi_Version.h
JAVADOC    doc
  JAVAC    mpi_Win.h
../../../../../ompi/mpi/java/java/Intracomm.java:134: error: cannot access Info
        @Override public Intracomm dupWithInfo(Info info) throws MPIException
                                               ^
  bad class file: ./mpi/Info.class
    class file contains wrong class: mpi.MPIException
    Please remove or make sure it appears in the correct subdirectory of the classpath.
1 error
make: *** [mpi_Intracomm.h] Error 1
make: *** Waiting for unfinished jobs....

I finally find that javac -h . -d . Foo.java creates Foo.h and Foo.class at the same time and javac -h . -d . Bar.java reads Foo.class if Bar.java uses Foo class. It causes a race. One possible solution will be adding -h . to the rule for mpi/MPI.class and delete the rule for $(JAVA_H) if OPAL_HAVE_JAVAH_SUPPORT is true.

@ggouaillardet
Copy link
Contributor Author

@kawashima-fj thanks for the insight ! I suspected such an issue might occur, but was unable to evidence it. I will fully review the process and update the PR

javah is no more available from Java 10, so try
javac -h first (available since Java 8) and fallback on javah

Refs. open-mpi#5000

Signed-off-by: Gilles Gouaillardet <[email protected]>
@ggouaillardet ggouaillardet changed the title configury: use javac -h when possible. configury: use javac vs javah whenever possible. Apr 5, 2018
@ggouaillardet
Copy link
Contributor Author

@kawashima-fj we should be good now, can you please give this PR a final review ?

@ggouaillardet
Copy link
Contributor Author

:bot:mellanox:retest

@kawashima-fj
Copy link
Member

@ggouaillardet I'll review and test later today or tomorrow.

@kawashima-fj
Copy link
Member

@ggouaillardet I reviewed and tested it on OpenJDK 7/8/9/10. Perfect.

For our record:
This change affects Open MPI only when the non-default --enable-mpi-java option (Open MPI Java binding) is specified to configure.
Without this change, building Open MPI with OpenJDK 10 (and future versions) fails because OpenJDK 10 dropped javah command.
With this change, all recent OpenJDK versions (at least 7, 8, 9, and 10) are supported.
I don't know other vendor's JDK. But if Open MPI can be built without this change, it can also be built with this change.
The combination of OpenJDK 10 and OS X/macOS has still the issue #5000. The PR #5015 is proposed for it.

@kawashima-fj kawashima-fj merged commit 5e12e0f into open-mpi:master Apr 6, 2018
ggouaillardet pushed a commit to ggouaillardet/ompi that referenced this pull request May 1, 2018
…acOS.

Also avoid picking up Apple's Java shims via the sym. links to them in
`/usr/bin` on systems where any one of them could possibly exhibit behavior
that is erratic and, to some extent, likely to be incorrect nowadays (cf.:

- https://www.mail-archive.com/[email protected]/msg20551.html
- open-mpi#5015 (comment)
- the last part  of
  open-mpi#5015 (comment)
- open-mpi#5015 (comment)

for more detailed context.)

Works alongside open-mpi#5001 to close open-mpi#5000.

Signed-off-by: Bryce Glover <[email protected]>

(cherry picked from commit open-mpi/ompi@8c32cd8)
ggouaillardet pushed a commit to ggouaillardet/ompi that referenced this pull request May 1, 2018
…acOS.

Also avoid picking up Apple's Java shims via the sym. links to them in
`/usr/bin` on systems where any one of them could possibly exhibit behavior
that is erratic and, to some extent, likely to be incorrect nowadays (cf.:

- https://www.mail-archive.com/[email protected]/msg20551.html
- open-mpi#5015 (comment)
- the last part  of
  open-mpi#5015 (comment)
- open-mpi#5015 (comment)

for more detailed context.)

Works alongside open-mpi#5001 to close open-mpi#5000.

Signed-off-by: Bryce Glover <[email protected]>

(cherry picked from commit open-mpi/ompi@8c32cd8)
@bosilca
Copy link
Member

bosilca commented May 9, 2018

This broke OMPI on OSX systems without Java SDK. The configure exits with the following:

*** Java compiler
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
checking OS X/macOS locations... found ()
configure: WARNING: No recognized directory structure found under
configure: error: Cannot continue

@RandomDSdevel
Copy link
Contributor

@bosilca:

     Are you sure that this PR is to blame? That looks like the part of the build infrastructure that goes through the logic I changed in #5015. I'm not sure how what I did could have caused this to break, though, at least at first glance; I'm pretty sure I didn't touch anything having to do with whether the Java bindings are enabled or not, and I would suspect that those always required you to have a JDK installed…

@bosilca
Copy link
Member

bosilca commented May 9, 2018

I am not 100% sure this PR was to be blamed, but I thought it was the last thing that touched the java support.

If I don't want java bindings, and especially if I did not requested them specifically, why should I have an SDK installed ?

@jsquyres
Copy link
Member

jsquyres commented May 9, 2018

George is right -- we do not require a Java SDK to build/run OMPI. Regardless of whether it was this PR or #5001, both of them touched the Java configury recently, and we apparently got it wrong. 😦

@RandomDSdevel
Copy link
Contributor

@jsquyres:

     Well, back to the drawing board it is, then. Upon further investigation, I believe my inserting this line into that file as a blind copy of the suggestion that you requested near the bottom of the code sketch you put in list item 2 of this review comment of yours is to blame; one of us should have noticed that this would cause this part of the build scripting to abort and thus make the fallback logic below unreachable. Removing that line should fix the resulting problem that @bosilca reported; I'll file a new PR to do just that against master shortly, and then that can get backported to the other branches (unless you want me to muck with Git history, although that…doesn't sound like a very good idea.)

@RandomDSdevel
Copy link
Contributor

@jsquyres: Submitted as #5160.

@jsquyres
Copy link
Member

jsquyres commented May 9, 2018

@RandomDSdevel Perfect -- thanks! (and correct: mucking with public git history in a large multi-developer project -- just say no!)

jsquyres pushed a commit to jsquyres/ompi that referenced this pull request May 9, 2018
     That PR accidentally changed Open MPI's build configuration infrastruc-
ture's Java toolchain detection logic so that it would, as reported by @bosilca
in open-mpi#5001 (comment) and tracked down by me in open-mpi#5001 (comment), abort your entire
in-progress Open MPI build when it failed to find an OS X/macOS JDK instead of
simply falling back to checking for a JDK in locations where it would be found
on other platforms.  _Oops…!_

Signed-off-by: Bryce Glover <[email protected]>
(cherry picked from commit 4a05c7e)
ggouaillardet pushed a commit to ggouaillardet/ompi that referenced this pull request May 10, 2018
     That PR accidentally changed Open MPI's build configuration infrastruc-
ture's Java toolchain detection logic so that it would, as reported by @bosilca
in open-mpi#5001 (comment) and tracked down by me in open-mpi#5001 (comment), abort your entire
in-progress Open MPI build when it failed to find an OS X/macOS JDK instead of
simply falling back to checking for a JDK in locations where it would be found
on other platforms.  _Oops…!_

Signed-off-by: Bryce Glover <[email protected]>

(cherry picked from commit open-mpi/ompi@4a05c7e)
kawashima-fj pushed a commit to kawashima-fj/ompi that referenced this pull request May 10, 2018
     That PR accidentally changed Open MPI's build configuration infrastruc-
ture's Java toolchain detection logic so that it would, as reported by @bosilca
in open-mpi#5001 (comment) and tracked down by me in open-mpi#5001 (comment), abort your entire
in-progress Open MPI build when it failed to find an OS X/macOS JDK instead of
simply falling back to checking for a JDK in locations where it would be found
on other platforms.  _Oops…!_

Signed-off-by: Bryce Glover <[email protected]>
(cherry picked from commit 4a05c7e)
hppritcha pushed a commit that referenced this pull request May 10, 2018
…acOS.

Also avoid picking up Apple's Java shims via the sym. links to them in
`/usr/bin` on systems where any one of them could possibly exhibit behavior
that is erratic and, to some extent, likely to be incorrect nowadays (cf.:

- https://www.mail-archive.com/[email protected]/msg20551.html
- #5015 (comment)
- the last part  of
  #5015 (comment)
- #5015 (comment)

for more detailed context.)

Works alongside #5001 to close #5000.

Signed-off-by: Bryce Glover <[email protected]>
(cherry picked from commit 8c32cd8)
Signed-off-by: KAWASHIMA Takahiro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants