Compilation problems on Slackware 14.2 32-bit

Could anyone let me know, how can I finish compilation (well, linking
actually)? It all was quite cumbersome, simplistic "configure.py" script
neither is able to find within system the files needed for compilation,
nor allows parameters which could suggest their locations - it's barely of
any use, I had to modify "Makefile" by hand afterwards - but when finally
I almost did it, I met a problem very difficult to solve: it stopped whole
process near (I believe) finish, complaining:

#v+
LINK utils/prepare-builtins
/usr/bin/ld: cannot find -lgcc
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
#v-

What do I do to complete it? Of course I have entire GCC package installed,
in Slackware there is no separation into "compiler" itself and "development"
package:

#v+
gcc -v

Reading specs from /usr/lib/gcc/i586-slackware-linux/5.3.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i586-slackware-linux/5.3.0/lto-wrapper
Target: i586-slackware-linux
Configured with: ../gcc-5.3.0/configure --prefix=/usr --libdir=/usr/lib --mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,go,java,lto,objc --enable-threads=posix --enable-checking=release --enable-objc-gc --with-system-zlib --with-python-dir=/lib/python2.7/site-packages --enable-libstdcxx-dual-abi --with-default-libstdcxx-abi=gcc4-compatible --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --enable-lto --disable-install-libiberty --with-gnu-ld --verbose --enable-java-home --with-java-home=/usr/lib/jvm/jre --with-jvm-root-dir=/usr/lib/jvm --with-jvm-jar-dir=/usr/lib/jvm/jvm-exports --with-arch-directory=i386 --with-antlr-jar=/root/slackware-current/source/d/gcc/antlr-runtime-3.4.jar --enable-java-awt=gtk --disable-gtktest --with-arch=i586 --target=i586-slackware-linux --build=i586-slackware-linux --host=i586-slackware-linux
Thread model: posix
gcc version 5.3.0 (GCC)
#v-

Since I have everything installed, this time I have no idea what it's
complaining about. I believe it's another fault of "configure.py", which
was unable to locate some file/directory, and in effect to generate Makefile
properly. How could I fix it and finish package preparation at last? Here's
relevant part of Makefile:

#v+
all::

ifndef VERBOSE
  Verb = @
endif

utils/prepare-builtins.o: ./utils/prepare-builtins.cpp
  @echo CXX utils/prepare-builtins.o
  $(Verb) /usr/bin/clang++ -MMD -MF utils/prepare-builtins.o.d -I/usr/include -O2 -march=i586 -mtune=i686 -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -DLLVM_BUILD_GLOBAL_ISEL -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-exceptions -fno-rtti -DHAVE_LLVM=0x0500 -c -o utils/prepare-builtins.o ./utils/prepare-builtins.cpp
-include utils/prepare-builtins.o.d

utils/prepare-builtins: utils/prepare-builtins.o
  @echo LINK utils/prepare-builtins
  $(Verb) /usr/bin/clang++ -o utils/prepare-builtins utils/prepare-builtins.o -lLLVM-5.0 -L/usr/lib -Wl,-rpath /usr/lib
[..]
#v-

Hi Zbigniew,

Thanks for your email. Could you please tell us how you ran configure.py?

Regards,

Jeroen

It's run by Slackbuild script. The relevant part is:

#v+
[..]
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
[..]
CFLAGS="$SLKCFLAGS -D__extern_always_inline=inline" \
./configure.py \
  --prefix=/usr \
  --libexecdir=/usr/lib$LIBDIRSUFFIX/clc/ \
  --pkgconfigdir=/usr/lib$LIBDIRSUFFIX/pkgconfig/ || exit 1
#v-

Well I managed to compile the library, but this is really painful process.

1. I had to modify generated Makefile, by adding there:

-I/usr/include/c++/5.3.0/i586-slackware-linux -I/usr/include/c++/5.3.0

"configure" script was unable to find out the library will need header
files from both directories.

2. Next problem was, that some object files (crtbegin.o IIRC) from directory

/usr/lib/gcc/i586-slackware-linux/5.3.0

...were also needed for linking stage.

Again: why "configure.py" is unable to detect their location? It's not that
difficult: "find /usr/lib -name crtbegin.o". Not being sure, how to pass
this information to Makefile, I simply copied all these object files from
that directory into libclc source directory. It seems, it worked.

3. Another problem - the one I contacted you with: it seems it's looking for
libgcc.o shared library, which SIMPLY DOESN'T EXIST in most distros! You can
choose among either:

/usr/lib/gcc/i586-slackware-linux/5.3.0/libgcc.a

...or:

/usr/lib/libgcc_s.so

So again I had to do "manual intervention" by adding a symlink, to complete
linking process: "ln -s /usr/lib/libgcc_s.so /usr/lib/libgcc.so". It seems
it worked, by until now I'm not sure is it exactly library meant to be
linked with libclc (similar name doesn't have mean it is). But I hope it is.

So finally I created the package, and even compiled Mesa which depends upon
it. It seems it also works.

Hi Zbigniew,

The configure script depends on the llvm-config executable to figure out the locations of all the headers and libraries you mention below. So, the question is whether the configure script is picking up on the correct llvm-config and whether llvm-config reports the right values. You in particular want to check the output of the following two commands:

llvm-config --ldflags
llvm-config --cxx-flags

You can also explicitly point the configure script to the correct llvm-config with the help of the --with-llvm-config option.

Does the above help?

Regards,

Jeroen

Hi Zbigniew,

In addition to be below: are you sure that they installed clang compiler is properly configured? Can you compile any program with it?

Thanks,

Jeroen

Hi Zbigniew,

The configure script depends on the llvm-config executable to figure out the locations of all the headers and libraries you mention below. So, the question is whether the configure script is picking up on the correct llvm-config and whether llvm-config reports the right values. You in particular want to check the output of the following two commands:

llvm-config --ldflags

-L/usr/lib

llvm-config --cxx-flags

-I/usr/include -O2 -march=i586 -mtune=i686 -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -DLLVM_BUILD_GLOBAL_ISEL -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

You can also explicitly point the configure script to the correct llvm-config with the help of the --with-llvm-config option.

Does the above help?

Just a little - I don't have ambition to master LLVM compiler, I simply
wanted to prepare library package not investing into this that many hours.
I believe when libclc cannot 100% rely on LLVM's output it would be better
idea to prepare better "configure" script.

I described the problems I had to solve - and actually I don't see much
related information in LLVM's commands outputs you wrote about. So either
it's not there, or I can't see it there - which in result means about the
same: if it isn't done "on automatic" the operator is in trouble (unless
he's experienced programmer using LLVM many times before, which is "not
always" the case).

As I wrote: so far compiled libclc and Mesa with it. I don't know much about
its configuration, I simply used "stock" build scripts taken from Slackware
repository. That's how they build it. Not knowing much about LLVM I have no
idea how to configure it any better, unfortunately.

Hi,

Could you just try to compile a simple C++ program with your /usr/bin/clang++ and report on the result?

Thanks,

Jeroen

[Adding back the mailing list in the cc]

Ok, so the clang you’re using is definitely not setup properly. This is not a libclc problem. You should inquire with the maintainer of the clang build scripts you’re using.

Jeroen