Error building llvm on AIX 7.1

Hi All,

I am trying to build llvm on AIX. I installed all the required packages including gcc, g++, etc
./configure also went fine. but i tried to run gmake, i got the following error:

llvm[1]: Compiling MemoryBuffer.cpp for Release+Asserts build
llvm[1]: Compiling MemoryObject.cpp for Release+Asserts build
llvm[1]: Compiling Mutex.cpp for Release+Asserts build
llvm[1]: Compiling Path.cpp for Release+Asserts build
In file included from Path.cpp:289:0:
Unix/Path.inc: In static member function ‘static llvm::sys::Path llvm::sys::Path::GetMainExecutable(const char*, void*)’:
Unix/Path.inc:345:3: error: ‘Dl_info’ was not declared in this scope
Unix/Path.inc:345:11: error: expected ‘;’ before ‘DLInfo’
Unix/Path.inc:346:31: error: ‘DLInfo’ was not declared in this scope
Unix/Path.inc:346:37: error: ‘dladdr’ was not declared in this scope
Unix/Path.inc: In static member function ‘static void llvm::sys::Path::UnMapFilePages(const char*, size_t)’:
Unix/Path.inc:887:19: warning: cast from type ‘const char*’ to type ‘void*’ casts away qualifiers [-Wcast-qual]
rm: /usr/llvm/llvm-3.1.src/lib/Support/Release+Asserts/Path.d.tmp: A file or directory in the path name does not exist.
gmake[1]: *** [/usr/llvm/llvm-3.1.src/lib/Support/Release+Asserts/Path.o] Error 1
gmake[1]: Leaving directory `/usr/llvm/llvm-3.1.src/lib/Support’
gmake: *** [all] Error 1

Any pointers ?

I was able to process further by making some code changes and replacing export-dynamic with -bexpfull in Makefile.config. Now, i am getting following error while linking …

llvm[3]: Linking Release+Asserts Loadable Module LLVMHello.so
ld: 0706-027 The -R $ORIGIN flag is ignored.
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::getPassName() const
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::print(llvm::raw_ostream&, llvm::Module const*) const
ld: 0711-317 ERROR: Undefined symbol: llvm::FunctionPass::createPrinterPass(llvm::raw_ostream&, std::basic_string<char, std::char_traits, std::allocator > const&) const
ld: 0711-317 ERROR: Undefined symbol: llvm::FunctionPass::assignPassManager(llvm::PMStack&, llvm::PassManagerType)
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::preparePassManager(llvm::PMStack&)
ld: 0711-317 ERROR: Undefined symbol: llvm::FunctionPass::getPotentialPassManagerType() const
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::getAnalysisUsage(llvm::AnalysisUsage&) const
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::releaseMemory()
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::getAdjustedAnalysisPointer(void const*)
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::getAsImmutablePass()
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::getAsPMDataManager()
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::verifyAnalysis() const
ld: 0711-317 ERROR: Undefined symbol: llvm::Pass::dumpPassStructure(unsigned int)
ld: 0711-317 ERROR: Undefined symbol: llvm::FunctionPass::doInitialization(llvm::Module&)
ld: 0711-317 ERROR: Undefined symbol: llvm::FunctionPass::doFinalization(llvm::Module&)
ld: 0711-317 ERROR: Undefined symbol: vtable for llvm::FunctionPass
ld: 0711-317 ERROR: Undefined symbol: .llvm::Pass::~Pass()
ld: 0711-317 ERROR: Undefined symbol: .llvm::sys::AtomicIncrement(unsigned int volatile*)
ld: 0711-317 ERROR: Undefined symbol: .llvm::sys::MemoryFence()
ld: 0711-317 ERROR: Undefined symbol: .llvm::Statistic::RegisterStatistic()
ld: 0711-317 ERROR: Undefined symbol: .AnnotateHappensAfter
ld: 0711-317 ERROR: Undefined symbol: .llvm::errs()
ld: 0711-317 ERROR: Undefined symbol: .llvm::Value::getName() const
ld: 0711-317 ERROR: Undefined symbol: .llvm::raw_ostream::write_escaped(llvm::StringRef, bool)
ld: 0711-317 ERROR: Undefined symbol: .llvm::raw_ostream::write(char const*, unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .llvm::raw_ostream::write(unsigned char)
ld: 0711-317 ERROR: Undefined symbol: .llvm::PassRegistry::getPassRegistry()
ld: 0711-317 ERROR: Undefined symbol: .llvm::PassRegistry::registerPass(llvm::PassInfo const&, bool)
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
gmake[3]: *** [/usr/llvm/llvm-3.1.src/Release+Asserts/lib/LLVMHello.so] Error 1
gmake[3]: Leaving directory /usr/llvm/llvm-3.1.src/lib/Transforms/Hello' gmake[2]: *** [Hello/.makeall] Error 2 gmake[2]: Leaving directory /usr/llvm/llvm-3.1.src/lib/Transforms’
gmake[1]: *** [Transforms/.makeall] Error 2
gmake[1]: Leaving directory `/usr/llvm/llvm-3.1.src/lib’
gmake: *** [all] Error 1

Thanks

What exactly was the linking command?

-Krzysztof

AIX 7.1 & Power5

I have downloaded the llvm source and ran the following steps:
1. ./configure --enable-targets=powerpc
2. gmake

Apart from it, i had to make a few changes.

