make SHARED_LIBRARY=1 broken?

Hi,

Until recently I’ve been building LLVM with SHARED_LIBRARY=1. However, sith current svn, build now fails with unresolved symbols building opt. I’ve done a clean checkout, configure and make so it’s not down to any local changes I’ve made.

I’m building with:
./configure --enable-assertions
–enable-expensive-checks=no
–enable-pic
–enable-targets=host-only
–enable-shared
–enable-jit
make SHARED_LIBRARY=1

failure is:
llvm[2]: Linking Release executable opt (without symbols)
/home/src/llvm-trunk/llvm/tools/opt/Release/opt.o: In function T.1603': opt.cpp:(.text+0x510): undefined reference to llvm::createStripDeadPrototypesPass()’
opt.cpp:(.text+0x525): undefined reference to llvm::createDeadTypeEliminationPass()' opt.cpp:(.text+0x54a): undefined reference to llvm::createConstantMergePass()’
opt.cpp:(.text+0x57d): undefined reference to llvm::createGlobalOptimizerPass()' opt.cpp:(.text+0x5a7): undefined reference to llvm::createDeadArgEliminationPass()’
opt.cpp:(.text+0x5e6): undefined reference to llvm::createPruneEHPass()' opt.cpp:(.text+0x64d): undefined reference to llvm::createArgumentPromotionPass(unsigned int)’
opt.cpp:(.text+0x668): undefined reference to llvm::createFunctionAttrsPass()' opt.cpp:(.text+0x688): undefined reference to llvm::createGlobalDCEPass()’
/home/src/llvm-trunk/llvm/tools/opt/Release/opt.o: In function (anonymous namespace)::AddOptimizationPasses(llvm::PassManager&, llvm::FunctionPassManager&, unsigned int)': opt.cpp:(.text+0x6e7): undefined reference to llvm::createFunctionInliningPass(int)’
opt.cpp:(.text+0x781): undefined reference to llvm::createAlwaysInlinerPass()' /home/src/llvm-trunk/llvm/tools/opt/Release/opt.o: In function T.1601’:
opt.cpp:(.text+0x1f1f): undefined reference to llvm::createArgumentPromotionPass(unsigned int)' opt.cpp:(.text+0x1f24): undefined reference to llvm::createStructRetPromotionPass()’
… more failures …

Should I expect this configuration to work?

Thanks,
– James Williams

I suspect my change adding --enable-shared broke you, since that
configure option didn't exist before last week (r97119).
SHARED_LIBRARY is not one of the variables you're supposed to be able
to set on make's command line
(http://llvm.org/docs/MakefileGuide.html#variables). What are you
using it for? What happens if you remove it?

Hi,

Thanks for getting back to me.

I don’t actually need opt dynamically linked but I do want shared libraries. If run make without “SHARED_LIBRARY=1” I don’t appear to get any shared libraries built or installed.

Is LLVM built as shared libraries supported? If so what’s the correct build procedure?

– James

Configuring with --enable-shared should build a
Release/lib/libLLVM-2.7svn.so that includes all of the LLVM libraries
not included in another .so.

James Williams <junk@giantblob.com> writes:

I don't actually need opt dynamically linked but I do want shared
libraries.

The cmake build should work:

http://www.llvm.org/docs/CMake.html

BUILD_SHARED_LIBS:BOOL
  Flag indicating is shared libraries will be built. Its default value
  is OFF. Shared libraries are not supported on Windows and not
  recommended in the other OSes.

The "not recommended" part is, IIRC, due to the overhead that dynamic
libraries introduce on startup, which is very noticeable when you are
executing a short process lots of times (i.e. a test suite)

OK. Yes this works fine. I’ll switch to building this way and linking against this library instead. Thanks for your help.

– James

James Williams <junk@giantblob.com> writes:

I don’t actually need opt dynamically linked but I do want shared
libraries.

The cmake build should work:

http://www.llvm.org/docs/CMake.html

Thanks but I’ve got this working now with configure+make now.

BUILD_SHARED_LIBS:BOOL
Flag indicating is shared libraries will be built. Its default value
is OFF. Shared libraries are not supported on Windows and not
recommended in the other OSes.

The “not recommended” part is, IIRC, due to the overhead that dynamic
libraries introduce on startup, which is very noticeable when you are
executing a short process lots of times (i.e. a test suite)

The application I want to dynamically link is an FCGI so startup time is not really an issue for me.

– James