morganstanley / hobbes

A language and an embedded JIT compiler
http://hobbes.readthedocs.io/
Apache License 2.0
1.16k stars 105 forks source link

build Hobbes with Clang on Linux #384

Closed smunix closed 3 years ago

smunix commented 3 years ago
[1/186] Building CXX object CMakeFiles/hobbes-test.dir/test/Convert.C.o
FAILED: CMakeFiles/hobbes-test.dir/test/Convert.C.o
/home/chaz/.local/local/clang+llvm/bin/clang++  -I/home/chaz/.local/local/clang+llvm/include -I../include -Werror=old-style-cast -Werror -Wall -Wextra -Winit-self -Wreturn-type -Wunused-variable -Wsign-compare
-Warray-bounds -Wunknown-pragmas -Wuninitialized -Wstrict-aliasing -Wunused-value -Wunused-label -Wswitch -Wcast-align -Wctor-dtor-privacy -Wmissing-noreturn -Wunused-parameter -Wreorder -O2   -D_GNU_SOURCE -D_
_STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DPYTHON_EXECUTABLE="/home/chaz/.local/bin/python" -DSCRIPT_DIR="/home/chaz/git/github.com_Morgan-Stanley_hobbes/scripts/" -std=gnu++14 -MD -MT
 CMakeFiles/hobbes-test.dir/test/Convert.C.o -MF CMakeFiles/hobbes-test.dir/test/Convert.C.o.d -o CMakeFiles/hobbes-test.dir/test/Convert.C.o -c ../test/Convert.C
