* [Buildroot] [PATCH v5 1/7] package/llvm: new package
2018-04-04 16:31 [Buildroot] [PATCH v5 0/7] llvm for mesa3d Valentin Korenblit
@ 2018-04-04 16:31 ` Valentin Korenblit
2018-04-04 20:50 ` Thomas Petazzoni
2018-04-04 16:31 ` [Buildroot] [PATCH v5 2/7] package/llvm: enable AMDGPU Valentin Korenblit
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Valentin Korenblit @ 2018-04-04 16:31 UTC (permalink / raw)
To: buildroot
This patch installs LLVM tools and libraries for the host and
libLLVM.so for the target.
In order to cross-compile LLVM for the target, LLVM
must be installed on the host, or at least llvm-tblgen.
This is necessary as the path to host's llvm-tblgen must
be specified when cross-compiling using the LLVM_TABLEGEN option.
Also, a version of llvm-config that can run on the host will
be required by packages that link with LLVM libraries, so we
need to generate it and install it in STAGING_DIR/usr/bin.
It is important to remark why we need llvm-config(host variant)
installed in STAGING dir. This tool is necessary to build
applications that use LLVM, as it prints the compiler flags,
linker flags and object libraries needed to link against LLVM libs.
More info: https://bugs.chromium.org/p/chromium/issues/detail?id=219369
The original idea was to compile only llvm-tblgen and llvm-config
for the host, as they are the only necessary components. However,
llvm-config tool does not work as expected if it is not linked with
libLLVM.so, so we must also enable LLVM_LINK_LLVM_DYLIB, what builds
LLVM as a single shared library and links LLVM tools with it.
More info: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224847
in comment #11.
If we don't build full LLVM for the host, it would be necessary to
patch configure.ac from mesa3d if we want dynamic linking, because it
uses llvm-config (host variant installed in STAGING_DIR) to get the
necessary LLVM libraries to link with, which has the following problems:
- llvm-config --shared mode outputs static (even if LLVM is built as
one shared library) which leads to link issues with libgallium.
- llvm-config --libs outputs all LLVM tiny libs: -lLLVMLTO,
-lLLVMPasses,etc instead of the single shared library containing
all LLVM components (-lLLVM-5.0)
Mesa tries to execute: llvm-config --link-shared --libs, but this outputs
llvm-config: error: libLLVM-5.0.so is missing.
Given that these problems may arise with other packages that use LLVM,
it is preferable to do a full build for the host. Also, having a
complete installation of LLVM on the host will also facilitate the
integration of Clang front-end, which is going to be added in a future
patch.
As option LLVM_BUILD_LLVM_DYLIB is enabled for the llvm target variant,
a single shared library containing all LLVM components is built.
This option is not compatible with BUILD_SHARED_LIBS, which generates
one .so per library and is only recommended for use by LLVM developers.
Tools and utils are not built for the target. The patch aims to provide
LLVM support for other packages.
The main options needed to cross-compile LLVM are the following ones:
LLVM_TABLEGEN
CMAKE_CROSSCOMPILING
LLVM_DEFAULT_TARGET_TRIPLE
LLVM_HOST_TRIPLE
LLVM_TARGET_ARCH
LLVM_TARGETS_TO_BUILD
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
DEVELOPERS | 3 +
package/Config.in | 1 +
package/llvm/Config.in | 27 +++++
package/llvm/llvm.hash | 3 +
package/llvm/llvm.mk | 263 +++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 297 insertions(+)
create mode 100644 package/llvm/Config.in
create mode 100644 package/llvm/llvm.hash
create mode 100644 package/llvm/llvm.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index 38e727ecc3..78be8256bc 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1887,6 +1887,9 @@ N: Tzu-Jung Lee <roylee17@gmail.com>
F: package/dropwatch/
F: package/tstools/
+N: Valentin Korenblit <valentin.korenblit@smile.fr>
+F: package/llvm/
+
N: Vanya Sergeev <vsergeev@gmail.com>
F: package/lua-periphery/
diff --git a/package/Config.in b/package/Config.in
index d883909094..82c5c40531 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1545,6 +1545,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"
diff --git a/package/llvm/Config.in b/package/llvm/Config.in
new file mode 100644
index 0000000000..f222b196cb
--- /dev/null
+++ b/package/llvm/Config.in
@@ -0,0 +1,27 @@
+config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+ bool
+ default y if BR2_i386
+ default y if BR2_x86_64
+ default y if BR2_aarch64
+ default y if BR2_arm || BR2_armeb
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH
+ string
+ default "AArch64" if BR2_aarch64
+ default "ARM" if BR2_arm || BR2_armeb
+ default "X86" if BR2_i386 || BR2_x86_64
+
+config BR2_PACKAGE_LLVM
+ bool "llvm"
+ depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+ depends on BR2_HOST_GCC_AT_LEAST_4_8
+ depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
+ help
+ The LLVM Project is a collection of modular and reusable
+ compiler and toolchain technologies.
+
+ http://llvm.org
+
+comment "llvm needs a toolchain w/ gcc >= 4.8, host gcc >= 4.8"
+ depends on !BR2_HOST_GCC_AT_LEAST_4_8 \
+ || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
diff --git a/package/llvm/llvm.hash b/package/llvm/llvm.hash
new file mode 100644
index 0000000000..3e998c4328
--- /dev/null
+++ b/package/llvm/llvm.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 5fa7489fc0225b11821cab0362f5813a05f2bcf2533e8a4ea9c9c860168807b0 llvm-5.0.1.src.tar.xz
+sha256 abd4d8794808bacb1eb6924d49efafd9ab6eef88faaaeb5d3cfa13ee3670d672 LICENSE.TXT
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
new file mode 100644
index 0000000000..525e0f98f8
--- /dev/null
+++ b/package/llvm/llvm.mk
@@ -0,0 +1,263 @@
+################################################################################
+#
+# llvm
+#
+################################################################################
+
+LLVM_VERSION = 5.0.1
+LLVM_SITE = http://llvm.org/releases/$(LLVM_VERSION)
+LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz
+LLVM_LICENSE = NCSA
+LLVM_LICENSE_FILES = LICENSE.TXT
+LLVM_SUPPORTS_IN_SOURCE_BUILD = NO
+LLVM_INSTALL_STAGING = YES
+
+# http://llvm.org/docs/GettingStarted.html#software
+# host-python: Python interpreter 2.7 or newer is required for builds and testing.
+HOST_LLVM_DEPENDENCIES = host-python
+LLVM_DEPENDENCIES = host-llvm
+
+# Don't build clang libcxx libcxxabi lldb compiler-rt lld polly as llvm subprojects
+# This flag assumes that projects are checked out side-by-side and not nested
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PROJECTS=""
+LLVM_CONF_OPTS += -DLLVM_ENABLE_PROJECTS=""
+
+HOST_LLVM_CONF_OPTS += -DLLVM_CCACHE_BUILD=$(if $(BR2_CCACHE),ON,OFF)
+LLVM_CONF_OPTS += -DLLVM_CCACHE_BUILD=$(if $(BR2_CCACHE),ON,OFF)
+
+# Disable experimental Global Instruction Selection support.
+# https://llvm.org/docs/GlobalISel.html
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
+LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
+
+# Get target architecture
+LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
+
+# Build backend for target architecture. This include backends like AMDGPU.
+LLVM_TARGETS_TO_BUILD = $(LLVM_TARGET_ARCH)
+HOST_LLVM_CONF_OPTS = -DLLVM_TARGETS_TO_BUILD="$(subst $(space),;,$(LLVM_TARGETS_TO_BUILD))"
+LLVM_CONF_OPTS = -DLLVM_TARGETS_TO_BUILD="$(subst $(space),;,$(LLVM_TARGETS_TO_BUILD))"
+
+# LLVM target to use for native code generation. This is required for JIT generation.
+# It must be set to LLVM_TARGET_ARCH for host and target, otherwise we get
+# "No available targets are compatible for this triple" with llvmpipe when host
+# and target architectures are different.
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH)
+LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH)
+
+# Use native llvm-tblgen from host-llvm (needed for cross-compilation)
+LLVM_CONF_OPTS += -DLLVM_TABLEGEN=$(HOST_DIR)/bin/llvm-tblgen
+
+# BUILD_SHARED_LIBS has a misleading name. It is in fact an option for
+# LLVM developers to build all LLVM libraries as separate shared libraries.
+# For normal use of LLVM, it is recommended to build a single
+# shared library, which is achieved by BUILD_SHARED_LIBS=OFF and
+# LLVM_BUILD_LLVM_DYLIB=ON.
+HOST_LLVM_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+LLVM_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+
+# Generate libLLVM.so. This library contains a default set of LLVM components
+# that can be overwritten with "LLVM_DYLIB_COMPONENTS". The default contains
+# most of LLVM and is defined in "tools/llvm-shlib/CMakelists.txt".
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_LLVM_DYLIB=ON
+LLVM_CONF_OPTS += -DLLVM_BUILD_LLVM_DYLIB=ON
+
+# LLVM_BUILD_LLVM_DYLIB to ON. We need to enable this option for the
+# host as llvm-config for the host will be used in STAGING_DIR by packages
+# linking against libLLVM and if this option is not selected, then llvm-config
+# does not work properly. For example, it assumes that LLVM is built statically
+# and cannot find libLLVM.so.
+HOST_LLVM_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
+LLVM_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
+
+LLVM_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
+
+# Disabled for the host since no host-libedit.
+# Fall back to "Simple fgets-based implementation" of llvm line editor.
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
+
+# We want to install llvm libraries and modules.
+HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
+LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
+
+# We build from a release archive without vcs files.
+HOST_LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
+LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
+
+# No backtrace package in Buildroot.
+# https://documentation.backtrace.io
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_BACKTRACES=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_BACKTRACES=OFF
+
+# Enable signal handlers overrides support.
+HOST_LLVM_CONF_OPTS += -DENABLE_CRASH_OVERRIDES=ON
+LLVM_CONF_OPTS += -DENABLE_CRASH_OVERRIDES=ON
+
+# Disable ffi for now.
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=OFF
+
+# Disable terminfo database (needs ncurses libtinfo.so)
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_TERMINFO=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_TERMINFO=OFF
+
+# Enable thread support
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON
+LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON
+
+# Enable optional host-zlib support for LLVM Machine Code (llvm-mc) to add
+# compression/uncompression capabilities.
+# Not needed on the target.
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_ZLIB=ON
+HOST_LLVM_DEPENDENCIES += host-zlib
+LLVM_CONF_OPTS += -DLLVM_ENABLE_ZLIB=OFF
+
+# We don't use llvm for static only build, so enable PIC
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PIC=ON
+LLVM_CONF_OPTS += -DLLVM_ENABLE_PIC=ON
+
+# Default is Debug build, which requires considerably more disk space and
+# build time. Release build is selected for host and target because the linker
+# can run out of memory in Debug mode.
+HOST_LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+# Disable C++1y (ISO C++ 2014 standard)
+# Disable C++1z (ISO C++ 2017 standard)
+# Compile llvm with the C++11 (ISO C++ 2011 standard) which is the fallback.
+HOST_LLVM_CONF_OPTS += \
+ -DLLVM_ENABLE_CXX1Y=OFF \
+ -DLLVM_ENABLE_CXX1Z=OFF
+LLVM_CONF_OPTS += \
+ -DLLVM_ENABLE_CXX1Y=OFF \
+ -DLLVM_ENABLE_CXX1Z=OFF
+
+# Disabled, requires sys/ndir.h header
+# Disable debug in module
+HOST_LLVM_CONF_OPTS += \
+ -DLLVM_ENABLE_MODULES=OFF \
+ -DLLVM_ENABLE_MODULE_DEBUGGING=OFF
+LLVM_CONF_OPTS += \
+ -DLLVM_ENABLE_MODULES=OFF \
+ -DLLVM_ENABLE_MODULE_DEBUGGING=OFF
+
+# Don't change the standard library to libc++.
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBCXX=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBCXX=OFF
+
+# Don't use lld as a linker.
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LLD=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_LLD=OFF
+
+# Generate code for the target. LLVM selects a target by looking at the
+# toolchain tuple
+HOST_LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+
+# LLVM_HOST_TRIPLE has a misleading name, it is in fact the triple of the
+# system where llvm is going to run on. We need to specify triple for native
+# code generation on the target.
+# This solves "No available targets are compatible for this triple" with llvmpipe
+LLVM_CONF_OPTS += -DLLVM_HOST_TRIPLE=$(GNU_TARGET_NAME)
+
+# The Go bindings have no CMake rules at the moment, but better remove the
+# check preventively. Building the Go and OCaml bindings is yet unsupported.
+HOST_LLVM_CONF_OPTS += \
+ -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \
+ -DOCAMLFIND=OCAMLFIND-NOTFOUND
+
+# Builds a release host tablegen that gets used during the LLVM build.
+HOST_LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
+
+# Keep llvm utility binaries for the host. llvm-tblgen is built anyway as
+# CMakeLists.txt has add_subdirectory(utils/TableGen) unconditionally.
+HOST_LLVM_CONF_OPTS += \
+ -DLLVM_BUILD_UTILS=ON \
+ -DLLVM_INCLUDE_UTILS=ON \
+ -DLLVM_INSTALL_UTILS=ON
+LLVM_CONF_OPTS += \
+ -DLLVM_BUILD_UTILS=OFF \
+ -DLLVM_INCLUDE_UTILS=OFF \
+ -DLLVM_INSTALL_UTILS=OFF
+
+HOST_LLVM_CONF_OPTS += \
+ -DLLVM_INCLUDE_TOOLS=ON \
+ -DLLVM_BUILD_TOOLS=ON
+
+# We need to activate LLVM_INCLUDE_TOOLS, otherwise it does not generate
+# libLLVM.so
+LLVM_CONF_OPTS += \
+ -DLLVM_INCLUDE_TOOLS=ON \
+ -DLLVM_BUILD_TOOLS=OFF
+
+# Compiler-rt not in the source tree.
+# llvm runtime libraries are not in the source tree.
+# Polly is not in the source tree.
+HOST_LLVM_CONF_OPTS += \
+ -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF \
+ -DLLVM_BUILD_RUNTIME=OFF \
+ -DLLVM_INCLUDE_RUNTIMES=OFF \
+ -DLLVM_POLLY_BUILD=OFF
+LLVM_CONF_OPTS += \
+ -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF \
+ -DLLVM_BUILD_RUNTIME=OFF \
+ -DLLVM_INCLUDE_RUNTIMES=OFF \
+ -DLLVM_POLLY_BUILD=OFF
+
+HOST_LLVM_CONF_OPTS += \
+ -DLLVM_ENABLE_WARNINGS=ON \
+ -DLLVM_ENABLE_PEDANTIC=ON \
+ -DLLVM_ENABLE_WERROR=OFF
+LLVM_CONF_OPTS += \
+ -DLLVM_ENABLE_WARNINGS=ON \
+ -DLLVM_ENABLE_PEDANTIC=ON \
+ -DLLVM_ENABLE_WERROR=OFF
+
+HOST_LLVM_CONF_OPTS += \
+ -DLLVM_BUILD_EXAMPLES=OFF \
+ -DLLVM_BUILD_DOCS=OFF \
+ -DLLVM_BUILD_TESTS=OFF \
+ -DLLVM_ENABLE_DOXYGEN=OFF \
+ -DLLVM_ENABLE_OCAMLDOC=OFF \
+ -DLLVM_ENABLE_SPHINX=OFF \
+ -DLLVM_INCLUDE_EXAMPLES=OFF \
+ -DLLVM_INCLUDE_DOCS=OFF \
+ -DLLVM_INCLUDE_GO_TESTS=OFF \
+ -DLLVM_INCLUDE_TESTS=OFF
+LLVM_CONF_OPTS += \
+ -DLLVM_BUILD_EXAMPLES=OFF \
+ -DLLVM_BUILD_DOCS=OFF \
+ -DLLVM_BUILD_TESTS=OFF \
+ -DLLVM_ENABLE_DOXYGEN=OFF \
+ -DLLVM_ENABLE_OCAMLDOC=OFF \
+ -DLLVM_ENABLE_SPHINX=OFF \
+ -DLLVM_INCLUDE_EXAMPLES=OFF \
+ -DLLVM_INCLUDE_DOCS=OFF \
+ -DLLVM_INCLUDE_GO_TESTS=OFF \
+ -DLLVM_INCLUDE_TESTS=OFF
+
+# Copy llvm-config (host variant) to STAGING_DIR
+# llvm-config (host variant) returns include and lib directories
+# for the host if it's installed in host/bin:
+# output/host/bin/llvm-config --includedir
+# output/host/include
+# When installed in STAGING_DIR, llvm-config returns include and lib
+# directories from STAGING_DIR.
+# output/staging/usr/bin/llvm-config --includedir
+# output/staging/usr/include
+define HOST_LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
+ $(INSTALL) -D -m 0755 $(HOST_DIR)/bin/llvm-config \
+ $(STAGING_DIR)/usr/bin/llvm-config
+endef
+HOST_LLVM_POST_INSTALL_HOOKS = HOST_LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
+
+# By default llvm-tblgen is built and installed on the target but it is
+# not necessary.
+define LLVM_DELETE_LLVM_TBLGEN_TARGET
+ rm -f $(TARGET_DIR)/usr/bin/llvm-tblgen
+endef
+LLVM_POST_INSTALL_TARGET_HOOKS = LLVM_DELETE_LLVM_TBLGEN_TARGET
+
+$(eval $(cmake-package))
+$(eval $(host-cmake-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread* [Buildroot] [PATCH v5 1/7] package/llvm: new package
2018-04-04 16:31 ` [Buildroot] [PATCH v5 1/7] package/llvm: new package Valentin Korenblit
@ 2018-04-04 20:50 ` Thomas Petazzoni
2018-04-04 21:20 ` Romain Naour
0 siblings, 1 reply; 14+ messages in thread
From: Thomas Petazzoni @ 2018-04-04 20:50 UTC (permalink / raw)
To: buildroot
Hello,
On Wed, 4 Apr 2018 18:31:18 +0200, Valentin Korenblit wrote:
> This patch installs LLVM tools and libraries for the host and
> libLLVM.so for the target.
I've applied to master, after doing the following changes:
[Thomas:
- add dependency on thread and C++ and update the Config.in comment
accordingly.
- make the Config.in comment depend on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
so that it isn't disabled on architectures where LLVM is anyway not
supported.]
Also, I noticed it doesn't build on the Cortex-M4 configuration, i.e
the following defconfig doesn't build:
BR2_arm=y
BR2_cortex_m4=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-cortex-m4-full-2017.11-rc1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_13=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_NPTL is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_LLVM=y
Even though I don't think it makes sense to support Cortex-M4 (and is
probably not possible anyway), the error is interesting:
-- Looking for __atomic_load_8 in atomic
-- Looking for __atomic_load_8 in atomic - not found
CMake Error at cmake/modules/CheckAtomic.cmake:74 (message):
Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
cmake/config-ix.cmake:326 (include)
CMakeLists.txt:580 (include)
So LLVM uses atomic built-ins, so probably it needs to "depends on
BR2_TOOLCHAIN_HAS_ATOMIC", and link against libatomic if
BR2_TOOLCHAIN_HAS_LIBATOMIC is defined.
Please watch for the autobuilders in the next few days, and look at the
LLVM build failures. You will anyway be notified every day of such
failures by e-mail, now that you are listed in the DEVELOPERS file.
Thanks a lot Valentin for your persistence on this LLVM work. I'm sure
it will be very useful in the future, and it was a major endeavor!
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 14+ messages in thread* [Buildroot] [PATCH v5 1/7] package/llvm: new package
2018-04-04 20:50 ` Thomas Petazzoni
@ 2018-04-04 21:20 ` Romain Naour
0 siblings, 0 replies; 14+ messages in thread
From: Romain Naour @ 2018-04-04 21:20 UTC (permalink / raw)
To: buildroot
Hi Valentin, All,
Le 04/04/2018 ? 22:50, Thomas Petazzoni a ?crit?:
> Hello,
>
> On Wed, 4 Apr 2018 18:31:18 +0200, Valentin Korenblit wrote:
>> This patch installs LLVM tools and libraries for the host and
>> libLLVM.so for the target.
[...]
>
> Thanks a lot Valentin for your persistence on this LLVM work. I'm sure
> it will be very useful in the future, and it was a major endeavor!
Congratulation Valentin!
I know it was a really ambitious task to take over llvm patch series for your
internship at Smile.
Next step: clang and opencl :)
See you tomorrow at work!
Best regards,
Romain
>
> Best regards,
>
> Thomas
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Buildroot] [PATCH v5 2/7] package/llvm: enable AMDGPU
2018-04-04 16:31 [Buildroot] [PATCH v5 0/7] llvm for mesa3d Valentin Korenblit
2018-04-04 16:31 ` [Buildroot] [PATCH v5 1/7] package/llvm: new package Valentin Korenblit
@ 2018-04-04 16:31 ` Valentin Korenblit
2018-04-04 20:52 ` Thomas Petazzoni
2018-04-04 16:31 ` [Buildroot] [PATCH v5 3/7] package/mesa3d: enable llvm support Valentin Korenblit
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Valentin Korenblit @ 2018-04-04 16:31 UTC (permalink / raw)
To: buildroot
The AMDGPU backend provides ISA code generation for AMD GPU's,
starting with the R600 family up until the current GCN families.
It should not be confused with the AMDGPU Linux kernel DRM driver.
For more info: https://llvm.org/docs/AMDGPUUsage.html
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
Tested-by: J?r?me Oufella <jerome.oufella@savoirfairelinux.com>
---
Tested on HD6480 using Gallium Radeon R600 driver.
package/llvm/Config.in | 10 ++++++++++
package/llvm/llvm.mk | 9 +++++++++
2 files changed, 19 insertions(+)
diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index f222b196cb..41e8e940bb 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -22,6 +22,16 @@ config BR2_PACKAGE_LLVM
http://llvm.org
+if BR2_PACKAGE_LLVM
+
+config BR2_PACKAGE_LLVM_AMDGPU
+ bool "AMDGPU backend"
+ help
+ Build AMDGPU target. Select this option if you are going
+ to install mesa3d with llvm and use Gallium Radeon driver.
+
+endif
+
comment "llvm needs a toolchain w/ gcc >= 4.8, host gcc >= 4.8"
depends on !BR2_HOST_GCC_AT_LEAST_4_8 \
|| !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 525e0f98f8..9c8bf5c820 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -45,6 +45,15 @@ LLVM_CONF_OPTS = -DLLVM_TARGETS_TO_BUILD="$(subst $(space),;,$(LLVM_TARGETS_TO_B
HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH)
LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH)
+# Build AMDGPU backend
+# We need to build AMDGPU backend for both host and target because
+# llvm-config --targets built (host variant installed in STAGING) will
+# output only $(LLVM_TARGET_ARCH) if not, and mesa3d won't build as
+# it thinks AMDGPU backend is not installed on the target.
+ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
+LLVM_TARGETS_TO_BUILD += AMDGPU
+endif
+
# Use native llvm-tblgen from host-llvm (needed for cross-compilation)
LLVM_CONF_OPTS += -DLLVM_TABLEGEN=$(HOST_DIR)/bin/llvm-tblgen
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread* [Buildroot] [PATCH v5 3/7] package/mesa3d: enable llvm support
2018-04-04 16:31 [Buildroot] [PATCH v5 0/7] llvm for mesa3d Valentin Korenblit
2018-04-04 16:31 ` [Buildroot] [PATCH v5 1/7] package/llvm: new package Valentin Korenblit
2018-04-04 16:31 ` [Buildroot] [PATCH v5 2/7] package/llvm: enable AMDGPU Valentin Korenblit
@ 2018-04-04 16:31 ` Valentin Korenblit
2018-04-04 20:52 ` Thomas Petazzoni
2018-04-04 16:31 ` [Buildroot] [PATCH v5 4/7] package/clang: new package Valentin Korenblit
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Valentin Korenblit @ 2018-04-04 16:31 UTC (permalink / raw)
To: buildroot
This patch provides LLVM support for Mesa3D, enabling llvmpipe
software rasterizer if Gallium swrast is selected.
In case Gallium r600 is selected, llvm AMDGPU backend is built.
Having llvm installed also enables radeonsi Gallium driver, but
it is not provided with this patch as it hasn't been tested.
It uses llvm-config (host variant) installed in STAGING_DIR/usr/bin
to get LLVM libraries. Assuming that LLVM version 5.0.1 is installed,
llvm-config --libs will output -lLLVM-5.0.
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
Tested-by: J?r?me Oufella <jerome.oufella@savoirfairelinux.com>
---
llvmpipe tested running glmark2-es2 on x86, ARM and Aarch64
package/mesa3d/Config.in | 6 ++++++
package/mesa3d/mesa3d.mk | 14 +++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
index f141587c4d..ffe0287ac5 100644
--- a/package/mesa3d/Config.in
+++ b/package/mesa3d/Config.in
@@ -25,6 +25,11 @@ menuconfig BR2_PACKAGE_MESA3D
if BR2_PACKAGE_MESA3D
+config BR2_PACKAGE_MESA3D_LLVM
+ bool "llvm support"
+ depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+ select BR2_PACKAGE_LLVM
+
# inform the .mk file of gallium, dri or vulkan driver selection
config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
bool
@@ -77,6 +82,7 @@ config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600
depends on BR2_i386 || BR2_x86_64
select BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
select BR2_PACKAGE_LIBDRM_RADEON
+ select BR2_PACKAGE_LLVM_AMDGPU if BR2_PACKAGE_MESA3D_LLVM
select BR2_PACKAGE_MESA3D_NEEDS_XA
help
Driver for ATI/AMD Radeon R600/R700/HD5000/HD6000 GPUs.
diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
index 1d88fd8480..506f84274f 100644
--- a/package/mesa3d/mesa3d.mk
+++ b/package/mesa3d/mesa3d.mk
@@ -32,6 +32,17 @@ ifeq ($(BR2_SHARED_STATIC_LIBS),y)
MESA3D_CONF_OPTS += --disable-static
endif
+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 += --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.
@@ -219,7 +230,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))
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread* [Buildroot] [PATCH v5 3/7] package/mesa3d: enable llvm support
2018-04-04 16:31 ` [Buildroot] [PATCH v5 3/7] package/mesa3d: enable llvm support Valentin Korenblit
@ 2018-04-04 20:52 ` Thomas Petazzoni
0 siblings, 0 replies; 14+ messages in thread
From: Thomas Petazzoni @ 2018-04-04 20:52 UTC (permalink / raw)
To: buildroot
Hello,
On Wed, 4 Apr 2018 18:31:20 +0200, Valentin Korenblit wrote:
> This patch provides LLVM support for Mesa3D, enabling llvmpipe
> software rasterizer if Gallium swrast is selected.
>
> In case Gallium r600 is selected, llvm AMDGPU backend is built.
>
> Having llvm installed also enables radeonsi Gallium driver, but
> it is not provided with this patch as it hasn't been tested.
>
> It uses llvm-config (host variant) installed in STAGING_DIR/usr/bin
> to get LLVM libraries. Assuming that LLVM version 5.0.1 is installed,
> llvm-config --libs will output -lLLVM-5.0.
>
> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
> Tested-by: J?r?me Oufella <jerome.oufella@savoirfairelinux.com>
> ---
Applied to master, thanks.
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Buildroot] [PATCH v5 4/7] package/clang: new package
2018-04-04 16:31 [Buildroot] [PATCH v5 0/7] llvm for mesa3d Valentin Korenblit
` (2 preceding siblings ...)
2018-04-04 16:31 ` [Buildroot] [PATCH v5 3/7] package/mesa3d: enable llvm support Valentin Korenblit
@ 2018-04-04 16:31 ` Valentin Korenblit
2018-04-05 19:36 ` Matthew Weber
2018-04-04 16:31 ` [Buildroot] [PATCH v5 5/7] package/libclc: " Valentin Korenblit
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Valentin Korenblit @ 2018-04-04 16:31 UTC (permalink / raw)
To: buildroot
This patch provides Clang tools and libraries for the host and libclang
for the target.
Clang is needed to build libclc, which is also provided in a follup patch.
We need libclang for the target because it is used by most of OpenCL implementations.
A later patch in this series will enable Clover, the OpenCl implementation part
of Mesa3D, which requires libclang.
clang-tblgen must be copied to HOST_DIR as it is not installed by default but is needed
for cross-compilation: http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.html
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
DEVELOPERS | 1 +
package/Config.in | 1 +
package/clang/Config.in | 9 ++++++
package/clang/clang.hash | 3 ++
package/clang/clang.mk | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 85 insertions(+)
create mode 100644 package/clang/Config.in
create mode 100644 package/clang/clang.hash
create mode 100644 package/clang/clang.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index 78be8256bc..72303992c2 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1888,6 +1888,7 @@ F: package/dropwatch/
F: package/tstools/
N: Valentin Korenblit <valentin.korenblit@smile.fr>
+F: package/clang/
F: package/llvm/
N: Vanya Sergeev <vsergeev@gmail.com>
diff --git a/package/Config.in b/package/Config.in
index 82c5c40531..b358e39c3f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1479,6 +1479,7 @@ menu "Other"
source "package/bctoolbox/Config.in"
source "package/bdwgc/Config.in"
source "package/boost/Config.in"
+ source "package/clang/Config.in"
source "package/clapack/Config.in"
source "package/classpath/Config.in"
source "package/cppcms/Config.in"
diff --git a/package/clang/Config.in b/package/clang/Config.in
new file mode 100644
index 0000000000..269766da1e
--- /dev/null
+++ b/package/clang/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_CLANG
+ bool "clang"
+ depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+ select BR2_PACKAGE_LLVM
+ help
+ Clang is a C/C++, Objective C/C++ and OpenCL C front-end
+ for the LLVM compiler.
+
+ http://clang.llvm.org
diff --git a/package/clang/clang.hash b/package/clang/clang.hash
new file mode 100644
index 0000000000..a5bf909814
--- /dev/null
+++ b/package/clang/clang.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 135f6c9b0cd2da1aff2250e065946258eb699777888df39ca5a5b4fe5e23d0ff cfe-5.0.1.src.tar.xz
+sha256 de4c79665f0f5688b0ace17cba6f8e0343925bb95e0949d66d47bbd4527310d6 LICENSE.TXT
diff --git a/package/clang/clang.mk b/package/clang/clang.mk
new file mode 100644
index 0000000000..7535782436
--- /dev/null
+++ b/package/clang/clang.mk
@@ -0,0 +1,71 @@
+################################################################################
+#
+# clang
+#
+################################################################################
+
+CLANG_VERSION = 5.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
+CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
+CLANG_INSTALL_STAGING = YES
+
+HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
+CLANG_DEPENDENCIES = llvm host-clang
+
+# This option is needed. Otherwise multiple shared libs (libclangAST.so,
+# libclangBasic.so, libclangFrontend.so, etc.) will be generated. As a final
+# shared lib containing all these components (libclang.so) is also generated, this
+# resulted in the following error when trying to use tools that use libclang:
+# $ CommandLine Error: Option 'track-memory' registered more than once!
+# $ LLVM ERROR: inconsistency in registered CommandLine options
+# By setting BUILD_SHARED_LIBS to OFF, we generate multiple static libraries
+# (the same way as host's clang build) and finally libclang.so to be installed on the
+# target.
+CLANG_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+
+# Default is Debug build, which requires considerably more disk space and
+# build time. Release build is selected for host and target because the linker
+# can run out of memory in Debug mode.
+HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
+
+# We need to build tools because libclang is a tool
+HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
+CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
+
+HOST_CLANG_CONF_OPTS += \
+ -DCLANG_BUILD_EXAMPLES=OFF \
+ -DCLANG_INCLUDE_DOCS=OFF \
+ -DCLANG_INCLUDE_TESTS=OFF
+
+CLANG_CONF_OPTS += \
+ -DCLANG_BUILD_EXAMPLES=OFF \
+ -DCLANG_INCLUDE_DOCS=OFF \
+ -DCLANG_INCLUDE_TESTS=OFF
+
+HOST_CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(HOST_DIR)/bin/llvm-config
+CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(STAGING_DIR)/usr/bin/llvm-config \
+ -DCLANG_TABLEGEN:FILEPATH=$(HOST_DIR)/usr/bin/clang-tblgen
+
+# Clang can't be used as compiler on the target since there are no development files
+# (headers) and other build tools. So remove clang binaries from target.
+define CLANG_DELETE_BINARIES_FROM_TARGET
+ rm -f $(TARGET_DIR)/usr/bin/clang*
+endef
+CLANG_POST_INSTALL_TARGET_HOOKS += CLANG_DELETE_BINARIES_FROM_TARGET
+
+# clang-tblgen is not installed by default, however it is necessary for
+# cross-compiling clang
+define HOST_CLANG_INSTALL_CLANG_TBLGEN
+ $(INSTALL) -D -m 0755 $(HOST_CLANG_BUILDDIR)/bin/clang-tblgen \
+ $(HOST_DIR)/usr/bin/clang-tblgen
+endef
+HOST_CLANG_POST_INSTALL_HOOKS = HOST_CLANG_INSTALL_CLANG_TBLGEN
+
+$(eval $(cmake-package))
+$(eval $(host-cmake-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread* [Buildroot] [PATCH v5 5/7] package/libclc: new package
2018-04-04 16:31 [Buildroot] [PATCH v5 0/7] llvm for mesa3d Valentin Korenblit
` (3 preceding siblings ...)
2018-04-04 16:31 ` [Buildroot] [PATCH v5 4/7] package/clang: new package Valentin Korenblit
@ 2018-04-04 16:31 ` Valentin Korenblit
2018-04-07 15:35 ` Romain Naour
2018-04-04 16:31 ` [Buildroot] [PATCH v5 6/7] package/mesa3d: enable OpenCL support Valentin Korenblit
2018-04-04 16:31 ` [Buildroot] [PATCH v5 7/7] package/clinfo: new package Valentin Korenblit
6 siblings, 1 reply; 14+ messages in thread
From: Valentin Korenblit @ 2018-04-04 16:31 UTC (permalink / raw)
To: buildroot
This patch provides libclc, an open source implementation of the
library requirements of the OpenCL C programming language, as
specified by the OpenCL 1.1 Specification. It is intended to be used
with Mesa Clover.
It needs to be compiled with Clang, as it generates LLVM IR bitcode
files containing device builtin functions for each target.
Currently, libclc supports AMDGCN, R600 and NVPTX targets.
As OpenCL kernels are built dynamically on the target using libclang and
libLLVM, it is necessary to copy /usr/include/clc from STAGING_DIR to the
target manually, as Buildroot doesn't include this directory.
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
This patch should not yet be applied, we must first find a place
where clc headers can be stored.
DEVELOPERS | 1 +
package/Config.in | 1 +
package/libclc/Config.in | 9 +++++++++
package/libclc/libclc.hash | 3 +++
package/libclc/libclc.mk | 41 +++++++++++++++++++++++++++++++++++++++++
5 files changed, 55 insertions(+)
create mode 100644 package/libclc/Config.in
create mode 100644 package/libclc/libclc.hash
create mode 100644 package/libclc/libclc.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index 72303992c2..ec8f73681a 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1889,6 +1889,7 @@ F: package/tstools/
N: Valentin Korenblit <valentin.korenblit@smile.fr>
F: package/clang/
+F: package/libclc/
F: package/llvm/
N: Vanya Sergeev <vsergeev@gmail.com>
diff --git a/package/Config.in b/package/Config.in
index b358e39c3f..3cd979661f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -281,6 +281,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"
diff --git a/package/libclc/Config.in b/package/libclc/Config.in
new file mode 100644
index 0000000000..797f090bfc
--- /dev/null
+++ b/package/libclc/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_LIBCLC
+ bool "libclc"
+ depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+ help
+ libclc is an open source, BSD licensed implementation of
+ the library requirements of the OpenCL C programming language,
+ as specified by the OpenCL 1.1 Specification.
+
+ http://libclc.llvm.org/
diff --git a/package/libclc/libclc.hash b/package/libclc/libclc.hash
new file mode 100644
index 0000000000..c5bf5a668c
--- /dev/null
+++ b/package/libclc/libclc.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 e2f1f294f93695f2d1f87ccb9760231b435702dd0c27abeb38baa97186674d9e libclc-00236279a293b3737dee08c14f25923a889d2795.tar.gz
+sha256 c66aa55d8478b45f1018500af9f433dd271444ad304d683dd49ff2a42f30dad1 LICENSE.TXT
diff --git a/package/libclc/libclc.mk b/package/libclc/libclc.mk
new file mode 100644
index 0000000000..35a69ea360
--- /dev/null
+++ b/package/libclc/libclc.mk
@@ -0,0 +1,41 @@
+################################################################################
+#
+# libclc
+#
+################################################################################
+
+# There are only two releases: release_35 and release_38, but the last
+# commit is from 2 years ago. Master has some recent activity.
+LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
+LIBCLC_SITE = https://git.llvm.org/git/libclc
+LIBCLC_SITE_METHOD = git
+LIBCLC_LICENSE = NCSA
+LIBCLC_LICENSE_FILES = LICENSE.TXT
+
+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 built with the C++ compiler from the host
+LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
+ --prefix="/usr" \
+ --pkgconfigdir="/usr/lib/pkgconfig" \
+ --with-cxx-compiler=$(HOSTCXX)
+
+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))
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread* [Buildroot] [PATCH v5 5/7] package/libclc: new package
2018-04-04 16:31 ` [Buildroot] [PATCH v5 5/7] package/libclc: " Valentin Korenblit
@ 2018-04-07 15:35 ` Romain Naour
0 siblings, 0 replies; 14+ messages in thread
From: Romain Naour @ 2018-04-07 15:35 UTC (permalink / raw)
To: buildroot
Hi all,
Le 04/04/2018 ? 18:31, Valentin Korenblit a ?crit?:
> This patch provides libclc, an open source implementation of the
> library requirements of the OpenCL C programming language, as
> specified by the OpenCL 1.1 Specification. It is intended to be used
> with Mesa Clover.
>
> It needs to be compiled with Clang, as it generates LLVM IR bitcode
> files containing device builtin functions for each target.
>
> Currently, libclc supports AMDGCN, R600 and NVPTX targets.
>
> As OpenCL kernels are built dynamically on the target using libclang and
> libLLVM, it is necessary to copy /usr/include/clc from STAGING_DIR to the
> target manually, as Buildroot doesn't include this directory.
>
> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
> ---
>
> This patch should not yet be applied, we must first find a place
> where clc headers can be stored.
I'll mark remaining patches of this series "Changes requested" since Valentin is
working on a v6 of this series, taking into account the llvm dependencies
recently added and some other fixes.
Also he will try to find a workaround for the clc headers.
For now, clc headers must be copied to /usr/include/clc but this location is
removed by Buildroot at the end of the build.
Best regards,
Romain
>
> DEVELOPERS | 1 +
> package/Config.in | 1 +
> package/libclc/Config.in | 9 +++++++++
> package/libclc/libclc.hash | 3 +++
> package/libclc/libclc.mk | 41 +++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 55 insertions(+)
> create mode 100644 package/libclc/Config.in
> create mode 100644 package/libclc/libclc.hash
> create mode 100644 package/libclc/libclc.mk
>
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 72303992c2..ec8f73681a 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1889,6 +1889,7 @@ F: package/tstools/
>
> N: Valentin Korenblit <valentin.korenblit@smile.fr>
> F: package/clang/
> +F: package/libclc/
> F: package/llvm/
>
> N: Vanya Sergeev <vsergeev@gmail.com>
> diff --git a/package/Config.in b/package/Config.in
> index b358e39c3f..3cd979661f 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -281,6 +281,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"
> diff --git a/package/libclc/Config.in b/package/libclc/Config.in
> new file mode 100644
> index 0000000000..797f090bfc
> --- /dev/null
> +++ b/package/libclc/Config.in
> @@ -0,0 +1,9 @@
> +config BR2_PACKAGE_LIBCLC
> + bool "libclc"
> + depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> + help
> + libclc is an open source, BSD licensed implementation of
> + the library requirements of the OpenCL C programming language,
> + as specified by the OpenCL 1.1 Specification.
> +
> + http://libclc.llvm.org/
> diff --git a/package/libclc/libclc.hash b/package/libclc/libclc.hash
> new file mode 100644
> index 0000000000..c5bf5a668c
> --- /dev/null
> +++ b/package/libclc/libclc.hash
> @@ -0,0 +1,3 @@
> +# locally calculated
> +sha256 e2f1f294f93695f2d1f87ccb9760231b435702dd0c27abeb38baa97186674d9e libclc-00236279a293b3737dee08c14f25923a889d2795.tar.gz
> +sha256 c66aa55d8478b45f1018500af9f433dd271444ad304d683dd49ff2a42f30dad1 LICENSE.TXT
> diff --git a/package/libclc/libclc.mk b/package/libclc/libclc.mk
> new file mode 100644
> index 0000000000..35a69ea360
> --- /dev/null
> +++ b/package/libclc/libclc.mk
> @@ -0,0 +1,41 @@
> +################################################################################
> +#
> +# libclc
> +#
> +################################################################################
> +
> +# There are only two releases: release_35 and release_38, but the last
> +# commit is from 2 years ago. Master has some recent activity.
> +LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
> +LIBCLC_SITE = https://git.llvm.org/git/libclc
> +LIBCLC_SITE_METHOD = git
> +LIBCLC_LICENSE = NCSA
> +LIBCLC_LICENSE_FILES = LICENSE.TXT
> +
> +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 built with the C++ compiler from the host
> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> + --prefix="/usr" \
> + --pkgconfigdir="/usr/lib/pkgconfig" \
> + --with-cxx-compiler=$(HOSTCXX)
> +
> +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))
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Buildroot] [PATCH v5 6/7] package/mesa3d: enable OpenCL support
2018-04-04 16:31 [Buildroot] [PATCH v5 0/7] llvm for mesa3d Valentin Korenblit
` (4 preceding siblings ...)
2018-04-04 16:31 ` [Buildroot] [PATCH v5 5/7] package/libclc: " Valentin Korenblit
@ 2018-04-04 16:31 ` Valentin Korenblit
2018-04-04 16:31 ` [Buildroot] [PATCH v5 7/7] package/clinfo: new package Valentin Korenblit
6 siblings, 0 replies; 14+ messages in thread
From: Valentin Korenblit @ 2018-04-04 16:31 UTC (permalink / raw)
To: buildroot
This patch provides Clover, the OpenCL 1.1 API implementation by Mesa
for AMD GPUs. It generates libOpenCL.so.
Add --disable-opencl-icd because int Mesa 18 defaults to on. When
disabled, the shared library is named libOpenCL instead of libMesaOpenCL
and CL headers are installed.
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
Tested with AMD Radeon Dual (AMD SUMO + AMD CAICOS) using Gallium r600:
Piglit taken from Romain Naour's patch, setting -DPIGLIT_BUILD_CL_TESTS=ON:
http://lists.busybox.net/pipermail/buildroot/2018-February/213601.html
Results from 704 tests:
skip 94
pass 541
fail 60
crash 9
Opencl-example (100% pass):
https://cgit.freedesktop.org/~tstellar/opencl-example/
package/mesa3d/Config.in | 17 +++++++++++++++++
package/mesa3d/mesa3d.mk | 10 ++++++++++
2 files changed, 27 insertions(+)
diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
index ffe0287ac5..600f9ffdda 100644
--- a/package/mesa3d/Config.in
+++ b/package/mesa3d/Config.in
@@ -30,6 +30,23 @@ config BR2_PACKAGE_MESA3D_LLVM
depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
select BR2_PACKAGE_LLVM
+config BR2_PACKAGE_MESA3D_OPENCL
+ bool "opencl support"
+ depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600
+ depends on BR2_PACKAGE_MESA3D_LLVM
+ depends on BR2_USE_WCHAR # elfutils
+ depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC
+ depends on !BR2_bfin # elfutils
+ select BR2_PACKAGE_CLANG
+ 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
diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
index 506f84274f..0d00b3f1b9 100644
--- a/package/mesa3d/mesa3d.mk
+++ b/package/mesa3d/mesa3d.mk
@@ -230,4 +230,14 @@ else
MESA3D_CONF_OPTS += --disable-lmsensors
endif
+# Clover requires libelf
+ifeq ($(BR2_PACKAGE_MESA3D_OPENCL),y)
+MESA3D_DEPENDENCIES += clang elfutils libclc
+MESA3D_CONF_OPTS += --enable-opencl \
+ --disable-opencl-icd \
+ --with-clang-libdir=$(STAGING_DIR)/usr/lib
+else
+MESA3D_CONF_OPTS += --disable-opencl
+endif
+
$(eval $(autotools-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread* [Buildroot] [PATCH v5 7/7] package/clinfo: new package
2018-04-04 16:31 [Buildroot] [PATCH v5 0/7] llvm for mesa3d Valentin Korenblit
` (5 preceding siblings ...)
2018-04-04 16:31 ` [Buildroot] [PATCH v5 6/7] package/mesa3d: enable OpenCL support Valentin Korenblit
@ 2018-04-04 16:31 ` Valentin Korenblit
6 siblings, 0 replies; 14+ messages in thread
From: Valentin Korenblit @ 2018-04-04 16:31 UTC (permalink / raw)
To: buildroot
This tool allows to verify if the OpenCL environment is set up correctly and
output information related to the supported OpenCL platforms.
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
DEVELOPERS | 1 +
package/Config.in | 1 +
package/clinfo/Config.in | 9 +++++++++
package/clinfo/clinfo.hash | 2 ++
package/clinfo/clinfo.mk | 23 +++++++++++++++++++++++
5 files changed, 36 insertions(+)
create mode 100644 package/clinfo/Config.in
create mode 100644 package/clinfo/clinfo.hash
create mode 100644 package/clinfo/clinfo.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index ec8f73681a..3312233fc3 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1889,6 +1889,7 @@ F: package/tstools/
N: Valentin Korenblit <valentin.korenblit@smile.fr>
F: package/clang/
+F: package/clinfo/
F: package/libclc/
F: package/llvm/
diff --git a/package/Config.in b/package/Config.in
index 3cd979661f..69af4aa15e 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1483,6 +1483,7 @@ menu "Other"
source "package/clang/Config.in"
source "package/clapack/Config.in"
source "package/classpath/Config.in"
+ source "package/clinfo/Config.in"
source "package/cppcms/Config.in"
source "package/cracklib/Config.in"
source "package/dawgdic/Config.in"
diff --git a/package/clinfo/Config.in b/package/clinfo/Config.in
new file mode 100644
index 0000000000..279b5acbfb
--- /dev/null
+++ b/package/clinfo/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_CLINFO
+ bool "clinfo"
+ depends on BR2_PACKAGE_MESA3D_OPENCL
+ help
+ clinfo is a simple command-line application that enumerates
+ all possible (known) properties of the OpenCL platform and
+ devices available on the system.
+
+ https://github.com/Oblomov/clinfo
diff --git a/package/clinfo/clinfo.hash b/package/clinfo/clinfo.hash
new file mode 100644
index 0000000000..e1c10afc9e
--- /dev/null
+++ b/package/clinfo/clinfo.hash
@@ -0,0 +1,2 @@
+# locally calculated
+sha256 64b02e68ccff3b95437bd0bd70dcb88438c58adec16a7145a5d4e5c26a898ccf clinfo-2.2.18.03.26.tar.gz
diff --git a/package/clinfo/clinfo.mk b/package/clinfo/clinfo.mk
new file mode 100644
index 0000000000..1477b76946
--- /dev/null
+++ b/package/clinfo/clinfo.mk
@@ -0,0 +1,23 @@
+################################################################################
+#
+# clinfo
+#
+################################################################################
+
+CLINFO_VERSION = 2.2.18.03.26
+CLINFO_SITE = $(call github,Oblomov,clinfo,$(CLINFO_VERSION))
+CLINFO_LICENSE = CC0-1.0
+CLINFO_LICENSE_FILES = legalcode.txt
+
+# libOpenCL is needed
+CLINFO_DEPENDENCIES = mesa3d
+
+define CLINFO_BUILD_CMDS
+ $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
+endef
+
+define CLINFO_INSTALL_TARGET_CMDS
+ $(INSTALL) -D -m 755 $(@D)/clinfo $(TARGET_DIR)/usr/bin/clinfo
+endef
+
+$(eval $(generic-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 14+ messages in thread