Skip to contentSkip to conversation

Add llvm/clang + openCL

RFC New Romain Naour 1 participant 10 messages Jul 3, 2017

lore
Share & tools
lore
#0 lore raw

cover Add llvm/clang + openCL

Hi,

This work is initially based on the series posted on the mailing list by Paul Cercueil [1] and completed to add a more complete LLVM+Clang stack. Some additional tools or libraries are missing (compiler-rt, clang-tools-extra...)

The series has been updated to use the latest llvm/clang release (4.0.1) and taking into account some comments given to the Adrian Perez de Castro series [2].

So, the five first patches add llvm and clang for the host and the target. host-llvm and host-clang provide host-compiler and libraries used as cross-compilation tools.
Target variant provide llvm/clang libraries needed at runtime on the target.

As also noticed by Adian, copy llvm-config (host variant) to STAGING_DIR since llvm-config provided by llvm target variant can't run on the host.

Also llvm-config (host variant) return include and lib directories for the host if it's installed in host/usr/bin:

output/host/usr/bin/llvm-config --includedir
output/host/usr/include

When istalled in STAGING_DIR llvm-config return include and lib directories from STAGING_DIR:

output/staging/usr/bin/llvm-config --includedir
output/staging/usr/include

As soon as we have host-llvm and llvm package, we can enable llvm as the shader compiler for Radeon video cards (HD6310) when the R600 Gallium driver is used.

The sixth patch add the support for AMDGPU llvm target in order to allow enabling llvm support in mesa3d.

The last two patches allow to enable openCL in mesa3d using libclc.

This is the first version published on the mailing list for review.

Best regards,
Romain

[1] http://lists.busybox.net/pipermail/buildroot/2015-February/119564.html

    http://patchwork.ozlabs.org/patch/440715/
    http://patchwork.ozlabs.org/patch/440716/

[2] http://lists.busybox.net/pipermail/buildroot/2017-June/194745.html

    http://patchwork.ozlabs.org/patch/777949/
    http://patchwork.ozlabs.org/patch/777947/

Romain Naour (9):
package/llvm: new host package package/clang: new host package package/llvm: enable target variant package/llvm: RFC: install llvm-config in staging package/clang: enable target variant package/llvm: add AMDGPU support package/mesa3d: enable llvm support package/libclc: new package package/mesa3d: enable openCL support

 package/Config.in                                  |   2 +
 package/Config.in.host                             |   2 +
 package/clang/Config.in.host                       |   8 +
 package/clang/clang.hash                           |   2 +
 package/clang/clang.mk                             |  57 +++++
 ...y-allow-to-define-llvm-bindir-for-cross-c.patch |  37 +++
 package/libclc/Config.in                           |  10 +
 package/libclc/libclc.mk                           |  40 +++
 package/llvm/Config.in                             |  38 +++
 package/llvm/Config.in.host                        |   8 +
 package/llvm/llvm.hash                             |   2 +
 package/llvm/llvm.mk                               | 285 +++++++++++++++++++++
 package/mesa3d/Config.in                           |  23 ++
 package/mesa3d/mesa3d.mk                           |  24 +-
 14 files changed, 536 insertions(+), 2 deletions(-)
 create mode 100644 package/clang/Config.in.host
 create mode 100644 package/clang/clang.hash
 create mode 100644 package/clang/clang.mk
 create mode 100644 package/libclc/0001-configure.py-allow-to-define-llvm-bindir-for-cross-c.patch
 create mode 100644 package/libclc/Config.in
 create mode 100644 package/libclc/libclc.mk
 create mode 100644 package/llvm/Config.in
 create mode 100644 package/llvm/Config.in.host
 create mode 100644 package/llvm/llvm.hash
 create mode 100644 package/llvm/llvm.mk
Signature · 1 line
2.9.4
#1 lore raw

RFC 1/9 package/llvm: new host package

Cc Adrian Perez de Castro <[email protected]>
---
 package/Config.in.host      |   1 +
 package/llvm/Config.in.host |  29 +++++++
 package/llvm/llvm.hash      |   2 +
 package/llvm/llvm.mk        | 206 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 238 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
