Bug 1673833 - Build fails due to wrong handling of -Wformat flag
Summary: Build fails due to wrong handling of -Wformat flag
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: java-openjdk
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: jiri vanek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-08 09:19 UTC by Petra Alice Mikova
Modified: 2019-02-14 09:28 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-02-14 09:28:23 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
openjdk bug system JDK-8218814 0 None None None 2019-02-12 12:50:40 UTC

Description Petra Alice Mikova 2019-02-08 09:19:05 UTC
Description of problem:
Build of java-openjdk with newest sources (jdk12+30) is failing due -Wformat flag, that is being added as extra cflag in our spec file, but being removed by another make file jdk12/make/common/TestFilesCompilation.gmk during the build.

Line 100: DISABLED_WARNINGS_gcc := format undef unused-function unused-value 

This causes error during compilation of some test libraries (e.g. libTestJNIWeakG1.c), because the -Wformat flag is needed by -Werror=format-security flag.

Due to that, we are unable to build the JDK without omitting the -Werror=format-security flag.

When I patch the file, removing the "format" from the line, the build then passes.

Version-Release number of selected component (if applicable):
java-openjdk-12.0.0.30-0.ea.1.rolling

Actual results:
Compilation fails:
Compiling libTestJNIWeakG1.c (for libTestJNIWeakG1.so)
( /usr/bin/rm -f /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.o.log && /usr/bin/gcc -MMD -MF /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.d -I/builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/modules_include/java.base -I/builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/modules_include/java.base/linux -I/builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/src/java.base/share/native/libjava -I/builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/src/java.base/unix/native/libjava -I/builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/src/hotspot/share/include -I/builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/src/hotspot/os/posix/include -pipe -fstack-protector -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DLINUX -DNDEBUG -fno-strict-aliasing -Wall -Wextra -Wformat=2 -Wpointer-arith -Wsign-compare -Wunused-function -Wundef -Wunused-value -Wreturn-type -Wtrampolines -m64 -g -pipe -Wformat -Wno-cpp -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -std=gnu++98 -Wno-error -fno-delete-null-pointer-checks -fno-lifetime-dse -D_LITTLE_ENDIAN -DARCH='"amd64"' -Damd64 -D_LP64=1 -fno-omit-frame-pointer -fno-delete-null-pointer-checks -fno-lifetime-dse -fPIC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -Wno-unused-parameter -Wno-unused -Wno-format -Wno-undef -Wno-unused-function -Wno-unused-value -O2 -DTHIS_FILE='"libTestJNIWeakG1.c"' -c -o /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.o /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/test/hotspot/jtreg/gc/g1/TestJNIWeakG1/libTestJNIWeakG1.c > >(/usr/bin/tee -a /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.o.log) 2> >(/usr/bin/tee -a /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.o.log >&2) || ( exitcode=$? && /usr/bin/cp /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.o.log /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/make-support/failure-logs/support_test_hotspot_jtreg_native_support_libTestJNIWeakG1_libTestJNIWeakG1.o.log && /usr/bin/cp /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.o.cmdline /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/make-support/failure-logs/support_test_hotspot_jtreg_native_support_libTestJNIWeakG1_libTestJNIWeakG1.o.cmdline && exit $exitcode ) )
BUILDSTDERR: JtregNativeHotspot.gmk:1518: Building /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.o  (from /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/test/hotspot/jtreg/gc/g1/TestJNIWeakG1/libTestJNIWeakG1.c) (/builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/test/hotspot/jtreg/gc/g1/TestJNIWeakG1/libTestJNIWeakG1.c /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/hotspot/jtreg/native/support/libTestJNIWeakG1/libTestJNIWeakG1.comp.vardeps  newer)
+ /usr/bin/cp /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/jdk/jtreg/native/support/libstringPlatformChars/libstringPlatformChars.o.cmdline /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/make-support/failure-logs/support_test_jdk_jtreg_native_support_libstringPlatformChars_libstringPlatformChars.o.cmdline
Compiling libCriticalNative.c (for libCriticalNative.so)
+ exit 1
BUILDSTDERR: gmake[3]: *** [JtregNativeJdk.gmk:87: /builddir/build/BUILD/java-12-openjdk-12.0.0.30-0.ea.1.rolling.fc29.1.x86_64/openjdk/build/support/test/jdk/jtreg/native/support/libstringPlatformChars/libstringPlatformChars.o] Error 1
....
cc1: warning: command line option '-std=gnu++98' is valid for C++/ObjC++ but not for C
cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]
cc1: some warnings being treated as errors

