-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8286582: Build fails on macos aarch64 when using --with-zlib=bundled #8651
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
Conversation
👋 Welcome back jpai! A progress list of the required criteria for merging this PR into |
Webrevs
|
make/autoconf/lib-bundled.m4
Outdated
@@ -216,7 +221,7 @@ AC_DEFUN_ONCE([LIB_SETUP_ZLIB], | |||
LIBZ_CFLAGS="" | |||
LIBZ_LIBS="" | |||
if test "x$USE_EXTERNAL_LIBZ" = "xfalse"; then | |||
LIBZ_CFLAGS="$LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" | |||
LIBZ_CFLAGS="$LIBZ_CFLAGS $APPLE_LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declaring APPLE_LIBZ_CFLAGS far away (and only conditionally) and then using it once here just makes for hard-to-read code.
LIBZ_CFLAGS="$LIBZ_CFLAGS $APPLE_LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" | |
LIBZ_CFLAGS="$LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" | |
if test "x$OPENJDK_TARGET_OS" = xmacosx; then | |
LIBZ_CFLAGS="$LIBZ_CFLAGS -DHAVE_UNISTD_H" | |
fi |
... and remove the assignment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR to implement this suggestion
@@ -449,7 +449,14 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
(void)vsnprintf(next, state->size, format, va); | |||
len = strlen(next); | |||
# else | |||
len = vsnprintf(next, state->size, format, va); | |||
# ifdef __APPLE__ // ignore format-nonliteral warning on macOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of patching 3rd party code to fix a compilation warning, you should disable that warning instead.
In make/modules/java.base/lib/CoreLibraries.gmk
, add
DISABLED_WARNINGS_clang := format-nonliteral, \
as line 138.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for these useful inputs Magnus. I did these changes locally but for some reason this format-nonliteral is not getting picked up while building that library. I will investigate and see what's going on. Will update the PR once I figure it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Magnus and try to avoid changing the imported zlib code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did these changes locally but for some reason this format-nonliteral is not getting picked up while building that library.
Turns out that was slightly inaccurate. What was actually happening was that, that setting you suggested in that build file did indeed work and got picked up. But it ran into an error which looked like:
src/java.base/share/native/libzip/zlib/gzwrite.c:452:40: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
len = vsnprintf(next, state->size, format, va);
^~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/secure/_stdio.h:75:63: note: expanded from macro 'vsnprintf'
__builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
^~~~~~
1 error generated.
make[3]: *** [build/macosx-aarch64-server-release/support/native/java.desktop/libsplashscreen/gzwrite.o] Error 1
I hadn't paid close attention initially and upon seeing that error, I thought it was coming while building LIBZIP
. However, what's actually happening is, it appears that while building LIBSPLASHSCREEN
if bundled zlib is used then the build process recompiles the bundled zlib, so I had to include that setting even in the Awt2dLibraries.gmk
.
I have now updated this PR with the changes you suggested and this additional change. Local build now works fine both for bundled and system zlib. I will trigger more extensive tests once these changes look OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Magnus and try to avoid changing the imported zlib code.
We already had modified gzwrite.c in our port so I thought keeping the changes narrowed to apple made sense here.
…ib instead of source code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Jai,
thank you for continuing the work to allow us to build/use the bundled zlib on macOS
we should also update: open/src/java.base/share/native/libzip/zlib/ChangeLog to add a comment regarding why the build changes were required
@@ -217,6 +217,9 @@ AC_DEFUN_ONCE([LIB_SETUP_ZLIB], | |||
LIBZ_LIBS="" | |||
if test "x$USE_EXTERNAL_LIBZ" = "xfalse"; then | |||
LIBZ_CFLAGS="$LIBZ_CFLAGS -I$TOPDIR/src/java.base/share/native/libzip/zlib" | |||
if test "x$OPENJDK_TARGET_OS" = xmacosx; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here as to why we are doing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LanceAndersen Is that really needed? We normally don't comment on the reason why certain code needs certain defines. We tried to document some compiler flags in the beginning, but it turned out that most command lines ended up as essays, and this were not helpful. I think it's quite obvious what this code does: libz requires the define HAVE_UNISTD_H on macOS. I'm not even sure how you'd formulate a "why" -- "otherwise it does not work properly"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LanceAndersen Is that really needed? We normally don't comment on the reason why certain code needs certain defines. We tried to document some compiler flags in the beginning, but it turned out that most command lines ended up as essays, and this were not helpful. I think it's quite obvious what this code does: libz requires the define HAVE_UNISTD_H on macOS. I'm not even sure how you'd formulate a "why" -- "otherwise it does not work properly"?
The zlib configure script, which needs to be run prior running make to build the upstream repository, will determine if HAVE_UNISTD_H is needed and generate zconf.h replacing the macro with "1". My reason for adding a comment as this is a variant from how zlib is built upstream. Perhaps just updating open/src/java.base/share/native/libzip/zlib/ChangeLog is enough. I was just trying to document why we are doing this.
Another question would it make sense to set LIBZ_DISABLED_WARNINGS_CLANG in make/autoconf/lib-bundled.m4 so that the value in the case of zlib is set in one location? In addition, I can log a request to address this in the upstream project so we do not need to worry about this warning going forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not make sense to set the disabled warning in the configure script, no. The current code looks perfectly fine. Disabled warnings per module are set in the makefiles.
If you feel strongly that this needs to be documented more than in the JBS issue and this PR review, updating the zlib ChangeLog file is probably the way to go. I have no strong opinion on that. But from the build system PoV, the current code is fine as it is to be committed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not make sense to set the disabled warning in the configure script, no. The current code looks perfectly fine. Disabled warnings per module are set in the makefiles.
OK, that you for your feedback regarding the makefile changes vs. configure script.
If you feel strongly that this needs to be documented more than in the JBS issue and this PR review, updating the zlib ChangeLog file is probably the way to go. I have no strong opinion on that. But from the build system PoV, the current code is fine as it is to be committed.
OK, I am probably overthinking the need to document this
@@ -135,6 +135,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBZIP, \ | |||
$(LIBZ_CFLAGS), \ | |||
CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \ | |||
DISABLED_WARNINGS_gcc := unused-function implicit-fallthrough, \ | |||
DISABLED_WARNINGS_clang := format-nonliteral, \ | |||
LDFLAGS := $(LDFLAGS_JDKLIB) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment would be good here also as to the reasoning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And once again, we never comment on why we disable warnings. The context is clear enough -- there is a compiler warning that is not applicable to this module. Especially for 3rd party code, which is not nearly as stringent as we are about enabling warnings.
@@ -680,6 +680,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) | |||
|
|||
ifeq ($(USE_EXTERNAL_LIBZ), false) | |||
LIBSPLASHSCREEN_EXTRA_SRC += java.base:libzip/zlib | |||
LIBZ_DISABLED_WARNINGS_CLANG := format-nonliteral |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here for a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@jaikiran 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:
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 15 new commits pushed to the
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Jai for the latest tweaks to the our original patch.
I think we should be good to go
Thank you Lance and Magnus for the reviews and inputs. I've triggered various build and test runs with this state of the PR. Once those complete satisfactorily, I'll go ahead and integrate this. |
/integrate |
Going to push as commit 50d47de.
Your commit was automatically rebased without conflicts. |
Can I please get a review of this change which fixes build failures on macos when using
--with-zlib=bundled
?With this change the build now passes (tested both with bundled and system zlib variants).
tier1, tier2 and tier3 testing has been done and no related failures have been noticed.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8651/head:pull/8651
$ git checkout pull/8651
Update a local copy of the PR:
$ git checkout pull/8651
$ git pull https://git.openjdk.java.net/jdk pull/8651/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8651
View PR using the GUI difftool:
$ git pr show -t 8651
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8651.diff