Clang on Ubuntu 11.04 (natty) 32 bits

Some weeks ago a patch for supporting Ubuntu 11.04 x86_64 was
applied. However, for i686 clang can't figure out the library paths (the
-L paramaters appear as nonsense relative paths). I
looked at ToolChains.cpp and there it is assumed that on Linux there
exists a directory /usr/lib/gcc/<platform-triple>. On my install there
is no /usr/lib/gcc directory. Creating a /usr/lib/gcc symlink to
/usr/lib/i386-linux-gnu allows me to go further, but then this:

#include <errno.h>

ends with the error message:

/usr/include/linux/errno.h:4:10: fatal error: 'asm/errno.h' file not found

"asm/errno.h" is in the directory /usr/include/i386-linux-gnu. gcc has
that directory on its search list, but clang doesn't.

As a side note, I noticed that clang checks the existence of lots of
directories, including quite a few that doesn't make sense for the
current platform (like those having x86_64 on its name) and adds to the
include search list directories for more than one compiler. In my case
it adds 4.4 and 4.5 (this is an upgraded machine and the previos OS
version came with gcc 4.4, which still is installed). This doesn't look
right at all, considering that the 4.4 header directories are listed
before those corresponding to 4.5, but then clang uses the 4.5 libraries
for linking.

Any pointers on how to configure clang for matching gcc's directory
search list appreciated.

to avoid related problems on gentoo (i have an amd64 cross compiler installed on a i386
userland) i configure with these:

--with-cxx-include-root=/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4
--with-cxx-include-arch=i686-pc-linux-gnu
--with-binutils-include=/usr/lib/binutils/i686-pc-linux-gnu/2.21/include

and on an amd64 userland i use these:

--with-cxx-include-root=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/include/g++-v4
--with-cxx-include-arch=x86_64-pc-linux-gnu
--with-cxx-include-32bit-dir=32

I do a similar setup for openSUSE FWIW.

Regards,
ismail

Some time ago I attempted to build conceptsGcc on Ubuntu 10.4 (64 bit). I had done this before on various Fedora systems and this time it would not compile. I found out with a bit of digging that the problem is that Debian and Ubuntu use a different arrangement of library locations compared to Fedora, when handling both 64 bit and 32 bit libraries.

Fedora: 32 bit: lib 64 bit lib64
Ubuntu 32 bit: lib32 64 bit lib with lib64 provided as a link.

I made some changes in the conceptGcc to get it to compile.

See here for more details: http://c2.com/cgi/wiki?UbuntuLinux

I hope this helps.

John

P.S. I found the following comment about this:
The fact that Debian maintainers go out of their way to modify and Debianize many software packages sometimes does mean that occasionally patches are required to get upstream sources to work. This is a feature not a bug...

pageexec@freemail.hu writes:

Óscar Fuentes <ofv@wanadoo.es> writes:

pageexec@freemail.hu writes:

Any pointers on how to configure clang for matching gcc's directory
search list appreciated.

to avoid related problems on gentoo (i have an amd64 cross compiler
installed on a i386
userland) i configure with these:

--with-cxx-include-root=/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4
--with-cxx-include-arch=i686-pc-linux-gnu
--with-binutils-include=/usr/lib/binutils/i686-pc-linux-gnu/2.21/include

Thanks. Will try using those configuration options.

Compiling works after configuring the cmake build using the
C_INCLUDE_DIRS variable with the same directories listed by "g++ -v".

Building some toy programs works but while linking one of my projects:

oscar@acer:~/home/oscar/bin/clang++ -v -fPIC -O3 -DNDEBUG -shared -Wl,-soname,liblp0core.so -o liblp0core.so <object-files> -L/home/oscar/lib -lboost_thread-mt -lboost_date_time-mt -ldl -Wl,-rpath,/home/oscar/lib
clang version 3.0 ()
Target: i386-pc-linux-gnu
Thread model: posix

"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m
elf_i386 -shared -o liblp0core.so /usr/lib/../lib/crti.o
/usr/lib/gcc/i686-linux-gnu/4.5.2/crtbeginS.o -L/home/oscar/lib
-L/usr/lib/gcc/i686-linux-gnu/4.5.2
-L/usr/lib/gcc/i686-linux-gnu/4.5.2/../../../../lib -L/lib/../lib
-L/usr/lib/../lib
-L/usr/lib/gcc/i686-linux-gnu/4.5.2/../../.. -L/usr/lib/i686-linux-gnu
-soname liblp0core.so <object-files> -lboost_thread-mt -lboost_date_time-mt -ldl -rpath /home/oscar/lib -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/lib/gcc/i686-linux-gnu/4.5.2/crtendS.o /usr/lib/../lib/crtn.o
/usr/bin/ld: CMakeFiles/lp0core.dir/basicops.cpp.o: relocation R_386_GOTOFF against undefined symbol `cosf@@GLIBC_2.0' can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value
clang-3: error: linker command failed with exit code 1 (use -v to see invocation)

There is PR8713 about this same error message but related to
libstdc++. Is this a bug?