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

8256012: Fix build of Monocle for Linux #350

Closed
wants to merge 3 commits into from

Conversation

jgneff
Copy link
Member

@jgneff jgneff commented Nov 7, 2020

This pull request fixes the error when building embedded JavaFX for Linux.

The error occurs because MonocleGLFactory.c does not define the macro __USE_GNU before including the header file dlfcn.h. The two lines in the conditional group "#ifndef ANDROID" below have no effect because the header file has already been included at that point, and the header contains include guards to ignore subsequent attempts.

MonocleGLFactory.c

...
#include <EGL/egl.h>
#include "eglUtils.h"

#include "../PrismES2Defs.h"

#include "com_sun_prism_es2_MonocleGLContext.h"
#ifndef ANDROID
#define __USE_GNU
#include <dlfcn.h>
#endif
...

The -H option of gcc prints the name of each header file used. Its output shows that egl.h ends up including dlfcn.h indirectly, but without the required macro definition.

$ grep -e 'EGL/egl.h' -e 'eglUtils.h' -e 'dlfcn.h' headers.log
. opt/vc/include/EGL/egl.h
...... usr/include/dlfcn.h
....... usr/include/arm-linux-gnueabihf/bits/dlfcn.h
. monocle/eglUtils.h

For the proposed fix, I referred to the page of the Linux Programmer's Manual at "man dlsym" which states, "The _GNU_SOURCE feature test macro must be defined in order to obtain the definitions of RTLD_DEFAULT and RTLD_NEXT from <dlfcn.h>." I also used information in the following two Stack Overflow conversations:


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jfx pull/350/head:pull/350
$ git checkout pull/350

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 7, 2020

👋 Welcome back jgneff! 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 Ready for review label Nov 7, 2020
@mlbridge
Copy link

mlbridge bot commented Nov 7, 2020

Webrevs

@johanvos
Copy link
Collaborator

I don't see any harm in this PR, but I wonder which toolchains are still not having RTLD_NEXT without specifying GNU_SOURCE. Does it also work if you specify -D__USE_GNU to the compiler?

@jgneff
Copy link
Member Author

jgneff commented Nov 26, 2020

I don't see any harm in this PR, but I wonder which toolchains are still not having RTLD_NEXT without specifying GNU_SOURCE.

Thanks, Johan. I've been following the instructions in the OpenJFX Wiki. I use the GCC cross-compiler installed by the repository's crosslibs-armv6hf.sh script. Then I build for ARM using the repository's armv6hf.gradle build file.

Does it also work if you specify -D__USE_GNU to the compiler?

No, that prints the same error. The comments in the header file /usr/include/features.h suggest that the macro __USE_GNU is for internal use, while _GNU_SOURCE is defined by the user. I tried the user macro, and it works!

So below is an alternative fix in the ARM build file:

diff --git a/buildSrc/armv6hf.gradle b/buildSrc/armv6hf.gradle
index 05e3e83551..bd56dcf86c 100644
--- a/buildSrc/armv6hf.gradle
+++ b/buildSrc/armv6hf.gradle
@@ -140,7 +140,7 @@ def iioCFlags = [extraCFlags,
          ].flatten()
 def iioLFlags = [extraLFlags].flatten()

-def es2EglfbCFlags = [extraCFlags, "-DIS_EGLFB", "-DLINUX"].flatten()
+def es2EglfbCFlags = [extraCFlags, "-DIS_EGLFB", "-DLINUX", "-D_GNU_SOURCE"].flatten()
 def es2EglfbLFlags = [extraLFlags].flatten()
 def es2MonocleCFlags = [extraCFlags, "-DIS_EGLFB", "-DLINUX"].flatten()
 def es2MonocleLFlags = [extraLFlags].flatten()

It seems the _GNU_SOURCE macro does a lot, so it's a question of limiting its use to one C file or enabling it for the entire prism_es2_monocle library. I'm fine with either solution.

@johanvos
Copy link
Collaborator

I think it is safer to use it as a flag for all monocle-es2 compilation then. It is also less intrusive as it doesn't require code changes, so it only affects specific builds.

@openjdk
Copy link

openjdk bot commented Dec 11, 2020

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

8256012: Fix build of Monocle for Linux

Reviewed-by: jvos

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 (@johanvos) 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 the ready Ready to be integrated label Dec 11, 2020
@johanvos
Copy link
Collaborator

@jgneff this looks good to be merged now. You can integrate it and then I will sponsor this.

@jgneff
Copy link
Member Author

jgneff commented Dec 11, 2020

/integrate

@openjdk openjdk bot added the sponsor Ready to sponsor label Dec 11, 2020
@openjdk
Copy link

openjdk bot commented Dec 11, 2020

@jgneff
Your change (at version 2d044e7) is now ready to be sponsored by a Committer.

@johanvos
Copy link
Collaborator

/sponsor

@openjdk openjdk bot closed this Dec 11, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed sponsor Ready to sponsor ready Ready to be integrated rfr Ready for review labels Dec 11, 2020
@openjdk
Copy link

openjdk bot commented Dec 11, 2020

@johanvos @jgneff Pushed as commit 97d655f.

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

@jgneff jgneff deleted the RTLD_DEFAULT branch February 23, 2021 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

2 participants