Removal of -Werror=format-security helps, however, it is considered a security risk, since we might miss some important warnings when omitting the flag.

Expected results:
Build is successful, no compilation errors.

Additional info:

Comment 1 Severin Gehwolf 2019-02-11 13:43:55 UTC
Is this failure happening in rawhide only? So far I don't seem to be able to reproduce on F29.

Comment 2 Severin Gehwolf 2019-02-11 15:00:51 UTC
(In reply to Severin Gehwolf from comment #1)
> Is this failure happening in rawhide only? So far I don't seem to be able to
> reproduce on F29.

OK, reproduced on F29. Somewhat expected it fails for the "test-image" target when configured with extra cflags like so:

$ bash configure [...] --with-extra-cflags="-Wformat -Werror=format-security"  --with-extra-cxxflags="-Wformat -Werror=format-security" [...]
$ make [...] test-image

It makes we wonder why we build these targets: 'bootcycle-images all docs'. I'd think 'bootcycle-images docs' would be sufficient? Do we actually package anything test image related?

Doc for "all" target says:

 make all               # Create all images: product, test, docs
                        # (alias for all-images)

Comment 3 jiri vanek 2019-02-11 15:34:32 UTC
Nope. nothig test related is packed

Comment 4 Severin Gehwolf 2019-02-11 16:18:25 UTC
Here is an alternative (possible) solution to this problem. Don't build the test image:

https://src.fedoraproject.org/fork/jerboaa/rpms/java-openjdk/c/4b97f4ea5da579cd0c9d53f9fe7b4dbffc19a00a?branch=pr23-alt-fix

Currently building here:
https://koji.fedoraproject.org/koji/taskinfo?taskID=32742439

We'll see how that goes :)

Comment 5 jiri vanek 2019-02-11 17:08:10 UTC
It is hiding the issue :)

Comment 6 Severin Gehwolf 2019-02-11 17:34:01 UTC
(In reply to jiri vanek from comment #5)
> It is hiding the issue :)

Sure. I agree. Though, it's unclear whether it's common for somebody to compile test libs with '-Wformat -Werror=format-security'. JDK libs, yes. Test libs, not sure. It might be that it'll get dismissed upstream.

What I'm questioning here is whether it makes sense to compile the test image during the build as it's not being packaged anyway. That increases compile time for no good reason (test libs are then thrown away post-build).

Comment 7 Severin Gehwolf 2019-02-12 10:20:21 UTC
(In reply to Severin Gehwolf from comment #4)
> Currently building here:
> https://koji.fedoraproject.org/koji/taskinfo?taskID=32742439

That failed on i686 with an unrelated failure. Trying again here:
https://koji.fedoraproject.org/koji/taskinfo?taskID=32759135

Comment 8 Severin Gehwolf 2019-02-12 12:49:52 UTC
FWIW, I'd go with the work-around for the following reasons:

a) It reduces build time a bit (no longer compiles test libs needlessly)
b) Bug filed upstream as https://bugs.openjdk.java.net/browse/JDK-8218814 So issue has been reported.

Comment 9 Severin Gehwolf 2019-02-14 09:28:23 UTC
I'll close this bug as it has been worked around by not compiling the test image during build. See:
https://koji.fedoraproject.org/koji/buildinfo?buildID=1209090

Feel free to re-open if you feel otherwise.


Note You need to log in before you can comment on or make changes to this bug.