RFR: 8327045: Consolidate -fvisibility=hidden as a basic flag for all compilation

Magnus Ihse Bursie ihse at openjdk.org
Fri Mar 8 17:03:02 UTC 2024


On Thu, 29 Feb 2024 12:23:37 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

> After we removed mapfiles, we can setup -fvisibility=hidden (and -Wl,--exclude-libs,ALL) in the most basic flags, so this applies to all compilation.
> 
> This will remove duplicate code and make the underlying assumptions of the build clearer.
> 
> Doing this will result in the same output result -- with one exception: native test libraries has not been compiled with this flag (and this caused an error for a Oracle-internal test).

Our sloppy approach to symbol visibility has left us a lot of issues now that we need to tighten it up for Hermetic Java. :-( I don't see any good reason not to treat test code just as properly as production code. When developing this patch, I noticed other parts of the build that had slipped between the cracks, so I really, really want to have a complete solution for all native code we produce.

With that said, of course we need to find a solution that is adequate for the tests in question. If including "jni.h" is no good, then of course we should not do that. 

My plan is to basically put this PR on hold for the moment, and find a proper way to turn on `-fvisibility=hidden` for test code as a separate issue. Once that is done, this PR will basically turn into a trivial unification of duplicated code in the build system + fixing a few laggards.

I have rebased this PR to instead build upon [JDK-8327460](https://bugs.openjdk.org/browse/JDK-8327460), PR https://github.com/openjdk/jdk/pull/18135. All changes to the tests has been moved to that PR, so this only deals with the makefile cleanup.

I apologize if it makes Jorns comments hard to understand due to removed context. (In summary, JDK-8327460 was created trying to address his comments.)

-------------

PR Comment: https://git.openjdk.org/jdk/pull/18061#issuecomment-1979105400
PR Comment: https://git.openjdk.org/jdk/pull/18061#issuecomment-1981006960


More information about the build-dev mailing list