index 0932b9f..cf49950 100644
@@ -21,6 +21,7 @@ menu "Host utilities"
 	source "package/imx-usb-loader/Config.in.host"
 	source "package/jq/Config.in.host"
 	source "package/jsmin/Config.in.host"
+	source "package/llvm/Config.in.host"
 	source "package/lpc3250loader/Config.in.host"
 	source "package/lttng-babeltrace/Config.in.host"
 	source "package/mfgtools/Config.in.host"
package/llvm/Config.in.host new file +29 -0
new file mode 100644
index 0000000..454cf10
@@ -0,0 +1,29 @@
+config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	bool
+	# http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
+	# http://llvm.org/docs/GettingStarted.html#local-llvm-configuration
+	depends on BR2_HOST_GCC_AT_LEAST_4_8
+	default y if BR2_arm || BR2_armeb
+	default y if BR2_aarch64
+	default y if BR2_i386 || BR2_x86_64
+	default y if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
+	default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
+	default y if BR2_sparc
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH
+	string
+	default "ARM" if BR2_arm || BR2_armeb
+	default "AArch64" if BR2_aarch64
+	default "X86" if BR2_i386 || BR2_x86_64
+	default "Mips" if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
+	default "PowerPC" if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
+	default "Sparc" if BR2_sparc
+
+config BR2_PACKAGE_HOST_LLVM
+	bool "host llvm"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	help
+	  The LLVM Project is a collection of modular and reusable
+	  compiler and toolchain technologies.
+
+	  http://llvm.org
package/llvm/llvm.hash new file +2 -0
new file mode 100644
index 0000000..6ab2571
@@ -0,0 +1,2 @@
+# locally calculated
+sha256	da783db1f82d516791179fe103c71706046561f7972b18f0049242dee6712b51	llvm-4.0.1.src.tar.xz
package/llvm/llvm.mk new file +206 -0

206 lines not on this page · raw message

Signature · 1 line
2.9.4
#2 lore raw

RFC 2/9 package/clang: new host package

In reply to Romain Naour

Install clang-tblgen to HOST_DIR.

---
 package/Config.in.host       |  1 +
 package/clang/Config.in.host |  8 ++++++++
 package/clang/clang.hash     |  2 ++
 package/clang/clang.mk       | 36 ++++++++++++++++++++++++++++++++++++
 4 files changed, 47 insertions(+)
 create mode 100644 package/clang/Config.in.host
 create mode 100644 package/clang/clang.hash
 create mode 100644 package/clang/clang.mk
package/Config.in.host +1 -0
index cf49950..ecbbea0 100644
@@ -4,6 +4,7 @@ menu "Host utilities"
 	source "package/android-tools/Config.in.host"
 	source "package/cbootimage/Config.in.host"
 	source "package/checkpolicy/Config.in.host"
+	source "package/clang/Config.in.host"
 	source "package/cramfs/Config.in.host"
 	source "package/dfu-util/Config.in.host"
 	source "package/dos2unix/Config.in.host"