In file included from ../test/Convert.C:20:
../include/hobbes/fregion.H:115:77: error: function 'raiseSysError' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
inline void raiseSysError(const std::string& msg, const std::string& fname) {
                                                                            ^
../include/hobbes/fregion.H:1685:27: error: unused parameter 'n' [-Werror,-Wunused-parameter]
    void ctor(const char* n, int id) {
                          ^
../include/hobbes/fregion.H:1685:34: error: unused parameter 'id' [-Werror,-Wunused-parameter]
    void ctor(const char* n, int id) {
                                 ^
../include/hobbes/fregion.H:1904:95: error: unused parameter 'wss' [-Werror,-Wunused-parameter]
    static void setWriteCBs(uint32_t, const std::function<void(uint32_t,uint64_t)>&, Wss& ... wss) { }
                                                                                              ^
4 errors generated.
[2/186] Building CXX object CMakeFiles/hobbes-test.dir/test/Definitions.C.o
FAILED: CMakeFiles/hobbes-test.dir/test/Definitions.C.o
/home/chaz/.local/local/clang+llvm/bin/clang++  -I/home/chaz/.local/local/clang+llvm/include -I../include -Werror=old-style-cast -Werror -Wall -Wextra -Winit-self -Wreturn-type -Wunused-variable -Wsign-compare
-Warray-bounds -Wunknown-pragmas -Wuninitialized -Wstrict-aliasing -Wunused-value -Wunused-label -Wswitch -Wcast-align -Wctor-dtor-privacy -Wmissing-noreturn -Wunused-parameter -Wreorder -O2   -D_GNU_SOURCE -D_
_STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DPYTHON_EXECUTABLE="/home/chaz/.local/bin/python" -DSCRIPT_DIR="/home/chaz/git/github.com_Morgan-Stanley_hobbes/scripts/" -std=gnu++14 -MD -MT
 CMakeFiles/hobbes-test.dir/test/Definitions.C.o -MF CMakeFiles/hobbes-test.dir/test/Definitions.C.o.d -o CMakeFiles/hobbes-test.dir/test/Definitions.C.o -c ../test/Definitions.C
In file included from ../test/Definitions.C:2:
In file included from ../include/hobbes/hobbes.H:6:
In file included from ../include/hobbes/eval/cc.H:7:
../include/hobbes/lang/tylift.H:429:37: error: unused parameter 'tenv' [-Werror,-Wunused-parameter]
    static MonoTypePtr type(typedb& tenv) { return Prim::make("unit"); }
                                    ^
In file included from ../test/Definitions.C:2:
In file included from ../include/hobbes/hobbes.H:6:
In file included from ../include/hobbes/eval/cc.H:13:
In file included from ../include/hobbes/eval/jitcc.H:9:
In file included from ../include/hobbes/util/llvm.H:18:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/DerivedTypes.h:23:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/Type.h:17:
/home/chaz/.local/local/clang+llvm/include/llvm/ADT/APFloat.h:842:31: error: function 'APFloat' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  APFloat() : U(IEEEdouble()) {
                              ^
In file included from ../test/Definitions.C:2:
In file included from ../include/hobbes/hobbes.H:6:
In file included from ../include/hobbes/eval/cc.H:13:
In file included from ../include/hobbes/eval/jitcc.H:9:
In file included from ../include/hobbes/util/llvm.H:19:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/IRBuilder.h:22:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/BasicBlock.h:22:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/Instruction.h:22:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/DebugLoc.h:17:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/TrackingMDRef.h:16:
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Metadata.h:95:49: error: function 'handleChangedOperand' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void handleChangedOperand(void *, Metadata *) {
                                                ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Metadata.h:888:42: error: function 'operator delete' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void operator delete(void *, unsigned) {
                                         ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Metadata.h:893:48: error: function 'operator delete' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void operator delete(void *, unsigned, bool) {
                                               ^
In file included from ../test/Definitions.C:2:
In file included from ../include/hobbes/hobbes.H:6:
In file included from ../include/hobbes/eval/cc.H:13:
In file included from ../include/hobbes/eval/jitcc.H:9:
In file included from ../include/hobbes/util/llvm.H:19:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/IRBuilder.h:33:
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Instructions.h:2941:50: error: function 'setSuccessor' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void setSuccessor(unsigned idx, BasicBlock *B) {
                                                 ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Instructions.h:4132:56: error: function 'setSuccessor' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
                                                       ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Instructions.h:4635:50: error: function 'setSuccessor' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void setSuccessor(unsigned idx, BasicBlock *B) {
                                                 ^
In file included from ../test/Definitions.C:2:
In file included from ../include/hobbes/hobbes.H:6:
../include/hobbes/eval/cc.H:329:26: error: unused parameter 'c' [-Werror,-Wunused-parameter]
    static T compile(cc* c, const str::seq& vns, const std::string& expr) {
                         ^
../include/hobbes/eval/cc.H:329:45: error: unused parameter 'vns' [-Werror,-Wunused-parameter]
    static T compile(cc* c, const str::seq& vns, const std::string& expr) {
                                            ^
../include/hobbes/eval/cc.H:329:69: error: unused parameter 'expr' [-Werror,-Wunused-parameter]
    static T compile(cc* c, const str::seq& vns, const std::string& expr) {
                                                                    ^
11 errors generated.
...

Originally posted by @Chaz6 in https://github.com/Morgan-Stanley/hobbes/issues/382#issuecomment-761621253

Chaz6 commented 3 years ago

Thanks for working on this. I have checked out the latest commit from master but it still fails to build for me:-

[1/184] Building CXX object CMakeFiles/hobbes-test.dir/test/Existentials.C.o
FAILED: CMakeFiles/hobbes-test.dir/test/Existentials.C.o
/home/chaz/.local/local/clang+llvm/bin/clang++  -I/home/chaz/.local/local/clang+llvm/include -I../include -Werror=old-style-cast -Werror -Wall -Wextra -Winit-self -Wreturn-type -Wunused-variable -Wsign-compare
-Warray-bounds -Wunknown-pragmas -Wuninitialized -Wstrict-aliasing -Wunused-value -Wunused-label -Wswitch -Wcast-align -Wctor-dtor-privacy -Wmissing-noreturn -Wunused-parameter -Wreorder -O2   -D_GNU_SOURCE -D_
_STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DPYTHON_EXECUTABLE="/home/chaz/.local/bin/python" -DSCRIPT_DIR="/home/chaz/git/github.com_Morgan-Stanley_hobbes/scripts/" -std=gnu++14 -MD -MT
 CMakeFiles/hobbes-test.dir/test/Existentials.C.o -MF CMakeFiles/hobbes-test.dir/test/Existentials.C.o.d -o CMakeFiles/hobbes-test.dir/test/Existentials.C.o -c ../test/Existentials.C
In file included from ../test/Existentials.C:2:
In file included from ../include/hobbes/hobbes.H:6:
In file included from ../include/hobbes/eval/cc.H:13:
In file included from ../include/hobbes/eval/jitcc.H:9:
In file included from ../include/hobbes/util/llvm.H:18:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/DerivedTypes.h:23:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/Type.h:17:
/home/chaz/.local/local/clang+llvm/include/llvm/ADT/APFloat.h:842:31: error: function 'APFloat' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  APFloat() : U(IEEEdouble()) {
                              ^
In file included from ../test/Existentials.C:2:
In file included from ../include/hobbes/hobbes.H:6:
In file included from ../include/hobbes/eval/cc.H:13:
In file included from ../include/hobbes/eval/jitcc.H:9:
In file included from ../include/hobbes/util/llvm.H:19:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/IRBuilder.h:22:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/BasicBlock.h:22:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/Instruction.h:22:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/DebugLoc.h:17:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/TrackingMDRef.h:16:
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Metadata.h:95:49: error: function 'handleChangedOperand' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void handleChangedOperand(void *, Metadata *) {
                                                ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Metadata.h:888:42: error: function 'operator delete' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void operator delete(void *, unsigned) {
                                         ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Metadata.h:893:48: error: function 'operator delete' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void operator delete(void *, unsigned, bool) {
                                               ^
In file included from ../test/Existentials.C:2:
In file included from ../include/hobbes/hobbes.H:6:
In file included from ../include/hobbes/eval/cc.H:13:
In file included from ../include/hobbes/eval/jitcc.H:9:
In file included from ../include/hobbes/util/llvm.H:19:
In file included from /home/chaz/.local/local/clang+llvm/include/llvm/IR/IRBuilder.h:33:
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Instructions.h:2941:50: error: function 'setSuccessor' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void setSuccessor(unsigned idx, BasicBlock *B) {
                                                 ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Instructions.h:4132:56: error: function 'setSuccessor' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
                                                       ^
/home/chaz/.local/local/clang+llvm/include/llvm/IR/Instructions.h:4635:50: error: function 'setSuccessor' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
  void setSuccessor(unsigned idx, BasicBlock *B) {
                                                 ^
7 errors generated.
Chaz6 commented 3 years ago

If I remove -Wmissing-noreturn then it does compile successfully. Does this need reporting upstream (to llvm)? It seems odd that this would happen.

Chaz6 commented 3 years ago

I spoke too soon! The linking failed with this output:-

libhobbes.a(jitcc.C.o):jitcc.C:typeinfo for hobbes::jitmm: error: undefined reference to 'typeinfo for llvm::SectionMemoryManager'
libhobbes.a(jitcc.C.o):jitcc.C:typeinfo for hobbes::LenWatch: error: undefined reference to 'typeinfo for llvm::JITEventListener'
smunix commented 3 years ago

Are you able to write a Github actions workflow describing the steps to reproduce your build failures? If not, maybe you want to share detailed steps to reproduce this?

What version of clang are you using? it is unusual to have llvm builds in one's $HOME as you do here.

Chaz6 commented 3 years ago

Sorry I do not know how to write a Github actions workflow. I am using LLVM 11.0.0 (I will upgrade to 11.0.1 later today) on a CentOS 7 64bit host (like RHEL). I keep all my build environment in $HOME so as not to interfere with the system.

smunix commented 3 years ago

try the following 2 commands from within your Hobbes directory (it won't mess up with the rest of your system, I promise):

$ curl -L https://nixos.org/nix/install | sh
$ nix-build -A hobbesPackages.clang-8.hobbes

Grab a beer and watch it build ... Your binaries will eventually be stored in $HOBBES/result/bin/...

Chaz6 commented 3 years ago

I have figured it out, LLVM needs to be built with LLVM_ENABLE_RTTI=ON and now I have been able to compile it from git with no problem.

Chaz6 commented 3 years ago

There is a test for this; the output of llvm-config --has-rtti should equal YES but in my case it was NO.