Building pass out of source with cmake: undefined symbol error

Hmmm, I just thought of something. Perhaps I need to set the MODULE cmake flag (via -DMODULE=ON)? I will try this today. (I remembered the LOADABLE_MODULE=1 flag in the makefile, and the if ( MODULE ) check in the AddLLVM cmake module.)

Still no go. I’m going to experiment building out of source manually with the cmake build and autotools build. I should’ve mentioned that I’m attempting this with the hello world pass example.

Ah! Think I figured it out – it’s rtti. When I build with -fno-rtti, the spurious symbol disappears. Blargh, that was complicated. I’m going to try an out-of-source cmake build now. So far this has been a soliloquy, hope it helps someone else.

Hurray! It works now. For anyone curious, I am using LLVM 3.2 (svn, tags/release 3.2). If this is a bug, it may have been fixed since then.

The infrastructure is there in the llvm cmake modules, but the command that adds the “-fno-rtti” flag is skipped over. In LLVMProcessSources.cmake,

llvm_replace_compiler_option(CMAKE_CXX_FLAGS “-frtti” “-fno-rtti”)
elseif( MSVC )
llvm_replace_compiler_option(CMAKE_CXX_FLAGS “/GR” “/GR-”)

is skipped because my config has LLVM_COMPILER_IS_GCC_COMPATIBLE unset when I try to build out of source. However, I confirmed that this -is- set when I run a fresh cmake configuration. (I confirmed that I’m not accidentally using the original cmake modules in the src directory.)

Also, in case anyone has a similar problem as mine (I noticed a few online), I found it helpful to build llvm with autotools, and then build the pass with VERBOSE=1 so I could see the compiler flags, and try a manual build until it worked.