package/clang/Config.in.host new file +8 -0
new file mode 100644
index 0000000..8d6c99a
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_HOST_CLANG
+	bool "host clang"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	help
+	  Clang is a C++, Objective C and Objective C++ front-end for
+	  the LLVM compiler.
+
+	  http://llvm.org
package/clang/clang.hash new file +2 -0
new file mode 100644
index 0000000..c2a9d23
@@ -0,0 +1,2 @@
+# locally calculated
+sha256	61738a735852c23c3bdbe52d035488cdb2083013f384d67c1ba36fabebd8769b	cfe-4.0.1.src.tar.xz
package/clang/clang.mk new file +36 -0
new file mode 100644
index 0000000..e70afa4
@@ -0,0 +1,36 @@
+################################################################################
+#
+# clang
+#
+################################################################################
+
+CLANG_VERSION = 4.0.1
+CLANG_SITE = http://llvm.org/releases/$(CLANG_VERSION)
+CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz
+CLANG_LICENSE = NCSA
+CLANG_LICENSE_FILES = LICENSE.TXT
+
+HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
+
+CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
+
+HOST_CLANG_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF \
+	-DCLANG_INCLUDE_TESTS=OFF \
+	-DCLANG_BUILD_EXAMPLES=OFF \
+	-DCLANG_BUILD_TOOLS=ON \
+	-DCLANG_VENDOR=$(TARGET_VENDOR) \
+	-DCLANG_VENDOR_UTI="http://bugs.buildroot.net/"
+
+# For some reason clang-tblgen is not installed in HOST_DIR.
+define HOST_CLANG_COPY_CLANG_TBLGEN_TO_HOST_DIR
+	$(INSTALL) -D -m 0755 $(@D)/buildroot-build/bin/clang-tblgen \
+		$(HOST_DIR)/usr/bin/clang-tblgen
+endef
+HOST_CLANG_POST_INSTALL_HOOKS = HOST_CLANG_COPY_CLANG_TBLGEN_TO_HOST_DIR
+
+# We need to set a proper RPATH otherwise the build stop on the RPATH check:
+# *** ERROR: package host-clang installs executables without proper RPATH
+HOST_CLANG_CONF_ENV += \
+	LDFLAGS="$(HOST_LDFLAGS) -L${HOST_DIR}/usr/lib -Wl,-rpath,${HOST_DIR}/usr/lib"
+
+$(eval $(host-cmake-package))
Signature · 1 line
2.9.4
#3 lore raw

RFC 3/9 package/llvm: enable target variant

In reply to Romain Naour

We need llvm libraries libLLVM* for the target installed in staging and target directories.

Move BR2_PACKAGE_LLVM_ARCH_SUPPORTS and BR2_PACKAGE_LLVM_TARGET_ARCH to package/llvm/Config.in for consistency with other packages.

Define target triple with GNU_TARGET_NAME.

Add tools to deploy *.a in STAGING_DIR.

Cc Adrian Perez de Castro <[email protected]>
---
 package/Config.in                          |  1 +
 package/llvm/{Config.in.host => Config.in} |  4 +-
 package/llvm/Config.in.host                | 21 ----------
 package/llvm/llvm.mk                       | 62 +++++++++++++++++++++++++++++-
 4 files changed, 63 insertions(+), 25 deletions(-)
 copy package/llvm/{Config.in.host => Config.in} (95%)
package/Config.in +1 -0
index 355aa52..c34325f 100644
@@ -1435,6 +1435,7 @@ menu "Other"
 	source "package/libuv/Config.in"
 	source "package/lightning/Config.in"
 	source "package/linux-pam/Config.in"
+	source "package/llvm/Config.in"
 if BR2_PACKAGE_LINUX_PAM
 comment "linux-pam plugins"
 	source "package/libpam-radius-auth/Config.in"
package/llvm/Config.in renamed from package/llvm/Config.in.host +2 -2
similarity index 95%
copy from package/llvm/Config.in.host
copy to package/llvm/Config.in
index 454cf10..84dde8d 100644
@@ -19,8 +19,8 @@ config BR2_PACKAGE_LLVM_TARGET_ARCH
 	default "PowerPC" if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
 	default "Sparc" if BR2_sparc
 
-config BR2_PACKAGE_HOST_LLVM
-	bool "host llvm"
+config BR2_PACKAGE_LLVM
+	bool "llvm"
 	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 	help
 	  The LLVM Project is a collection of modular and reusable
package/llvm/Config.in.host +0 -21
index 454cf10..fc46535 100644
@@ -1,24 +1,3 @@
-config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
-	bool
-	# http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
-	# http://llvm.org/docs/GettingStarted.html#local-llvm-configuration
-	depends on BR2_HOST_GCC_AT_LEAST_4_8
-	default y if BR2_arm || BR2_armeb
-	default y if BR2_aarch64
-	default y if BR2_i386 || BR2_x86_64
-	default y if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
-	default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
-	default y if BR2_sparc
-
-config BR2_PACKAGE_LLVM_TARGET_ARCH
-	string
-	default "ARM" if BR2_arm || BR2_armeb
-	default "AArch64" if BR2_aarch64
-	default "X86" if BR2_i386 || BR2_x86_64
-	default "Mips" if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
-	default "PowerPC" if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
-	default "Sparc" if BR2_sparc
-
 config BR2_PACKAGE_HOST_LLVM
 	bool "host llvm"
 	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
