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

Building fails on macOS in zlib with error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] #18615

Closed
kgibm opened this issue Dec 13, 2023 · 6 comments

Comments

@kgibm
Copy link
Contributor

kgibm commented Dec 13, 2023

Building JDK17 on macOS ARM64 Sonoma 14.2 with XCode 15.0.1 fails with:

/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/compress.c:46:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/compress.c:92:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT compress(dest, destLen, source, sourceLen)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/compress.c:105:15: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
uLong ZEXPORT compressBound(sourceLen)
              ^
3 errors generated.
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:222:12: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
local void slide_hash(s)
           ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:249:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateInit_(strm, level, version, stream_size)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:261:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:413:11: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
local int deflateStateCheck(strm)
          ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:436:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:505:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:527:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateResetKeep(strm)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:565:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateReset(strm)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:577:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateSetHeader(strm, head)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:588:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflatePending(strm, pending, bits)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:602:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflatePrime(strm, bits, value)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:629:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateParams(strm, level, strategy)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:678:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:720:15: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
uLong ZEXPORT deflateBound(strm, sourceLen)
              ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:792:12: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
local void putShortMSB(s, b)
           ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:806:12: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
local void flush_pending(strm)
           ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:839:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflate(strm, flush)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:1154:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateEnd(strm)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:1180:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateCopy(dest, source)
            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[3]: *** [/Users/kevin/git/openj9/openj9-openjdk-jdk17/build/macosx-aarch64-server-release/support/native/java.base/libzip/compress.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/Users/kevin/git/openj9/openj9-openjdk-jdk17/build/macosx-aarch64-server-release/support/native/java.base/libzip/deflate.o] Error 1
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/gzclose.c:35:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT gzclose(file)
            ^
1 error generated.
make[3]: *** [/Users/kevin/git/openj9/openj9-openjdk-jdk17/build/macosx-aarch64-server-release/support/native/java.base/libzip/gzclose.o] Error 1
make[2]: *** [java.base-libs] Error 2
make[2]: *** Waiting for unfinished jobs....
Generating REFERENCE_API javadoc for 21 modules
Generating JAVASE_API javadoc for 21 modules
Generating JDK_API javadoc for 65 modules
Updating support/src.zip
Compiling 2736 files for java.desktop
Generating javadoc for openj9 source files
sed: 1: "/<section class="module ...": unexpected EOF (pending }'s)
sed: 1: "/<section class="servic ...": unexpected EOF (pending }'s)

ERROR: Build failed for target 'all' in configuration 'macosx-aarch64-server-release' (exit code 2) 
Stopping sjavac server

=== Output from failing command(s) repeated here ===
* For target support_native_java.base_libzip_compress.o:
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/compress.c:46:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/compress.c:92:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT compress(dest, destLen, source, sourceLen)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/compress.c:105:15: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
uLong ZEXPORT compressBound(sourceLen)
              ^
3 errors generated.
* For target support_native_java.base_libzip_deflate.o:
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:222:12: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
local void slide_hash(s)
           ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:249:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateInit_(strm, level, version, stream_size)
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:261:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
            ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:413:11: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
local int deflateStateCheck(strm)
          ^
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/deflate.c:436:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength)
            ^
   ... (rest of output omitted)
* For target support_native_java.base_libzip_gzclose.o:
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.base/share/native/libzip/zlib/gzclose.c:35:13: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
int ZEXPORT gzclose(file)
            ^
1 error generated.

* All command lines available in /Users/kevin/git/openj9/openj9-openjdk-jdk17/build/macosx-aarch64-server-release/make-support/failure-logs.
=== End of repeated output ===

No indication of failed target found.
Hint: Try searching the build log for '] Error'.
Hint: See doc/building.html#troubleshooting for assistance.

make[1]: *** [main] Error 2
make: *** [all] Error 2
@pshipton
Copy link
Member

It seems this should be reported to the zlib project so we can then pick up a fix from from there.
https://github.com/madler/zlib/issues

@kgibm
Copy link
Contributor Author

kgibm commented Dec 13, 2023

Looks like this was fixed upstream: madler/zlib#633

Looks like it was fixed in zlib 1.3: https://github.com/madler/zlib/blob/v1.3/ChangeLog#L5

Worked around with -Wno-deprecated-non-prototype:

bash configure --with-extra-cflags='-Wno-deprecated-non-prototype' --with-boot-jdk=...

Next issue due to __has_trivial_assign is deprecated:

In file included from /Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.desktop/share/native/libharfbuzz/hb.hh:527:
/Users/kevin/git/openj9/openj9-openjdk-jdk17/src/java.desktop/share/native/libharfbuzz/hb-algs.hh:1195:18: error: builtin __has_trivial_assign is deprecated; use __is_trivially_assignable instead [-Werror,-Wdeprecated-builtins]
  static_assert (hb_is_trivially_copy_assignable (T), "");

Adding -Wno-deprecated-builtins as follows did not resolve those errors (even with make clean):

bash configure --with-extra-cflags='-Wno-deprecated-non-prototype -Wno-deprecated-builtins' \
               --with-boot-jdk=...

However adding to CXXFLAGS as well resolved the errors:

bash configure --with-extra-cflags='-Wno-deprecated-non-prototype -Wno-deprecated-builtins' \
               --with-extra-cxxflags='-Wno-deprecated-non-prototype -Wno-deprecated-builtins' \
               --with-boot-jdk=...

@pshipton
Copy link
Member

We're already using zlib 1.3, are you building an older version?
#18137

@kgibm
Copy link
Contributor Author

kgibm commented Dec 13, 2023

I'm building with zlib 1.3 in openj9/runtime/include/zlib.h

However the error is in src/java.base/share/native/libzip

So that's a different zlib: src/java.base/share/native/libzip/zlib/zlib.h:

  version 1.2.13, October 13th, 2022

@pshipton
Copy link
Member

You'll have to take that one to OpenJDK.

@pshipton
Copy link
Member

I do notice that jdk22 is already using zlib 1.3, maybe it will get backported in a future OpenJDK release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants