OPM / opm-common

Common components for OPM, in particular build system (cmake).
http://www.opm-project.org
GNU General Public License v3.0
30 stars 112 forks source link

compilation failure with clang 9.0.0 #1421

Open GitPaean opened 4 years ago

GitPaean commented 4 years ago

as suggested by some colleagues, it uses less memory to compile OPM with clang than gcc, which will probably help me to build the full flow fast on my machine. I gave it a try.

The only difference I did is to set to use clang and clang++ for mpicc and mpicxx, and everything else keeps the same as before.

I ran into the following error. Can someone point me to the correct direction? Thanks. It was on ubuntu 19.10.

 50 [  4%] Building CXX object CMakeFiles/genkw.dir/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp.o
 51 /usr/bin/mpicxx  -DHAVE_CONFIG_H=1 -DSILENCE_EXTERNAL_WARNINGS -I/home/kaib/OPM-master-test/debug/opm-common-build -I/home/kaib/OPM-master-test/debug/opm-common/external/cjson -I/home/kaib/OPM-master-test/debug/opm-common-build/include -I/home/kaib/OPM-master-test/debug/opm-common  -pipe -std=c++14 -pedantic -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wmissing-declarations -Wcast-qual -Wshadow -Wwrite-strings -Wchar-subscripts -Wredundant-decls -fopen    mp=libomp -pthread -O2 -g -DDEBUG   -std=c++14 -o CMakeFiles/genkw.dir/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp.o -c /home/kaib/OPM-master-test/debug/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp
 52 Stack dump:
 53 0.  Program arguments: /usr/lib/llvm-9/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name RawRecord.cpp -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /home/kaib/OPM-mas    ter-test/debug/opm-common-build/CMakeFiles/genkw.dir/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp.gcno -resource-dir /usr/lib/llvm-9/lib/clang/9.0.0 -D HAVE_CONFIG_H=1 -D SILENCE_EXTERNAL_WARNINGS -I /home/kaib/OPM-master-test/debug/opm-common-build -I /home/kaib/OPM-master-test/debug/opm-common/external/cjson -I /home/kaib/OPM-master-test/debug/opm-common-build/include -I /home/kaib/OPM-master-test/debug/opm-common -D DEBUG -I /usr/lib/x86_64-linux-gnu/openmpi/includ    e/openmpi -I /usr/lib/x86_64-linux-gnu/openmpi/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /usr/local/include -interna    l-isystem /usr/lib/llvm-9/lib/clang/9.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wmissing-declarations -Wcast-qual -Wshadow -Wwrite-strings -Wchar-subscripts -Wredundant-decls -pedantic -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/kaib/OPM-master-test/debug/opm-common-build -ferror-limit 19 -    fmessage-length 0 -fopenmp -pthread -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -faddrsig -o CMakeFiles/genkw.dir/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp.o -x c++ /home/kaib/OPM-master-test/debug/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp 
 54 1.  <eof> parser at end of file
 55 2.  Per-file LLVM IR generation
 56 3.  /home/kaib/OPM-master-test/debug/opm-common/src/opm/parser/eclipse/Parser/raw/RawConsts.hpp:67:28: Generating code for declaration 'Opm::RawConsts::is_separator::operator()'
 57  #0 0x00007faa44eee56f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xa4256f)
 58  #1 0x00007faa44eec980 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xa40980)
 59  #2 0x00007faa44eee971 (/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xa42971)
 60  #3 0x00007faa4aac3540 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x15540)
 61  #4 0x00007faa4502a462 llvm::PointerType::get(llvm::Type*, unsigned int) (/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xb7e462)
 62  #5 0x00007faa498713fa (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x11c63fa)
 63  #6 0x00007faa4987134c (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x11c634c)
 64  #7 0x00007faa498ef02a (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x124402a)
 65  #8 0x00007faa4997073c clang::CodeGen::CodeGenFunction::EmitCheckedInBoundsGEP(llvm::Value*, llvm::ArrayRef<llvm::Value*>, bool, bool, clang::SourceLocation, llvm::Twine const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x12c573c)
 66  #9 0x00007faa499413eb (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x12963eb)
 67 #10 0x00007faa49934435 clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(clang::ArraySubscriptExpr const*, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x1289435)
 68 #11 0x00007faa4992bab6 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x1280ab6)
 69 #12 0x00007faa49932eea clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x1287eea)
 70 #13 0x00007faa4997161a (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x12c661a)
 71 #14 0x00007faa4997b85b (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x12d085b)
 72 #15 0x00007faa49969f4f clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x12bef4f)
 73 #16 0x00007faa49a505ab clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13a55ab)
 74 #17 0x00007faa49a4dd57 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13a2d57)
 75 #18 0x00007faa49a56c7c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13abc7c)
 76 #19 0x00007faa49a91732 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13e6732)
 77 #20 0x00007faa49a91f5f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13e6f5f)
 78 #21 0x00007faa49aa9068 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13fe068)
 79 #22 0x00007faa49aa36bd clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13f86bd)
 80 #23 0x00007faa49a9a7d3 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13ef7d3)
 81 #24 0x00007faa49a9a768 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13ef768)
 82 #25 0x00007faa49a9a768 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13ef768)
 83 #26 0x00007faa49a9a768 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13ef768)
 84 #27 0x00007faa49a9a768 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13ef768)
 85 #28 0x00007faa49a9a768 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13ef768)
 86 #29 0x00007faa49a9a768 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13ef768)
 87 #30 0x00007faa49a99b07 clang::CodeGen::CodeGenModule::Release() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13eeb07)
 88 #31 0x00007faa49b14004 (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x1469004)
 89 #32 0x00007faa49a8a406 (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x13df406)
 90 #33 0x00007faa48df3d13 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x748d13)
 91 #34 0x00007faa4a059228 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x19ae228)
 92 #35 0x00007faa4a018de0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x196dde0)
 93 #36 0x00007faa4a0bbbf0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.9+0x1a10bf0)
 94 #37 0x000000000049941b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-9/bin/clang+0x49941b)
 95 #38 0x0000000000497741 main (/usr/lib/llvm-9/bin/clang+0x497741)
 96 #39 0x00007faa43f891e3 __libc_start_main /build/glibc-4WA41p/glibc-2.30/csu/../csu/libc-start.c:342:3
 97 #40 0x0000000000494bbe _start (/usr/lib/llvm-9/bin/clang+0x494bbe)
 98 clang: error: unable to execute command: Segmentation fault (core dumped)
 99 clang: error: clang frontend command failed due to signal (use -v to see invocation)