package/llvm/llvm.mk +60 -2

244 lines not on this page · raw message

Signature · 1 line
2.9.4
#4 lore raw

RFC 4/9 package/llvm: RFC: install llvm-config in staging

In reply to Romain Naour
---
 package/llvm/llvm.mk | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
package/llvm/llvm.mk +16 -0
index 3d0a052..45ce4b4 100644
@@ -24,6 +24,22 @@ LLVM_DEPENDENCIES = host-llvm zlib
 # Use native llvm-tblgen from host-llvm.
 LLVM_CONF_OPTS += -DLLVM_TABLEGEN=$(HOST_DIR)/usr/bin/llvm-tblgen
 
+# Copy llvm-config (host variant) to STAGING_DIR since llvm-config
+# provided by llvm target variant can't run on the host.
+# Also llvm-config (host variant) return include and lib directories
+# for the host if it's installed in host/usr/bin:
+# output/host/usr/bin/llvm-config --includedir
+# output/host/usr/include
+# When istalled in STAGING_DIR llvm-config return include and lib
+# directories from STAGING_DIR.
+# output/staging/usr/bin/llvm-config --includedir
+# output/staging/usr/include
+define LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
+	$(INSTALL) -D -m 0755 $(HOST_DIR)/usr/bin/llvm-config \
+		$(STAGING_DIR)/usr/bin/llvm-config
+endef
+LLVM_POST_INSTALL_STAGING_HOOKS = LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
+
 # Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
 # Ninja is not supported yet by Buildroot
 HOST_LLVM_CONF_OPTS += -G "Unix Makefiles"
Signature · 1 line
2.9.4
#5 lore raw

RFC 5/9 package/clang: enable target variant

In reply to Romain Naour
---
 package/clang/clang.mk | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
package/clang/clang.mk +21 -0
index e70afa4..2a82165 100644
@@ -12,7 +12,10 @@ CLANG_LICENSE_FILES = LICENSE.TXT
 
 HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
 
+CLANG_DEPENDENCIES = host-clang host-llvm host-libxml2 llvm
+
 CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
+CLANG_INSTALL_STAGING = YES
 
 HOST_CLANG_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF \
 	-DCLANG_INCLUDE_TESTS=OFF \
@@ -21,6 +24,20 @@ HOST_CLANG_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF \
 	-DCLANG_VENDOR=$(TARGET_VENDOR) \
 	-DCLANG_VENDOR_UTI="http://bugs.buildroot.net/"
 
+CLANG_CONF_ENV += LLVM_CONFIG=$(STAGING_DIR)/usr/bin/llvm-config
+
+# Needs build_tools to provide clangSema etc...
+CLANG_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF \
+	-DCLANG_INCLUDE_TESTS=OFF \
+	-DCLANG_BUILD_EXAMPLES=OFF \
+	-DCLANG_BUILD_TOOLS=ON \
+	-DCLANG_INCLUDE_TESTS=OFF \
+	-DCLANG_TABLEGEN=$(HOST_DIR)/usr/bin/clang-tblgen \
+	-DCLANG_VENDOR=$(TARGET_VENDOR) \
+	-DCLANG_VENDOR_UTI="http://bugs.buildroot.net/" \
+	-DLLVM_CONFIG=$(STAGING_DIR)/usr/bin/llvm-config \
+	-DLLVM_TABLEGEN_EXE=$(HOST_DIR)/usr/bin/llvm-tblgen
+
 # For some reason clang-tblgen is not installed in HOST_DIR.
 define HOST_CLANG_COPY_CLANG_TBLGEN_TO_HOST_DIR
 	$(INSTALL) -D -m 0755 $(@D)/buildroot-build/bin/clang-tblgen \
@@ -33,4 +50,8 @@ HOST_CLANG_POST_INSTALL_HOOKS = HOST_CLANG_COPY_CLANG_TBLGEN_TO_HOST_DIR
 HOST_CLANG_CONF_ENV += \
 	LDFLAGS="$(HOST_LDFLAGS) -L${HOST_DIR}/usr/lib -Wl,-rpath,${HOST_DIR}/usr/lib"
 
