Difficulties compiling: clang (not clang++) to precompile c++ headers; various compiler warnings (treated as errors)
Arthur Eubanks
aeubanks at google.com
Mon Jul 22 15:28:40 UTC 2019
I believe everybody has been passing --disable-warnings-as-errors, I added
that to the wiki page <https://wiki.openjdk.java.net/display/tsan/Main>.
I personally haven't been using --disable-precompiled-headers, so I'm not
sure why it's necessary for you. make shouldn't be invoking clang on cpp
files.
On Sun, Jul 21, 2019 at 4:07 AM Jiri Daněk <jdanek at redhat.com> wrote:
> I attempted compilation of jdk-tsan with both gcc9 and clang_8. With either
> compiler, I had to add additional options to configure, otherwise
> compilation would fail. I thought I'll mention it here.
>
> # Gcc 9
>
> I had to do
>
> bash configure --disable-warnings-as-errors
>
> otherwise I'd have errors like
>
> In file included from
> >
> /nix/store/bniand9afisrgrsfi7kr093334iv3ibv-glibc-2.27-dev/include/stdio.h:862,
> > from
> > /home/jdanek/repos/jdk-tsan/src/hotspot/share/adlc/adlc.hpp:35,
> > from
> > /home/jdanek/repos/jdk-tsan/src/hotspot/share/adlc/adlparse.cpp:27:
> > In function 'int fprintf(FILE*, const char*, ...)',
> > inlined from 'FormatRule* ADLParser::template_parse()' at
> > /home/jdanek/repos/jdk-tsan/src/hotspot/share/adlc/adlparse.cpp:4080:34:
> >
> /nix/store/bniand9afisrgrsfi7kr093334iv3ibv-glibc-2.27-dev/include/bits/stdio2.h:97:24:
> > error: '%s' directive argument is null [-Werror=format-overflow=]
> > 97 | return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
> > | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 98 | __va_arg_pack ());
> > | ~~~~~~~~~~~~~~~~~
> >
>
> # Clang 8
>
> I had to do
>
> bash configure --with-toolchain-type=clang --disable-precompiled-headers
> --disable-warnings-as-errors
>
> without --disable-precompiled-headers, make would try to compile headers
> with clang, instead of clang++, and my clang would not find c++ headers
>
> $ LOG=trace make
> > [...]
> >
> /nix/store/ki0cb2q9bib66zwjldfk6dkp9apkmgph-clang-wrapper-8.0.0/bin/clang
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
> -D_GNU_SOURCE -pipe -fno-rtti -fno-exceptions -fvisibility=hidden
> -fno-strict-aliasing -fno-omit-frame-pointer -flimit-debug-info
> -mno-omit-leaf-frame-pointer -mstack-alignment=16
> -DSUPPORTS_CLOCK_MONOTONIC -DLINUX -Wall -Wextra -Wformat=2 -Wpointer-arith
> -Wsign-compare -Wreorder -Wunused-function -Wundef -Wunused-value
> -Woverloaded-virtual -fPIC -DVM_LITTLE_ENDIAN -D_LP64=1 -m64 -DPRODUCT
> -DTARGET_ARCH_x86 -DINCLUDE_SUFFIX_OS=_linux -DINCLUDE_SUFFIX_CPU=_x86
> -DINCLUDE_SUFFIX_COMPILER=_gcc -DTARGET_COMPILER_gcc -DAMD64
> '-DHOTSPOT_LIB_ARCH="amd64"' -DCOMPILER1 -DCOMPILER2
> -DSUPPORT_BARRIER_ON_PRIMITIVES -DSUPPORT_NOT_TO_SPACE_INVARIANT
>
> -I/home/jdanek/repos/jdk-tsan/build/linux-x86_64-server-release/hotspot/variant-server/gensrc/adfiles
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/share
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/os/linux
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/os/posix
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/cpu/x86
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/os_cpu/linux_x86
>
> -I/home/jdanek/repos/jdk-tsan/build/linux-x86_64-server-release/hotspot/variant-server/gensrc
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/share/precompiled
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/share/include
> -I/home/jdanek/repos/jdk-tsan/src/hotspot/os/posix/include
>
> -I/home/jdanek/repos/jdk-tsan/build/linux-x86_64-server-release/support/modules_include/java.base
>
> -I/home/jdanek/repos/jdk-tsan/build/linux-x86_64-server-release/support/modules_include/java.base/linux
> -I/home/jdanek/repos/jdk-tsan/src/java.base/share/native/libjimage -m64 -g
> -Wno-unused-parameter -Wno-unused -Wno-tautological-compare
> -Wno-undefined-var-template -Wno-sometimes-uninitialized
> -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor -Wno-missing-braces
> -Wno-char-subscripts -Wno-ignored-qualifiers
> -Wno-missing-field-initializers -Wno-mismatched-tags -Werror -O3 -x
> c++-header -c -MMD -MF
>
> /home/jdanek/repos/jdk-tsan/build/linux-x86_64-server-release/hotspot/variant-server/libjvm/objs/precompiled/precompiled.hpp.pch.d
> /home/jdanek/repos/jdk-tsan/src/hotspot/share/precompiled/precompiled.hpp
> -o
>
> /home/jdanek/repos/jdk-tsan/build/linux-x86_64-server-release/hotspot/variant-server/libjvm/objs/precompiled/precompiled.hpp.pch
> In file included from
>
> /home/jdanek/repos/jdk-tsan/src/hotspot/share/precompiled/precompiled.hpp:34:
> In file included from
>
> /home/jdanek/repos/jdk-tsan/src/hotspot/share/classfile/classLoaderData.hpp:28:
> /home/jdanek/repos/jdk-tsan/src/hotspot/share/memory/allocation.hpp:32:10:
> fatal error: 'new' file not found
> #include <new>
> ^~~~~
> 1 error generated.
>
>
> when I rerun the command with clang++, it passed without error.
>
> Next, --disable-warnings-as-errors was needed because of warnings like this
>
> >
> >
> /home/jdanek/repos/jdk-tsan/test/hotspot/gtest/classfile/test_symbolTable.cpp:62:6:
> > error: explicitly assigning value of variable of type 'TempNewSymbol' to
> > itself [-Werror,-Wself-assign-overloaded]
> > s1 = s1; // self assignment
> > ~~ ^ ~~
> > 1 error generated.
> >
> >
> /home/jdanek/repos/jdk-tsan/src/java.smartcardio/share/native/libj2pcsc/pcsc.c:48:9:
> > warning: 'dprintf' macro redefined [-Wmacro-redefined]
> > #define dprintf(s)
> > ^
> >
> /nix/store/bniand9afisrgrsfi7kr093334iv3ibv-glibc-2.27-dev/include/bits/stdio2.h:145:12:
> > note: previous definition is here
> > # define dprintf(fd, ...) \
> > ^
> > Creating support/modules_cmds/jdk.aot/jaotc from 1 file(s)
> >
>
> and later I saw also this
>
> clang-8: warning: argument unused during compilation: '-D
> > _FORTIFY_SOURCE=2' [-Wunused-command-line-argument]
> > clang-8: warning: argument unused during compilation:
> > '-fstack-protector-strong' [-Wunused-command-line-argument]
> > clang-8: warning: argument unused during compilation: '--param
> > ssp-buffer-size=4' [-Wunused-command-line-argument]
> > clang-8: warning: argument unused during compilation:
> > '-fno-strict-overflow' [-Wunused-command-line-argument]
> > clang-8: warning: argument unused during compilation: '-idirafter
> > /nix/store/bniand9afisrgrsfi7kr093334iv3ibv-glibc-2.27-dev/include'
> > [-Wunused-command-line-argument]
> > clang-8: warning: argument unused during compilation: '-isystem
> > /nix/store/1s2f1fhb63kv01s0mbjrs7sps0lvc5qi-libc++-8.0.0/include'
> > [-Wunused-command-line-argument]
> >
>
> Thanks,
> --
> Mit freundlichen Grüßen / Kind regards
> Jiri Daněk
>
More information about the tsan-dev
mailing list