[llvm-commits] [PATCH] Building llvm-gcc with llvm-2.5 debian packages

Hi,

Anybody has an opinion would it be good thing to add support for llvm-gcc to be able to be built with existing llvm installation?

Right now building works with llvm installation also, but only if llvm libs and includes are installed under the same prefix, even though this seems to be unintended functionality.

So after support for building llvm-gcc without llvm sources it would be possible to build e.g. llvm-gcc cross compilers with globally installed llvm package.

Mikael Lepistö

Mikael Lepistö wrote:

Anybody has an opinion would it be good thing to add support for llvm-gcc to be able to be built with existing llvm installation?

To put it the another way: is there a reason to disallow
compiling llvm-gcc (optionally) against an installed LLVM (e.g.
from the Debian package)? It seems to work fine with this patch
Mikael posted.

For us at TCE project* it's a bit nuisance as even though the TCE
user might have LLVM (and native llvm-gcc) installed from Debian,
he still needs to download LLVM sources just for recompiling llvm-gcc to
be used as the TCE cross-compiler.

(*)http://tce.cs.tut.fi

Best regards,

Hi Pekka,

To put it the another way: is there a reason to disallow
compiling llvm-gcc (optionally) against an installed LLVM (e.g.
from the Debian package)? It seems to work fine with this patch
Mikael posted.

I think it would be great if llvm-gcc could be built against
an installed LLVM. However my impression was that Mikael's
original patch would break building against an not-installed llvm.

Ciao,

Duncan.

Hi Pekka,

To put it the another way: is there a reason to disallow
compiling llvm-gcc (optionally) against an installed LLVM (e.g.
from the Debian package)? It seems to work fine with this patch
Mikael posted.

I think it would be great if llvm-gcc could be built against
an installed LLVM. However my impression was that Mikael's
original patch would break building against an not-installed llvm.

Hi, sorry for being a bit unclear before.

The patch would just fix llvm-gcc build system to be able to compile with both, *llvm build in source directory* and *installed llvm version*.

Correct include directory can be get with llvm-config --includedir, because when llvm-config is excuted from llvm source tree (from Release or Debug directory) it will return the include directory of source tree (e.g. llvm-2.6svn/include). If llvm-config is called from installation path it returns include directory of installed llvm includes.

I tried the patch with compiling llvm-gcc with:
- llvm-2.5 source tree build
- installed llvm-2.5 from sources
- apt-get installed debian llvm-2.5 packages.

I will try if the patch works correctly with llvm trunk as well and show also the compile commands which were used to configure and compile the llvm-gcc.

- Mikael

Mikael Lepistö wrote:

Hi Pekka,

To put it the another way: is there a reason to disallow
compiling llvm-gcc (optionally) against an installed LLVM (e.g.
from the Debian package)? It seems to work fine with this patch
Mikael posted.
      

I think it would be great if llvm-gcc could be built against
an installed LLVM. However my impression was that Mikael's
original patch would break building against an not-installed llvm.

Hi, sorry for being a bit unclear before.

The patch would just fix llvm-gcc build system to be able to compile with both, *llvm build in source directory* and *installed llvm version*.

Correct include directory can be get with llvm-config --includedir, because when llvm-config is excuted from llvm source tree (from Release or Debug directory) it will return the include directory of source tree (e.g. llvm-2.6svn/include). If llvm-config is called from installation path it returns include directory of installed llvm includes.

I tried the patch with compiling llvm-gcc with:
- llvm-2.5 source tree build
- installed llvm-2.5 from sources
- apt-get installed debian llvm-2.5 packages.

I will try if the patch works correctly with llvm trunk as well and show also the compile commands which were used to configure and compile the llvm-gcc.
  

Hi,

I tested the trunk and it seems to work as well. Below some information about testing process. I also attached the latest version of the patch.

- Mikael

elhigu@mr-lenovo:~/stow_sources/llvm-svn$ ./configure --prefix=/home/elhigu/stow_repo/test_install/
elhigu@mr-lenovo:~/stow_sources/llvm-svn$ make
elhigu@mr-lenovo:~/stow_sources/llvm-svn$ make install

...

elhigu@mr-lenovo:~/test_llvm_gcc_compilation/llvm-gcc-built-source-tree$ llvm-config
The program 'llvm-config' is currently not installed. You can install it by typing:
sudo apt-get install llvm
bash: llvm-config: command not found

# the source tree build

elhigu@mr-lenovo:~/test_llvm_gcc_compilation/llvm-gcc-built-source-tree$ ../../stow_sources/llvm-gcc-4.2-svn/configure --enable-llvm=/home/elhigu/stow_sources/llvm-svn/ --enable-languages=c

...

elhigu@mr-lenovo:~/test_llvm_gcc_compilation/llvm-gcc-built-source-tree$ make

...
And include switches in compile command in llvm-gcc/gcc directory are:

-I. -I. -I../../../stow_sources/llvm-gcc-4.2-svn/gcc -I../../../stow_sources/llvm-gcc-4.2-svn/gcc/. -I../../../stow_sources/llvm-gcc-4.2-svn/gcc/../include
-I../../../stow_sources/llvm-gcc-4.2-svn/gcc/../libcpp/include -I../../../stow_sources/llvm-gcc-4.2-svn/gcc/../libdecnumber -I../libdecnumber
-I/home/elhigu/stow_sources/llvm-svn/include -I/home/elhigu/stow_sources/llvm-svn/include -I/home/elhigu/stow_sources/llvm-svn/include

...

# and with installed build

elhigu@mr-lenovo:~/test_llvm_gcc_compilation/llvm-gcc-with-installed-llvm$ ../../stow_sources/llvm-gcc-4.2-svn/configure --enable-llvm=/home/elhigu/stow_repo/test_install/ --enable-languages=c

...

elhigu@mr-lenovo:~/test_llvm_gcc_compilation/llvm-gcc-built-source-tree$ make

...

include switches in compile command in llvm-gcc/gcc directory are:

-I. -I. -I../../../stow_sources/llvm-gcc-4.2-svn/gcc -I../../../stow_sources/llvm-gcc-4.2-svn/gcc/. -I../../../stow_sources/llvm-gcc-4.2-svn/gcc/../include
-I../../../stow_sources/llvm-gcc-4.2-svn/gcc/../libcpp/include -I../../../stow_sources/llvm-gcc-4.2-svn/gcc/../libdecnumber -I../libdecnumber
-I/home/elhigu/stow_repo/test_install/include -I/home/elhigu/stow_repo/test_install/include

Makefile-fix-for-allowing-to-build-with-pre-installed-llvm.patch (1.94 KB)

Hi Mikael, I don't like this bit:

+# Also remove extra llvm postfix from includedir, because llvm-config
+# on debian seems to return /usr/include/llvm instead /usr/include

Can this not be fixed in debian?

Ciao,

Duncan.

Hi Mikael, with your patch I can't build llvm-gcc:

make[2]: *** No rule to make target `/home/duncan/LLVM/llvm-objects/../llvm/include/llvm/Intrinsics.gen', needed by `llvm-convert.o'. Stop.

Maybe because I use objdir != srcdir in my LLVM build?

Ciao,

Duncan.

Hi, thanks for testing.

I'll try to duplicate and fix the problem. I also remove that debian (actually it was ubuntu) dependent fix and file a bug report to package maintainer.

For now on I will also test compilation with llvm built when objdir != srcdir. Hopefully I get updated patch before end of the week.

- Mikael