+CLANG_CONF_ENV += \
+	LDFLAGS="$(LDFLAGS) -L${STAGING_DIR}/usr/lib -Wl,-rpath,${STAGING_DIR}/usr/lib"
+
+$(eval $(cmake-package))
 $(eval $(host-cmake-package))
Signature · 1 line
2.9.4
#6 lore raw

RFC 6/9 package/llvm: add AMDGPU support

In reply to Romain Naour

Limit the number of supported target for mesa3d when openCL support is enabled. With -DLLVM_TARGETS_TO_BUILD="all" mesa3d fail to build on x86_64 target with AMDGPU target:

CXXLD libOpenCL.la
../../../../src/gallium/state_trackers/clover/.libs/libclover.a(libclllvm_la-invocation.o): In function `(anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
invocation.cpp:(.text+0x1a8): undefined reference to `LLVMInitializeAArch64Target'
invocation.cpp:(.text+0x1b2): undefined reference to `LLVMInitializeARMTarget'
invocation.cpp:(.text+0x1b7): undefined reference to `LLVMInitializeBPFTarget'
invocation.cpp:(.text+0x1bc): undefined reference to `LLVMInitializeHexagonTarget'
invocation.cpp:(.text+0x1c1): undefined reference to `LLVMInitializeLanaiTarget'
invocation.cpp:(.text+0x1c6): undefined reference to `LLVMInitializeMipsTarget'
invocation.cpp:(.text+0x1cb): undefined reference to `LLVMInitializeMSP430Target'
invocation.cpp:(.text+0x1d0): undefined reference to `LLVMInitializeNVPTXTarget'
invocation.cpp:(.text+0x1d5): undefined reference to `LLVMInitializePowerPCTarget'
invocation.cpp:(.text+0x1da): undefined reference to `LLVMInitializeRISCVTarget'
invocation.cpp:(.text+0x1df): undefined reference to `LLVMInitializeSparcTarget'
invocation.cpp:(.text+0x1e4): undefined reference to `LLVMInitializeSystemZTarget'
invocation.cpp:(.text+0x1ee): undefined reference to `LLVMInitializeXCoreTarget'
invocation.cpp:(.text+0x1f3): undefined reference to `LLVMInitializeAArch64TargetInfo'
invocation.cpp:(.text+0x1fd): undefined reference to `LLVMInitializeARMTargetInfo'
invocation.cpp:(.text+0x202): undefined reference to `LLVMInitializeBPFTargetInfo'
invocation.cpp:(.text+0x207): undefined reference to `LLVMInitializeHexagonTargetInfo'
invocation.cpp:(.text+0x20c): undefined reference to `LLVMInitializeLanaiTargetInfo'
invocation.cpp:(.text+0x211): undefined reference to `LLVMInitializeMipsTargetInfo'
invocation.cpp:(.text+0x216): undefined reference to `LLVMInitializeMSP430TargetInfo'
invocation.cpp:(.text+0x21b): undefined reference to `LLVMInitializeNVPTXTargetInfo'
invocation.cpp:(.text+0x220): undefined reference to `LLVMInitializePowerPCTargetInfo'
invocation.cpp:(.text+0x225): undefined reference to `LLVMInitializeRISCVTargetInfo'
invocation.cpp:(.text+0x22a): undefined reference to `LLVMInitializeSparcTargetInfo'
invocation.cpp:(.text+0x22f): undefined reference to `LLVMInitializeSystemZTargetInfo'
invocation.cpp:(.text+0x239): undefined reference to `LLVMInitializeXCoreTargetInfo'
invocation.cpp:(.text+0x23e): undefined reference to `LLVMInitializeAArch64TargetMC'
invocation.cpp:(.text+0x248): undefined reference to `LLVMInitializeARMTargetMC'
invocation.cpp:(.text+0x24d): undefined reference to `LLVMInitializeBPFTargetMC'
invocation.cpp:(.text+0x252): undefined reference to `LLVMInitializeHexagonTargetMC'
invocation.cpp:(.text+0x257): undefined reference to `LLVMInitializeLanaiTargetMC'
invocation.cpp:(.text+0x25c): undefined reference to `LLVMInitializeMipsTargetMC'
invocation.cpp:(.text+0x261): undefined reference to `LLVMInitializeMSP430TargetMC'
invocation.cpp:(.text+0x266): undefined reference to `LLVMInitializeNVPTXTargetMC'
invocation.cpp:(.text+0x26b): undefined reference to `LLVMInitializePowerPCTargetMC'
invocation.cpp:(.text+0x270): undefined reference to `LLVMInitializeRISCVTargetMC'
invocation.cpp:(.text+0x275): undefined reference to `LLVMInitializeSparcTargetMC'
invocation.cpp:(.text+0x27a): undefined reference to `LLVMInitializeSystemZTargetMC'
invocation.cpp:(.text+0x284): undefined reference to `LLVMInitializeXCoreTargetMC'
invocation.cpp:(.text+0x289): undefined reference to `LLVMInitializeAArch64AsmPrinter'
invocation.cpp:(.text+0x293): undefined reference to `LLVMInitializeARMAsmPrinter'
invocation.cpp:(.text+0x298): undefined reference to `LLVMInitializeBPFAsmPrinter'
invocation.cpp:(.text+0x29d): undefined reference to `LLVMInitializeHexagonAsmPrinter'
invocation.cpp:(.text+0x2a2): undefined reference to `LLVMInitializeLanaiAsmPrinter'
invocation.cpp:(.text+0x2a7): undefined reference to `LLVMInitializeMipsAsmPrinter'
invocation.cpp:(.text+0x2ac): undefined reference to `LLVMInitializeMSP430AsmPrinter'
invocation.cpp:(.text+0x2b1): undefined reference to `LLVMInitializeNVPTXAsmPrinter'
invocation.cpp:(.text+0x2b6): undefined reference to `LLVMInitializePowerPCAsmPrinter'
invocation.cpp:(.text+0x2bb): undefined reference to `LLVMInitializeSparcAsmPrinter'
invocation.cpp:(.text+0x2c0): undefined reference to `LLVMInitializeSystemZAsmPrinter'
invocation.cpp:(.text+0x2ca): undefined reference to `LLVMInitializeXCoreAsmPrinter'
collect2: error: ld returned 1 exit status