i. dladdr code has been commented for the time being and using the default
constructor code for that method
ii. In Makefile.config, 2 changes were done.

  +153 # Linker flags.
  +154 LDFLAGS+=-Wl,-G,-bexpfull

  +211 # What to pass as -rdynamic flag to g++
  +212 #RDYNAMIC := -Wl,-export-dynamic
  +213 RDYNAMIC := -Wl,-brtl

It helped me to proceed lot further with the compilation but i am stuck at
assembler error while compiling
/usr/llvm/llvm-3.1.src/lib/Target/PowerPC/PPCJITInfo.cpp file. It throws the
following error.

# pwd
/usr/llvm/llvm-3.1.src/lib/Target/PowerPC
# gmake
llvm[0]: Compiling PPCJITInfo.cpp for Release+Asserts build
Assembler:
/tmp//ccKtnq1J.s: line 5: 1252-016 The specified opcode or pseudo-op is not
valid.
        Use supported instructions or pseudo-ops only.
gmake: ***
[/usr/llvm/llvm-3.1.src/lib/Target/PowerPC/Release+Asserts/PPCJITInfo.o]
Error 1

I googled and found that there was a bug raised with similar issue.
http://llvm.org/bugs/show_bug.cgi?id=2210

I applied the code changes mentioned in the bug and it worked. Now, i am
stuck at the following error. Working overit ..
llvm[2]: Compiling SmallVectorTest.cpp for Release+Asserts build
llvm[2]: Compiling SparseBitVectorTest.cpp for Release+Asserts build
llvm[2]: Compiling SparseSetTest.cpp for Release+Asserts build
llvm[2]: Compiling StringMapTest.cpp for Release+Asserts build
llvm[2]: Compiling StringRefTest.cpp for Release+Asserts build
llvm[2]: Compiling TripleTest.cpp for Release+Asserts build
llvm[2]: Compiling TwineTest.cpp for Release+Asserts build
llvm[2]: Compiling VariadicFunctionTest.cpp for Release+Asserts build
llvm[2]: Compiling ilistTest.cpp for Release+Asserts build
gmake[2]: *** No rule to make target
`/usr/llvm/llvm-3.1.src/unittests/lib/libLLVMSupport.a', needed by
`Release+Asserts/ADTTests'. Stop.
gmake[2]: Leaving directory `/usr/llvm/llvm-3.1.src/unittests/ADT'
gmake[1]: *** [ADT/.makeall] Error 2
gmake[1]: Leaving directory `/usr/llvm/llvm-3.1.src/unittests'
gmake: *** [all] Error 1
# cd /usr/llvm/llvm-3.1.src/unittests/ADT
# gmake
gmake: *** No rule to make target
`/usr/llvm/llvm-3.1.src/unittests/lib/libLLVMSupport.a', needed by
`Release+Asserts/ADTTests'. Stop.

Any idea how to fix this makefile issue .. i am stuck here .. It seems i am
missing some config paramter here .. If i copy the library to the
respective location, the compilation proceeds further .. but there are
multiple libraries which needs to be copied ..

Please advise.

gmake[2]: Nothing to be done for `all'.
gmake[2]: Leaving directory `/usr/llvm/llvm-3.1.src/tools/llvm-config'
gmake[2]: Entering directory `/usr/llvm/llvm-3.1.src/tools/opt'
gmake[2]: *** No rule to make target
`/usr/llvm/llvm-3.1.src/tools/lib/libLLVMipo.a', needed by
`/usr/llvm/llvm-3.1.src/Release+Asserts/bin/opt'. Stop.
gmake[2]: Leaving directory `/usr/llvm/llvm-3.1.src/tools/opt'
gmake[1]: *** [opt/.makeall] Error 2
gmake[1]: Leaving directory `/usr/llvm/llvm-3.1.src/tools'
gmake: *** [all] Error 1

Seems like you're building it in the source tree. Try building it from a separate directory.

-Krzysztof

Pardon my ignorance but i didn't understand what it means by building it from
separate directory ..

# pwd
/usr/llvm/llvm-3.1.src ===> entire source code is extracted here ..
#gmake

...
gmake[2]: Entering directory `/usr/llvm/llvm-3.1.src/tools/llvm-config'
gmake[2]: Nothing to be done for `all'.
gmake[2]: Leaving directory `/usr/llvm/llvm-3.1.src/tools/llvm-config'
gmake[2]: Entering directory `/usr/llvm/llvm-3.1.src/tools/opt'
gmake[2]: *** No rule to make target
`/usr/llvm/llvm-3.1.src/tools/lib/libLLVMipo.a', needed by
`/usr/llvm/llvm-3.1.src/Release+Asserts/bin/opt'. Stop.
gmake[2]: Leaving directory `/usr/llvm/llvm-3.1.src/tools/opt'
gmake[1]: *** [opt/.makeall] Error 2
gmake[1]: Leaving directory `/usr/llvm/llvm-3.1.src/tools'
gmake: *** [all] Error 1

# cd /usr/llvm/llvm-3.1.src/tools/opt <<<moving to opt directory >>>
# gmake
gmake: *** No rule to make target
`/usr/llvm/llvm-3.1.src/tools/lib/libLLVMipo.a', needed by
`/usr/llvm/llvm-3.1.src/Release+Asserts/bin/opt'. Stop.

I meant this:

$ mkdir /path/to/build-dir
$ cd /path/to/build-dir
$ /path/to/sources/configure -foo -bar -blah -etc
$ make all
$ make install

In other words, make the build process put output files somewhere outside of the source tree.

-Krzysztof