kalibera / rchk

102 stars 10 forks source link

error building on ubuntu 18.04 #11

Closed jjallaire closed 6 years ago

jjallaire commented 6 years ago

I get this error when following the build instructions on a fresh install of Ubuntu 18.04:

patterns.cpp: In function ‘bool isTypeSwitch(llvm::Value*, llvm::AllocaInst*&, llvm::BasicBlock*&, TypeSwitchInfoTy&)’:
patterns.cpp:380:26: error: base operand of ‘->’ has non-pointer type ‘llvm::SwitchInst::CaseIt’
     ConstantInt *val = ci->getCaseValue();
                          ^~
patterns.cpp:381:26: error: base operand of ‘->’ has non-pointer type ‘llvm::SwitchInst::CaseIt’
     BasicBlock *succ = ci->getCaseSuccessor();
                          ^~
<builtin>: recipe for target 'patterns.o' failed
make: *** [patterns.o] Error 1

Any idea what the source of this error might be?

jjallaire commented 6 years ago

The error occurs in code from the most recent commit: https://github.com/kalibera/rchk/commit/1ff04583d2a91f690a17d9cc6ef039853fc4cb95

jjallaire commented 6 years ago

If I revert that commit then it all builds fine.

kalibera commented 6 years ago

Strange - sadly I am travelling without access to 18.04. You can try the version with "." (manually override the ifdef). What is your llvm version ? (llvm-config --version)

kalibera commented 6 years ago

I got the guard wrong, the new API is from LLVM 5. Now should be working (but I still have to test on 18.04). Thanks for the report!

jjallaire commented 6 years ago

Yes, that works. Thanks!

jjallaire commented 6 years ago

I may have spoken a bit too soon. On Ubuntu 18.04 I now get these warnings for each source file:

WARNING:Did not recognize the compiler flag "-g3"
clang: warning: -Wl,--no-keep-files-mapped: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -Wl,--no-map-whole-files: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-fuse-ld=gold' [-Wunused-command-line-argument]
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
1 warning generated.
clang: warning: argument unused during compilation: '-fuse-ld=gold' [-Wunused-command-line-argument]
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
1 warning generated.

Then this error linking:

/home/jjallaire/.local/bin/wllvm++ -stdlib=libc++ -I/usr/lib/llvm-4.0/include -std=c++0x -fuse-ld=gold -Wl,--no-keep-files-mapped -Wl,--no-map-whole-files -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -O2 -DNDEBUG -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -g3 -MMD -DBCHECK_MAX_STATES=3000000 -DCALLOCATORS_MAX_STATES=1000000 -I/usr/include/llvm-3.8/ -I/usr/lib/llvm-4.0/include   -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/usr/lib/llvm-4.0/lib    errcheck.o state.o lannotate.o patterns.o cgclosure.o linemsg.o symbols.o guards.o liveness.o callocators.o common.o allocators.o exceptions.o balance.o cprotect.o freshvars.o vectors.o errors.o  -lLLVM-4.0  -o errcheck
WARNING:Did not recognize the compiler flag "-g3"
common.cpp:126: error: undefined reference to 'llvm::Linker::linkModules(llvm::Module&, std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> >, unsigned int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR:Failed to compile using given arguments: [-stdlib=libc++ -I/usr/lib/llvm-4.0/include -std=c++0x -fuse-ld=gold -Wl,--no-keep-files-mapped -Wl,--no-map-whole-files -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -O2 -DNDEBUG -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -g3 -MMD -DBCHECK_MAX_STATES=3000000 -DCALLOCATORS_MAX_STATES=1000000 -I/usr/include/llvm-3.8/ -I/usr/lib/llvm-4.0/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/usr/lib/llvm-4.0/lib errcheck.o state.o lannotate.o patterns.o cgclosure.o linemsg.o symbols.o guards.o liveness.o callocators.o common.o allocators.o exceptions.o balance.o cprotect.o freshvars.o vectors.o errors.o -lLLVM-4.0 -o errcheck]
<builtin>: recipe for target 'errcheck' failed
make: *** [errcheck] Error 1

Note that I got none of these errors with the revert of https://github.com/kalibera/rchk/commit/1ff04583d2a91f690a17d9cc6ef039853fc4cb95

This could be some some side effect of my building with different source trees? Apologize if this is noise but wanted you to see these errors just in case.

kalibera commented 6 years ago

The linking error seems to be that the LLVM library is not found. I've tried in docker/18.04 using the steps as in the README and it worked for me. If you are building specially it might be related - and perhaps sensitive to setting LLVM in config.inc (how exactly are you building?) The warnings are probably because i need to refresh my makefiles (and perhaps differentiate more between options for clang++ and g++).

jjallaire commented 6 years ago

Okay, I'm sure there are some wires crossed on my end as a result of building in different configs. I'll try again with a fresh start and I'm sure all will be well.