LLVM
This set of patches adds a very preliminary support for compiling a LLVM cross-compiler within Buildroot.
While this is not the full LLVM+Clang stack, it already permits to compile LLVM bitcode into executables.
For instance, to compile a helloworld for a mipsel CPU (using my PC's "clang" as it is not yet available in Buildroot):
clang hello.c -target mipsel-buildroot-linux-uclibc -c -emit-llvm -o hello.bc mipsel-buildroot-linux-uclibc-llc hello.bc -o hello.S mipsel-buildroot-linux-uclibc-gcc hello.S -o hello
Note that this requires host-binutils v2.24 (at least for MIPS).
The second patch adds support for LLVM to the Mesa3d package. It permits to use LLVM as the shader compiler for Radeon video cards when the R600 Gallium driver is used. This is mostly for reference to demonstrate how the LLVM cross-compiler can be also used by the cross-compiled packages.
RFC PATCH 1/2 LLVM: Added package
--- package/Config.in.host | 1 + package/llvm/Config.in.host | 13 +++++++++++++ package/llvm/llvm.hash | 1 + package/llvm/llvm.mk | 22 ++++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 package/llvm/Config.in.host create mode 100644 package/llvm/llvm.hash create mode 100644 package/llvm/llvm.mk
package/Config.in.host +1 -0
@@ -10,6 +10,7 @@ menu "Host utilities" source "package/genext2fs/Config.in.host" source "package/genimage/Config.in.host" source "package/genpart/Config.in.host" + source "package/llvm/Config.in.host" source "package/lpc3250loader/Config.in.host" source "package/mke2img/Config.in.host" source "package/mtd/Config.in.host"
package/llvm/Config.in.host new file +13 -0
@@ -0,0 +1,13 @@ +config BR2_PACKAGE_HOST_LLVM + bool "host llvm" + depends on BR2_arm || BR2_armeb || BR2_aarch64 || \ + BR2_i386 || BR2_x86_64 || \ + BR2_mips || BR2_mipsel || \ + BR2_mips64 || BR2_mips64el || \ + BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le || \ + BR2_sparc + help + The LLVM Project is a collection of modular and reusable compiler + and toolchain technologies. + + http://llvm.org
package/llvm/llvm.hash new file +1 -0
@@ -0,0 +1 @@ +sha256 bf3275d2d7890015c8d8f5e6f4f882f8cf3bf51967297ebe74111d6d8b53be15 llvm-3.5.1.src.tar.xz
package/llvm/llvm.mk new file +22 -0
@@ -0,0 +1,22 @@ +################################################################################ +# +# llvm +# +################################################################################ + +LLVM_VERSION = 3.5.1 +LLVM_SITE = http://llvm.org/releases/$(LLVM_VERSION) +LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz +LLVM_LICENSE = University of Illinois/NCSA Open Source License +LLVM_LICENSE_FILES = LICENSE.TXT + +HOST_LLVM_DEPENDENCIES = host-libxml2 host-zlib host-python + +ENABLED_TARGETS := $(ARCH),$(if $(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600),r600) + +HOST_LLVM_CONF_OPTS = --with-default-sysroot=$(STAGING_DIR) \ + --enable-bindings=none \ + --enable-targets=$(ENABLED_TARGETS) \ + --target=$(GNU_TARGET_NAME) + +$(eval $(host-autotools-package))
Signature · 1 line
2.1.4
RFC PATCH 1/2 LLVM: Added package
Paul, All,
On 2015-02-17 23:02 +0100, Paul Cercueil spake thusly:
Quoted 7 lines
Signed-off-by Paul Cercueil <[email protected]>package/llvm/Config.in.host new file +0
-0
package/llvm/Config.in.host line 8
Quoted 8 lines
package/llvm/Config.in.host new file +8
-0@@ -0,0 +1,13 @@ +config BR2_PACKAGE_HOST_LLVM + bool "host llvm" + depends on BR2_arm || BR2_armeb || BR2_aarch64 || \ + BR2_i386 || BR2_x86_64 || \ + BR2_mips || BR2_mipsel || \ + BR2_mips64 || BR2_mips64el || \ + BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le || \ + BR2_sparc
It would be nice to move all those dependency to their own symbol, like so:
config BR2_PACKAGE_HOST_LLVM_ARCH_SUPPORT
bool
default y
depends on ....and then have the main symbol simply depend on that.
This will be usefull in case other packages want to select host llvm; they'd simply have to depend on BR2_PACKAGE_HOST_LLVM_ARCH_SUPPORT.
package/llvm/llvm.hash line 1
Quoted 7 lines
package/llvm/llvm.hash new file +1
-0@@ -0,0 +1 @@ +sha256 bf3275d2d7890015c8d8f5e6f4f882f8cf3bf51967297ebe74111d6d8b53be15 llvm-3.5.1.src.tar.xz
Where did you get that sha1 from? If you computed it locally, say so. If you grabbed it from upstream, say so an point to it.
Quoted 11 lines
package/llvm/llvm.mk new file +5
-0@@ -0,0 +1,22 @@ +################################################################################ +# +# llvm +# +################################################################################
package/llvm/llvm.mk line 15
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+ +LLVM_VERSION = 3.5.1 +LLVM_SITE = http://llvm.org/releases/$(LLVM_VERSION) +LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz +LLVM_LICENSE = University of Illinois/NCSA Open Source License +LLVM_LICENSE_FILES = LICENSE.TXT + +HOST_LLVM_DEPENDENCIES = host-libxml2 host-zlib host-python + +ENABLED_TARGETS := $(ARCH),$(if $(BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600),r600)
Variables have only global scope, so they need to be prefixed with the package name:
HOST_LLVM_ENABLED_TARGETS = ...
package/llvm/llvm.mk line 20
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+HOST_LLVM_CONF_OPTS = --with-default-sysroot=$(STAGING_DIR) \ + --enable-bindings=none \ + --enable-targets=$(ENABLED_TARGETS) \ + --target=$(GNU_TARGET_NAME)
It seems that, like me, you're using a 4-space tabs. In Buildroot, we use an 8-char tab, so the above get mis-aligned.
I was confused as to why you needed to pass --target, as the pkg-autotools infra already does it. But then I relaised you are building a host package, and building a compiler, thus the need for --target. I wonder if a comment about that would not be needed...
package/llvm/llvm.mk line 22
Quoted 1 line
package/llvm/llvm.mk new file +1
-0+$(eval $(host-autotools-package))
I thought you were adding a target package, i.e. building libllvm (and libclang) for the target. Is that what this is supposed to do?
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
RFC PATCH 2/2 mesa3d: Use LLVM as the shader compiler when applicable
In reply to Paul Cercueil--- package/mesa3d/mesa3d.mk | 11 +++++++++++ 1 file changed, 11 insertions(+)
package/mesa3d/mesa3d.mk +11 -0
@@ -24,6 +24,17 @@ MESA3D_DEPENDENCIES = \ host-xutil_makedepend \ libdrm +ifeq ($(BR2_PACKAGE_HOST_LLVM),y) +MESA3D_DEPENDENCIES += elfutils host-llvm +MESA3D_CONF_OPTS += --enable-gallium-llvm=yes \ + --enable-r600-llvm-compiler=yes \ + --with-llvm-prefix=$(HOST_DIR)/usr +else +MESA3D_CONF_OPTS += --enable-llvm-shared-libs=no \ + --enable-r600-llvm-compiler=no \ + --enable-gallium-llvm=no +endif + ifeq ($(BR2_PACKAGE_XORG7),y) MESA3D_DEPENDENCIES += \ xproto_xf86driproto \
Signature · 1 line
2.1.4