JDK-8174050 : Compilation errors with clang-4.0
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-02-07
  • Updated: 2019-05-22
  • Resolved: 2017-08-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8
10 b22Fixed 8u202Fixed
Related Reports
Relates :  
Relates :  
Description
Building and testing with recent clang's is a Product Excellence sort of thing.
Besides good warnings, it enables the ability to run things like ASAN over the jdk sources.

clang-4.0 fail to compile hotspot, giving:

Building target 'images' in configuration 'linux-x86_64-normal-server-release'
/home/martin/ws/jdk9-clang/hotspot/src/share/vm/memory/virtualspace.cpp:584:14: error: ordered comparison between pointer and zero ('char *' and 'int')
  if (base() > 0) {
      ~~~~~~ ^ ~
1 error generated.
make[3]: *** [/home/martin/ws/jdk9-clang/build/linux-x86_64-normal-server-release/hotspot/variant-server/libjvm/objs/virtualspace.o] Error 1
/home/martin/ws/jdk9-clang/hotspot/src/share/vm/opto/lcm.cpp:42:35: error: ordered comparison between pointer and zero ('address' (aka 'unsigned char *') and 'int')
  if (Universe::narrow_oop_base() > 0) { // Implies UseCompressedOops.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
1 error generated.
make[3]: *** [/home/martin/ws/jdk9-clang/build/linux-x86_64-normal-server-release/hotspot/variant-server/libjvm/objs/lcm.o] Error 1
make[3]: Target `default' not remade because of errors.
make[2]: *** [hotspot-server-libs] Error 1
make[2]: Target `images' not remade because of errors.

ERROR: Build failed for target 'images' in configuration 'linux-x86_64-normal-server-release' (exit code 2) 

=== Output from failing command(s) repeated here ===
* For target hotspot_variant-server_libjvm_objs_lcm.o:
/home/martin/ws/jdk9-clang/hotspot/src/share/vm/opto/lcm.cpp:42:35: error: ordered comparison between pointer and zero ('address' (aka 'unsigned char *') and 'int')
  if (Universe::narrow_oop_base() > 0) { // Implies UseCompressedOops.
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
1 error generated.
* For target hotspot_variant-server_libjvm_objs_virtualspace.o:
/home/martin/ws/jdk9-clang/hotspot/src/share/vm/memory/virtualspace.cpp:584:14: error: ordered comparison between pointer and zero ('char *' and 'int')
  if (base() > 0) {
      ~~~~~~ ^ ~
1 error generated.


Comments
URL: http://hg.openjdk.java.net/jdk10/jdk10/hotspot/rev/316854ef2fa2 User: jwilhelm Date: 2017-08-28 22:58:14 +0000
28-08-2017

URL: http://hg.openjdk.java.net/jdk10/hs/hotspot/rev/316854ef2fa2 User: kvn Date: 2017-08-25 06:04:31 +0000
25-08-2017

I expected my posted patches here to be equivalent to a plea for hotspot push help ... But here's a webrev: http://cr.openjdk.java.net/~martin/webrevs/openjdk10/pointer-sign-comparison/
23-08-2017

Martin: if you intend to fix this in 10 then it can be changed back to 10 (as it has). Simply prepare webrev and RFR on hotspot-dev, and get a sponsor (needed for hotspot pushes). Thanks.
23-08-2017

It seems wrong to defer build errors to a future release when actual working patch exists. What should I do to at least get the minimal fixes here into jdk10?
22-08-2017

If I additionally build fastdebug, I get * For target hotspot_variant-server_libjvm_objs_loopPredicate.o: /home/martin/ws/jdk9-clang/hotspot/src/share/vm/opto/loopPredicate.cpp:809:73: error: ordered comparison between pointer and zero ('const TypeInt *' and 'int') assert(rng->Opcode() == Op_LoadRange || _igvn.type(rng)->is_int() >= 0, "must be"); ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~ Now is_int() very misleadingly returns a pointer, not a bool (although elsewhere in hotspot is_int() does return a bool), and here the pointer comparison is non-sensically >= 0. Apart from being undefined, one could naively expect every pointer to satisfy that condition, and so this assertion is tautologically true, "must be" as the code says! I have no idea how to properly fix it, since the author's intent iis not clear.
07-02-2017

One case in runtime code and two in compiler code, but I moved this to runtime from build.
07-02-2017

Here's how I configure my build for clang-4.0 bash ./configure --with-toolchain-type=clang --with-toolchain-path=/usr/lib/llvm-4.0/bin --disable-warnings-as-errors --with-extra-ldflags=-z execstack --disable-precompiled-headers --with-cacerts-file=/etc/ssl/certs/java/cacerts --enable-unlimited-crypto --disable-hotspot-gtest --with-native-debug-symbols=none --with-default-make-target=jdk-image --with-boot-jdk=/home/martin/jdk/jdk8
07-02-2017

Here's an obvious fix for these particular compile errors (but there is much more work to be done). Would a hotspot engineer like to adopt them? diff --git a/src/share/vm/memory/virtualspace.cpp b/src/share/vm/memory/virtualspace.cpp --- a/src/share/vm/memory/virtualspace.cpp +++ b/src/share/vm/memory/virtualspace.cpp @@ -581,7 +581,7 @@ assert(markOopDesc::encode_pointer_as_mark(&_base[size])->decode_pointer() == &_base[size], "area must be distinguishable from marks for mark-sweep"); - if (base() > 0) { + if (base() != 0) { MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap); } } diff --git a/src/share/vm/opto/lcm.cpp b/src/share/vm/opto/lcm.cpp --- a/src/share/vm/opto/lcm.cpp +++ b/src/share/vm/opto/lcm.cpp @@ -39,7 +39,7 @@ // Check whether val is not-null-decoded compressed oop, // i.e. will grab into the base of the heap if it represents NULL. static bool accesses_heap_base_zone(Node *val) { - if (Universe::narrow_oop_base() > 0) { // Implies UseCompressedOops. + if (Universe::narrow_oop_base() != 0) { // Implies UseCompressedOops. if (val && val->is_Mach()) { if (val->as_Mach()->ideal_Opcode() == Op_DecodeN) { // This assumes all Decodes with TypePtr::NotNull are matched to nodes that
07-02-2017