---
 package/llvm/Config.in | 9 +++++++++
 package/llvm/llvm.mk   | 9 +++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
package/llvm/Config.in +9 -0
index 84dde8d..417af6e 100644
@@ -27,3 +27,12 @@ config BR2_PACKAGE_LLVM
 	  compiler and toolchain technologies.
 
 	  http://llvm.org
+
+if BR2_PACKAGE_LLVM
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH_AMDGPU
+	bool "AMDGPU"
+	help
+	  TODO
+
+endif # BR2_PACKAGE_LLVM
package/llvm/llvm.mk +7 -2
index 45ce4b4..0e381ff 100644
@@ -228,8 +228,13 @@ HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
 LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
 
 HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
-HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD=$(HOST_LLVM_TARGET_ARCH)
-LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD=$(HOST_LLVM_TARGET_ARCH)
+
+ifeq ($(BR2_PACKAGE_LLVM_TARGET_ARCH_AMDGPU),y)
+HOST_LLVM_TARGET_TO_BUILD = "$(HOST_LLVM_TARGET_ARCH);AMDGPU"
+endif
+
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD=$(HOST_LLVM_TARGET_TO_BUILD)
+LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD=$(HOST_LLVM_TARGET_TO_BUILD)
 # LLVM target to use for native code generation.
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
 LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
Signature · 1 line
2.9.4
#7 lore raw

RFC 7/9 package/mesa3d: enable llvm support

In reply to Romain Naour
Cc Adrian Perez de Castro <[email protected]>
---
 package/mesa3d/Config.in |  8 ++++++++
 package/mesa3d/mesa3d.mk | 17 ++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)
package/mesa3d/Config.in +8 -0
index ad41b1c..94ef767 100644
@@ -23,6 +23,14 @@ menuconfig BR2_PACKAGE_MESA3D
 
 if BR2_PACKAGE_MESA3D
 
