Building on x86-64

I made my first attempt to build on an x86_64-unknown-linux-gnu system.
Is this supposed to work? I get libtools errors (below). The problem seems
to be that it finds a 32-bit libltdl rather than the 64-bit libltdl.

  /home/dag> ls /usr/lib/libltdl.so.3.1.0
  /usr/lib/libltdl.so.3.1.0
  /home/dag> ls /usr/lib64/libltdl.so.3.1.0
  /usr/lib64/libltdl.so.3.1.0

Is this a known problem? I'm not very familiar with how libtools works so I'm
a bit hesitant to hack up ltmain.sh.

                                         -Dave

llvm[2]: Linking Debug+Checks executable tblgen
/tmp/ptmp/dag/build.llvm.modified.debug/mklib --tag=CXX --tag=disable-shared
--mode=link /tools/llvm-tools/x86_64-unknown-linux-gnu/bin/g++
-I/tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen
-I/users/dag/projects/llvm-project.modified/llvm/trunk/utils/TableGen
-I/tmp/ptmp/dag/build.llvm.modified.debug/include
-I/users/dag/projects/llvm-project.modified/llvm/trunk/include
-I/tmp/ptmp/dag/build.llvm.modified.debug/include
-I/users/dag/projects/llvm-project.modified/llvm/trunk/include -D_DEBUG
-D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -g
-Woverloaded-virtual -Wall -W -Wwrite-strings -Wunused -Wno-unused-parameter
-g -rpath /tmp/ptmp/dag/build.llvm.modified.debug/Debug+Checks/bin
-export-dynamic -L/tmp/ptmp/dag/build.llvm.modified.debug/Debug+Checks/lib
-L/tmp/ptmp/dag/build.llvm.modified.debug/Debug+Checks/lib
-o /tmp/ptmp/dag/build.llvm.modified.debug/Debug+Checks/bin/tblgen /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/AsmWriterEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/CallingConvEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/CodeEmitterGen.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/CodeGenTarget.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/DAGISelEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/FileLexer.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/FileParser.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/InstrInfoEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/IntrinsicEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/Record.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/RegisterInfoEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/SubtargetEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/TableGen.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/TableGenBackend.o
-lLLVMSupport -lLLVMSystem \
   -lltdl -lm -lelf
/tools/llvm-tools/x86_64-unknown-linux-gnu/bin/g++
-I/tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen
-I/users/dag/projects/llvm-project.modified/llvm/trunk/utils/TableGen
-I/tmp/ptmp/dag/build.llvm.modified.debug/include
-I/users/dag/projects/llvm-project.modified/llvm/trunk/include
-I/tmp/ptmp/dag/build.llvm.modified.debug/include
-I/users/dag/projects/llvm-project.modified/llvm/trunk/include -D_DEBUG
-D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -g -Woverloaded-virtual
-Wall -W -Wwrite-strings -Wunused -Wno-unused-parameter -g
-o /tmp/ptmp/dag/build.llvm.modified.debug/Debug+Checks/bin/tblgen /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/AsmWriterEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/CallingConvEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/CodeEmitterGen.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/CodeGenTarget.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/DAGISelEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/FileLexer.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/FileParser.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/InstrInfoEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/IntrinsicEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/Record.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/RegisterInfoEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/SubtargetEmitter.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/TableGen.o /tmp/ptmp/dag/build.llvm.modified.debug/utils/TableGen/Debug+Checks/TableGenBackend.o
-Wl,--export-dynamic
-L/tmp/ptmp/dag/build.llvm.modified.debug/Debug+Checks/lib -lLLVMSupport
-lLLVMSystem /usr/lib/libltdl.so -ldl -lm -lelf -Wl,--rpath
-Wl,/tmp/ptmp/dag/build.llvm.modified.debug/Debug+Checks/bin

On my gentoo/amd64 installation i could get llvm and llvm-gcc to compile.
llvm/tests are mostly passed
the test-suite fails with a glibc double free error.

you could try setting the CC="gcc -L/usr/lib64" or maybe even CC="gcc
-m64 -L/usr/lib64" environment variable and likewise for CXX before
configuring and make.

although i would guess that something is wrong with your install
because it should find the 64bit libs by default (that is if your on a
64bit system)

but i am not a linux expert so take everything i say with a grain
(boulder) of salt

gritz arnold

I suspect you are right. I just ran into a similar problem building another
package that uses libtool. The only "non-standard" flag I passed to
configure when building gcc was --disable-shared, but I don't see
how that would affect the search path for libraries. libtool does it's own
searching and I don't think it cares where gcc looks. But again, I know
very little about libtool, mostly just from looking at sh -x output.

Does anyone have any insight as to how libtool finds libraries? Why
can't it just pass -lltdl to the linker like the compile command told it to?

                                             -Dave

> although i would guess that something is wrong with your install
> because it should find the 64bit libs by default (that is if your on a
> 64bit system)

I suspect you are right.

Ha! We're both wrong! This is a bug in libtool 5.22, which llvm uses:

From the libtool 5.24 NEWS file:

* Search paths with GCC on multilib systems like x86_64 have been fixed.

We should upgrade our libtool. How does one go about doing this? Is it
simply a matter of copying ltmain.sh from the libtool distribution?

                                             -Dave

David Greene wrote:

No i have multilib configuration (whatever this means on gentoo :wink: and
there are 32bit libs. Libtool version installed is 1.5.22. Maybe its
patched/configured specially by gentoos build system.

ls -la /usr/
...
lib -> lib64
lib32
lib64
There is a libltdl.s.3.1.4 in lib32 and lib64.

But i have quite the opposite problem: getting 32bit versions of
llvm-gcc to build on the 64 bit machine. In order to achieve this i am
currently experimenting with a 32bit chroot.

gritz arnold

Ah, but /usr/lib links to /usr/lib64 so that saves you. Do a VERBOSE=1
build and see what mklib spits out when doing a link. I'll bet you see
/usr/lib/libltdl.a there.

I just tried to libtoolize to 1.5.24 but I'm still seeing the same problem. I
will continue to investigate.

                                            -Dave

Ugh. I hate libtool.

Here's what I've been able to glean so far. libtool uses the output of
gcc -print-search-dirs to populate its library search path. On our
x86_64-unknown-linux-gnu gcc, this output doesn't include /usr/lib64.
Figuring this was a configuration problem, I rebuilt the compiler. No
such luck. The new compiler has the same problem.

This is with gcc 4.1.2. gcc. gcc 4.2.1 works fine and correctly includes
/usr/lib64. I configured both compilers with the same options.

This appears to be a gcc 4.1.2 bug. Anyone else know anything about this?
Perhaps we should add 4.1.2 to the buggy compilers list with an explanation
that llvm can't be built on multilib machines with it unless /usr/lib links to
/usr/lib64.

                                             -Dave