Skip to content

Conversation

@magicus
Copy link
Member

@magicus magicus commented Dec 6, 2024

For various reasons, we have added some extra flags to the compiler command line when compiling C/C++ for static libraries. This is a blocker for the goal of compiling once, linking twice for static and dynamic library. Fortunately, these extra flags are not needed.

Note that -DSTATIC_BUILD=1 is still kept, but set in SetupNativeCompilation. Going forward, this flag should only be sent to the very small set of files that actually need to know if we're creating a static or dynamic library. (But that is a future follow-up.)

The flags I removed, with rationales for removing them:

  • (gcc/clang) ffunction-sections -fdata-sections: This forces the compiler to create a separate section for each and every function and data entry. The idea is that the linker can use this to get rid of dead code when creating the static library, and hence saving space. The idea is perhaps good, but it does not work. libjvm.so gets about 10% larger with these flags than without them, so they are not only useless, but actually harmful.
  • (gcc/clang) -DJNIEXPORT='__attribute__((visibility(\"default\")))': This is default now anyway so it does not contribute anything.
  • (microsoft)-DJNIEXPORT=: The static launcher still does not work fully on Windows. (It is an ongoing project to get it to work) However, removing this flag is an essential first step, since it otherwise removes the __declspec(dllexport) annotation, and we are hence renders us unable to lookup symbols in the static libraries. (I don't understand why this was introduced in the first place.)
  • (gcc) -Xassembler -mrelax-relocations=no: This was apparently added for compatibility with "older" linkers. Unfortunately, no version was given, and the original author of the code does not remember. I can build with no ill effects without this flag, so I assume that in the years that has passed, our toolchain version increments has made this unnecessary.

There is a small risk of breakage for some old/odd gcc toolchain out there. But I can see of no other realistic way of solving this than to remove the flag, and if it breaks somewhere, we can re-introduce the flag, but with a valid GCC version number attached to it.


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-8345683: Remove special flags for files compiled for static libraries (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22606

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 6, 2024

👋 Welcome back ihse! 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 Dec 6, 2024

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

8345683: Remove special flags for files compiled for static libraries

Reviewed-by: erikj

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

  • a21d21f: 8345609: [C1] LIR Operations with one input should be implemented as LIR_Op1
  • 2382a2d: 8345661: Simplify page size alignment in code heap reservation
  • 076bfa6: 8345656: Move os alignment functions out of ReservedSpace
  • 2826838: 8345658: WB_NMTCommitMemory redundantly records an NMT tag
  • c9ec271: 8345800: Update copyright year to 2024 for serviceability in files where it was missed
  • 8e0f929: 8345805: Update copyright year to 2024 for other files where it was missed
  • f88c1c6: 8345773: Class-File API debug printing capability
  • e88e793: 8343148: C2: Refactor uses of "PhaseValue::con() + PhaseIdealLoop::set_ctrl()" into separate method
  • 1e9204f: 8345273: Fix -Wzero-as-null-pointer-constant warnings in s390 code
  • c40140e: 8334581: Remove no-arg constructor BasicSliderUI()
  • ... and 54 more: https://git.openjdk.org/jdk/compare/daa2ba52a3197924c34ccdd0c33703e61cdc8350...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 added the rfr Pull request is ready for review label Dec 6, 2024
@openjdk
Copy link

openjdk bot commented Dec 6, 2024

@magicus 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 Dec 6, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 6, 2024

Webrevs

@erikj79
Copy link
Member

erikj79 commented Dec 6, 2024

  • (gcc) -Xassembler -mrelax-relocations=no

I managed to dig up the reason for this and have sent a question to the original stakeholders. Please hold off until we get confirmation.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 11, 2024
@magicus
Copy link
Member Author

magicus commented Dec 11, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Dec 11, 2024

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

  • 08bdeed: 8345269: Fix -Wzero-as-null-pointer-constant warnings in ppc code
  • e4a34e9: 8345616: Unnecessary Hashtable usage in javax.swing.text.html.parser.Element
  • cce5808: 8345421: (bf) Create specific test for temporary direct buffers and the buffer size limit
  • cf0e1aa: 8345335: Add excluded jdk_foreign tests to manual group
  • 2c4567a: 8342651: Refactor array constant to use an array of jbyte
  • 72c6daf: 8346007: Incorrect copyright header in UModLNodeIdealizationTests.java
  • cc47918: 8345040: Clean up unused variables and code in generate_native_wrapper
  • c34b87c: 8345659: Fix broken alignment after ReservedSpace splitting in GC code
  • e294899: 8345647: Fix recent NULL usage backsliding in Shenandoah
  • d381d58: 8332268: C2: Add missing optimizations for UDivI/L and UModI/L and unify the shared logic with the signed nodes
  • ... and 65 more: https://git.openjdk.org/jdk/compare/daa2ba52a3197924c34ccdd0c33703e61cdc8350...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 11, 2024

@magicus Pushed as commit cbab40b.

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

2 participants