+config BR2_PACKAGE_MESA3D_LLVM
+	bool "mesa3d w/ llvm"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	select BR2_PACKAGE_LLVM
+
+comment "mesa3d w/ llvm needs a llvm compiler"
+	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+
 # inform the .mk file of gallium, dri or vulkan driver selection
 config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
 	bool
package/mesa3d/mesa3d.mk +14 -3
index 7b312e3..4633bff 100644
@@ -26,6 +26,20 @@ MESA3D_DEPENDENCIES = \
 # Disable assembly usage.
 MESA3D_CONF_OPTS = --disable-asm
 
+ifeq ($(BR2_PACKAGE_MESA3D_LLVM),y)
+MESA3D_DEPENDENCIES += host-llvm llvm
+MESA3D_CONF_OPTS += \
+	--with-llvm-prefix=$(STAGING_DIR)/usr \
+	--enable-llvm-shared-libs \
+	--enable-llvm
+else
+# Avoid automatic search of llvm-config
+MESA3D_CONF_OPTS += \
+	--with-llvm-prefix=$(STAGING_DIR)/usr \
+	--disable-llvm-shared-libs \
+	--disable-llvm
+endif
+
 # The Sourcery MIPS toolchain has a special (non-upstream) feature to
 # have "compact exception handling", which unfortunately breaks with
 # mesa3d, so we disable it here by passing -mno-compact-eh.
@@ -213,7 +227,4 @@ else
 MESA3D_CONF_OPTS += --disable-lmsensors
 endif
 
-# Avoid automatic search of llvm-config
-MESA3D_CONF_OPTS += --with-llvm-prefix=$(STAGING_DIR)/usr/bin
-
 $(eval $(autotools-package))
Signature · 1 line
2.9.4
#8 lore raw

RFC 8/9 package/libclc: new package

In reply to Romain Naour

Use the latest commit in master branch.

---
 package/Config.in                                  |  1 +
 ...y-allow-to-define-llvm-bindir-for-cross-c.patch | 37 ++++++++++++++++++++
 package/libclc/Config.in                           | 10 ++++++
 package/libclc/libclc.mk                           | 40 ++++++++++++++++++++++
 4 files changed, 88 insertions(+)
 create mode 100644 package/libclc/0001-configure.py-allow-to-define-llvm-bindir-for-cross-c.patch
 create mode 100644 package/libclc/Config.in
 create mode 100644 package/libclc/libclc.mk
package/Config.in +1 -0
index c34325f..711c6f3 100644
@@ -266,6 +266,7 @@ comment "Graphic libraries"
 	source "package/fbv/Config.in"
 	source "package/freerdp/Config.in"
 	source "package/imagemagick/Config.in"
+	source "package/libclc/Config.in"
 	source "package/linux-fusion/Config.in"
 	source "package/lite/Config.in"
 	source "package/mesa3d/Config.in"