100 clang version 9.0.0-2 (tags/RELEASE_900/final)
101 Target: x86_64-pc-linux-gnu
102 Thread model: posix
103 InstalledDir: /usr/bin
104 clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
105 clang: note: diagnostic msg: 
106 ********************
107 
108 PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
109 Preprocessed source(s) and associated run script(s) are located at:
110 clang: note: diagnostic msg: /tmp/RawRecord-f06778.cpp
111 clang: note: diagnostic msg: /tmp/RawRecord-f06778.sh
112 clang: note: diagnostic msg: 
113 
114 ********************
115 make[2]: *** [CMakeFiles/genkw.dir/build.make:297: CMakeFiles/genkw.dir/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp.o] Error 254
116 make[2]: Leaving directory '/home/kaib/OPM-master-test/debug/opm-common-build'
117 make[1]: *** [CMakeFiles/Makefile2:3752: CMakeFiles/genkw.dir/all] Error 2
118 make[1]: Leaving directory '/home/kaib/OPM-master-test/debug/opm-common-build'
119 make: *** [Makefile:141: all] Error 2
blattms commented 4 years ago

The only difference I did is to set to use clang and clang++ for mpicc and mpicxx, and everything else keeps the same as before.

Not sure what you mean by this. Shouldn't it be sufficient to the right compilers to CMake via -DCMAKE_CXX_COMPILER=clang++ -D-DCMAKE_C_COMPILER=clang -DUSE_MPI=ON and let the build system doe its magic?