package/libclc/0001-configure.py-allow-to-define-llvm-bindir-for-cross-c.patch new file +37 -0
new file mode 100644
index 0000000..27f46cf
@@ -0,0 +1,37 @@
+From d46e38da621a64637970a071b9aa08dc17f0638b Mon Sep 17 00:00:00 2001
+From: Romain Naour <[email protected]>
+Date: Mon, 3 Jul 2017 10:37:11 +0200
+Subject: [PATCH] configure.py: allow to define llvm-bindir for cross-compiling
+
+TODO
+
+Signed-off-by: Romain Naour <[email protected]>
+---
+ configure.py | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/configure.py b/configure.py
+index f26f535..fe4cbc0 100755
+--- a/configure.py
++++ b/configure.py
+@@ -22,6 +22,8 @@ import metabuild
+ p = OptionParser()
+ p.add_option('--with-llvm-config', metavar='PATH',
+              help='use given llvm-config script')
++p.add_option('--llvm-bindir', metavar='PATH',
++             help='use given llvm-bindir')
+ p.add_option('--with-cxx-compiler', metavar='PATH',
+              help='use given C++ compiler')
+ p.add_option('--prefix', metavar='PATH',
+@@ -74,7 +76,7 @@ if llvm_int_version < 400:
+     sys.exit(1)
+ 
+ llvm_system_libs = llvm_config(['--system-libs'])
+-llvm_bindir = llvm_config(['--bindir'])
++llvm_bindir = options.llvm_bindir or llvm_config(['--bindir'])
+ llvm_core_libs = llvm_config(['--libs', 'core', 'bitreader', 'bitwriter']) + ' ' + \
+                  llvm_system_libs + ' ' + \
+                  llvm_config(['--ldflags'])
+-- 
+2.9.4
+
package/libclc/Config.in new file +10 -0
new file mode 100644
index 0000000..44d4d96
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_LIBCLC
+	bool "libclc"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	help
+	  libclc is an open source, BSD/MIT dual licensed
+	  implementation of the library requirements of the OpenCL C
+	  programming language, as specified by the OpenCL 1.1
+	  Specification.
+
+	  http://libclc.llvm.org/
package/libclc/libclc.mk new file +40 -0
new file mode 100644
index 0000000..a176a59
@@ -0,0 +1,40 @@
+################################################################################
+#
+# libclc
+#
+################################################################################
+
+LIBCLC_VERSION = 1cb3fbf504e25d86d972e8b2af3e24571767046b
+LIBCLC_SITE = http://llvm.org/git/libclc.git
+LIBCLC_SITE_METHOD = git
+
+LIBCLC_DEPENDENCIES = host-clang host-llvm
+
+LIBCLC_INSTALL_STAGING = YES
+
+# C++ compiler is used to build a small tool (prepare-builtins) for the host.
+# It must be build with the C++ compiler from the host, simply use
+# HOSTCXX_NOCCACHE.
+LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
+	--prefix="/usr" \
+	--pkgconfigdir="/usr/lib/pkgconfig" \
+	--llvm-bindir=$(HOST_DIR)/usr/bin \
+	--with-cxx-compiler='$(HOSTCXX_NOCCACHE)'
+
+define LIBCLC_CONFIGURE_CMDS
+	(cd $(@D); $(TARGET_CONFIGURE_OPTS) ./configure.py $(LIBCLC_CONF_OPTS))
+endef
+
+define LIBCLC_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
+endef
+
+define LIBCLC_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
+endef
+
+define LIBCLC_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.9.4
#9 lore raw

RFC 9/9 package/mesa3d: enable openCL support

In reply to Romain Naour
---
 package/mesa3d/Config.in | 15 +++++++++++++++
 package/mesa3d/mesa3d.mk |  9 +++++++++
 2 files changed, 24 insertions(+)
package/mesa3d/Config.in +15 -0
index 94ef767..4e7f56a 100644
@@ -31,6 +31,21 @@ config BR2_PACKAGE_MESA3D_LLVM
 comment "mesa3d w/ llvm needs a llvm compiler"
 	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 
+config BR2_PACKAGE_MESA3D_OPENCL
+	bool "mesa3d openCL"
+	depends on BR2_PACKAGE_MESA3D_LLVM
+	depends on BR2_USE_WCHAR # elfutils
+	depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC # elfutils
+	depends on !BR2_bfin # elfutils
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_LIBCLC
+
+comment "mesa3d openCL needs a uClibc or glibc toolchain w/ wchar"
+	depends on BR2_PACKAGE_MESA3D_LLVM
+	depends on !BR2_bfin
+	depends on !BR2_USE_WCHAR \
+		|| !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC)
+
 # inform the .mk file of gallium, dri or vulkan driver selection
 config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
 	bool
package/mesa3d/mesa3d.mk +9 -0
index 4633bff..530a63c 100644
@@ -227,4 +227,13 @@ else
 MESA3D_CONF_OPTS += --disable-lmsensors
 endif
 
+# libclc (Clover) requires libelf
+ifeq ($(BR2_PACKAGE_MESA3D_OPENCL),y)
+MESA3D_DEPENDENCIES += clang elfutils libclc
+MESA3D_CONF_OPTS += --enable-opencl \
+	--with-clang-libdir=$(HOST_DIR)/usr/lib
+else
+MESA3D_CONF_OPTS += --disable-opencl
+endif
+
 $(eval $(autotools-package))
Signature · 1 line
2.9.4