GitPaean commented 4 years ago

The command triggered the problem is as follows

/usr/bin/mpicxx  -DHAVE_CONFIG_H=1 -DSILENCE_EXTERNAL_WARNINGS -I/home/kaib/OPM-master-test/debug/opm-common-build -I/home/kaib/OPM-master-test/debug/opm-common/external/cjson -I/home/kaib/OPM-master-test/debug/opm-common-build/include -I/home/kaib/OPM-master-test/debug/opm-common  -pipe -std=c++14 -pedantic -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wmissing-declarations -Wcast-qual -Wshadow -Wwrite-strings -Wchar-subscripts -Wredundant-decls -fopenmp=libomp -pthread -O2 -g -DDEBUG   -std=c++14 -o CMakeFiles/genkw.dir/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp.o -c /home/kaib/OPM-master-test/debug/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp
GitPaean commented 4 years ago

Not sure what you mean by this. Shouldn't it be sufficient to the right compilers to CMake via -DCMAKE_CXX_COMPILER=clang++ -D-DCMAKE_C_COMPILER=clang -DUSE_MPI=ON and let the build system doe its magic?

What I did is to set OMPI_CC=clang and OMPI_CXX=clang++, which makes mpicc and mpicxx to use clang and calng++.

I guess it might be similar to your suggestion, while I will try to see whether it makes a difference.

blattms commented 4 years ago

Not sure what you mean by this. Shouldn't it be sufficient to the right compilers to CMake via -DCMAKE_CXX_COMPILER=clang++ -D-DCMAKE_C_COMPILER=clang -DUSE_MPI=ON and let the build system doe its magic?

What I did is to set OMPI_CC=clang and OMPI_CXX=clang++, which makes mpicc and mpicxx to use clang and calng++.

Please try my approach. There should be no need to fiddle around with MPI directly.

Even with your approach, there are some parts that will not be compiled with MPI support. As long as you do not either set the other compilers to clang or the MPI compilers, these might be compiled with gcc/g++. But maybe you did that already?

GitPaean commented 4 years ago

Please try my approach. There should be no need to fiddle around with MPI directly.

The result is the same. The compilation crashed due to the same reason with the same symptom.

Even with your approach, there are some parts that will not be compiled with MPI support. As long as you do not either set the other compilers to clang or the MPI compilers, these might be compiled with gcc/g++. But maybe you did that already?

Because USE_MPI=ON, it might be true while I have not seen that.

alfbr commented 4 years ago

as suggested by some colleagues, it uses less memory to compile OPM with clang than gcc, which will probably help me to build the full flow fast on my machine. I gave it a try.

Similar claims was made earlier, and we spent quite a bit of time figuring out that is was not true. In any case, consider asking for a hardware upgrade. Your time is valuable, RAM is cheap. There are a few places during compilation where the memory consumption goes up significantly, but I am not sure how much effort it makes sense to use bringing it down.

blattms commented 4 years ago

This does not look like anything solvable by a hardware upgrade. We should check CMakeCachte.txt whether the settings make sense and maybe try my suggested settings and another version of clang.

If that does not help it seems to be a compiler error and should be reported like suggested in the error message.

GitPaean commented 4 years ago

If that does not help it seems to be a compiler error and should be reported like suggested in the error message.

I will do that. Since OPM is open-source, we can send the full report which will include some code. But if someone manage to build OPM with clang 9.0, please let us know. When I got time, I might try to test other versions of clang, might not.

In anyway, it is not an urgent issue.

berndflemisch commented 4 years ago

I just wanted to confirm the issue with Clang 9 on Ubuntu 19.10. Things are fine with Clang 7 and 8.