All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v4 00/11] llvm for mesa3d
@ 2018-03-29 11:33 Valentin Korenblit
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 01/11] package/llvm: new host package Valentin Korenblit
                   ` (10 more replies)
  0 siblings, 11 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

Hello all,

This series provides llvm support for Mesa 3D:


Changes v1 -> v2:

The series has been simplified:

*Build only backend for target architecture by default.
*Support for AMDGPU(PATCH 3/4 in v1) was removed because I cannot test
it currently. 
*Host: make options modified to build only llvm-config and llvm-tblgen
(reduces drastically build time for host).
*Target: support only x86 currently (tested), I will test on ARM soon.

Changes v2 -> v3:

* Full installation of LLVM (tools and libLLVM.so) for the host.
* Disable Mesa 3D static linking, it now links with shared lib.
* Options to disable building each tool one by one were removed.
* Support for AMDGPU.
* Support for ARM and AArch64.
*-DLLVM_HOST_TRIPLE=$(GNU_TARGET_NAME) added. This fixes the error:
"No available targets are compatible with this triple" for llvmpipe.

Changes v3 -> v4:

This series is focused on OpenCL support

* Add Clang for host (needed to build libclc)
* Add Clang for target (libOpenCL needs libclang and libLLVM)
* Add libclc
* Add OpenCL support in Mesa3D
* Add package clinfo

Regards,

Valent?n


Valentin Korenblit (11):
  package/llvm: new host package
  package/llvm: enable target variant
  package/llvm: enable AMDGPU
  package/mesa3d: enable llvm support
  package/llvm: enable ARM
  package/llvm: enable AArch64
  package/clang: new host package
  package/clang: enable target variant
  package/libclc: new package
  package/mesa3d: enable OpenCL support
  package/clinfo: new package

 DEVELOPERS                   |   6 +
 package/Config.in            |   4 +
 package/Config.in.host       |   2 +
 package/clang/Config.in      |   8 ++
 package/clang/Config.in.host |   8 ++
 package/clang/clang.hash     |   3 +
 package/clang/clang.mk       |  70 ++++++++++
 package/clinfo/Config.in     |   7 +
 package/clinfo/clinfo.hash   |   2 +
 package/clinfo/clinfo.mk     |  23 ++++
 package/libclc/Config.in     |   9 ++
 package/libclc/libclc.mk     |  38 ++++++
 package/llvm/Config.in       |  29 +++++
 package/llvm/Config.in.host  |   8 ++
 package/llvm/llvm.hash       |   3 +
 package/llvm/llvm.mk         | 302 +++++++++++++++++++++++++++++++++++++++++++
 package/mesa3d/Config.in     |  24 ++++
 package/mesa3d/mesa3d.mk     |  24 +++-
 18 files changed, 568 insertions(+), 2 deletions(-)
 create mode 100644 package/clang/Config.in
 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/clinfo/Config.in
 create mode 100644 package/clinfo/clinfo.hash
 create mode 100644 package/clinfo/clinfo.mk
 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

-- 
2.14.3

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 01/11] package/llvm: new host package
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-04-01 20:36   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant Valentin Korenblit
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch installs LLVM on the host machine: tools and libraries.

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 option LLVM_TABLEGEN.
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 componentes. 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, what has the following problems:

llvm-config --shared mode outputs static (even if LLVM is built as
one shared library)

llvm-config --libs outputs all LLVM tiny libs: -lLLVMLTO, -lLLVMPasses,etc.

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, what is going to be added in a future patch.

As this package is intended to be used together with Mesa3D to enable llvmpipe,
we target x86 architecture. Mesa strongly recommends support for SSE2. Support
for SSE3 and SSE4.1 will yield the most efficient code.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 DEVELOPERS                  |   3 +
 package/Config.in.host      |   1 +
 package/llvm/Config.in.host |  17 ++++
 package/llvm/llvm.hash      |   3 +
 package/llvm/llvm.mk        | 217 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 241 insertions(+)
 create mode 100644 package/llvm/Config.in.host
 create mode 100644 package/llvm/llvm.hash
 create mode 100644 package/llvm/llvm.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 40fda40bda..3ed9407670 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1858,6 +1858,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.host b/package/Config.in.host
index 199a8e9856..9a6227174b 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -27,6 +27,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"
diff --git a/package/llvm/Config.in.host b/package/llvm/Config.in.host
new file mode 100644
index 0000000000..26ee7e28bb
--- /dev/null
+++ b/package/llvm/Config.in.host
@@ -0,0 +1,17 @@
+config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	bool
+	default y if BR2_i386 || BR2_x86_64
+	depends on BR2_HOST_GCC_AT_LEAST_4_8
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH
+	string
+	default "X86" if BR2_i386 || BR2_x86_64
+
+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
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..71fcaa2b8e
--- /dev/null
+++ b/package/llvm/llvm.mk
@@ -0,0 +1,217 @@
+################################################################################
+#
+# 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
+
+# http://llvm.org/docs/GettingStarted.html#software
+# host-python: Python interpreter 2.7 or newer is required for builds and testing.
+# host-zlib: Optional, adds compression / uncompression capabilities to selected LLVM tools.
+HOST_LLVM_DEPENDENCIES = host-python host-zlib
+
+# Don't build clang libcxx libcxxabi lldb compiler-rt lld polly as llvm subprojects
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PROJECTS=""
+
+# Disable CCACHE
+HOST_LLVM_CONF_OPTS += -DLLVM_CCACHE_BUILD=OFF
+
+# Disable Build GlobalIsel
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
+
+# * Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
+#   Ninja is not supported yet by Buildroot
+HOST_LLVM_CONF_OPTS += -G "Unix Makefiles"
+
+# * LLVM_BUILD_UTILS: Build LLVM utility binaries. If OFF, just generate build targets.
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=ON
+
+# * LLVM_INSTALL_UTILS: Include utility binaries in the 'install' target. ON for host.
+#   Utils : FileCheck, KillTheDoctor, llvm-PerfectShuffle, count, not, yaml-bench
+HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=ON
+
+# * LLVM_ENABLE_LIBEDIT: Use libedit if available
+#   Disabled since no host-libedit
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
+
+# * LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target. OFF
+#   We also want llvm libraries and modules.
+HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
+
+# * LLVM_APPEND_VC_REV "Append the version control system revision id to LLVM version OFF
+#   We build from a release archive without vcs
+HOST_LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
+
+# * BUILD_SHARED_LIBS Build all libraries as shared libraries instead of static
+#   It is only recommended to be used by LLVM developers.To build LLVM as a single
+#   shared library, we should use the LLVM_BUILD_LLVM_DYLIB option.
+HOST_LLVM_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+
+# * LLVM_ENABLE_BACKTRACES: Enable embedding backtraces on crash ON
+#   Use backtraces on crash to report toolchain issue.
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_BACKTRACES=ON
+
+# * ENABLE_CRASH_OVERRIDES: Enable crash overrides ON
+#   Keep the possibility to install or overrides signal handlers
+HOST_LLVM_CONF_OPTS += -DENABLE_CRASH_OVERRIDES=ON
+
+# * LLVM_ENABLE_FFI: Use libffi to call external functions from the interpreter OFF
+#   Keep ffi disabled for now
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=OFF
+
+# * LLVM_ENABLE_TERMINFO: Use terminfo database if available.
+#   Disable terminfo database (needs ncurses libtinfo.so)
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_TERMINFO=OFF
+
+# * LLVM_ENABLE_THREADS: Use threads if available ON
+#   Keep threads enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON
+
+# * LLVM_ENABLE_ZLIB: Use zlib for compression/decompression if available ON
+#   Keep zlib support enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_ZLIB=ON
+
+# * LLVM_ENABLE_PIC: Build Position-Independent Code ON
+#   We don't use llvm for static only build, so enable PIC
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PIC=ON
+
+# * LLVM_ENABLE_WARNINGS: Enable compiler warnings ON
+#   Keep compiler warning enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WARNINGS=ON
+
+# * LLVM_ENABLE_PEDANTIC: Compile with pedantic enabled ON
+#   Keep pedantic enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PEDANTIC=ON
+
+# * LLVM_ENABLE_WERROR: Fail and stop if a warning is triggered OFF
+#   Keep Werror disabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WERROR=OFF
+
+# * CMAKE_BUILD_TYPE: Set build type Debug, Release, RelWithDebInfo, and MinSizeRel.
+#   Default is Debug. Use the Release build which requires considerably less space.
+HOST_LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+# * LLVM_POLLY_BUILD: Build LLVM with Polly ON
+#   Keep it enabled, if POLLY is not in-tree it will not be built
+HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_BUILD=ON
+
+# * LINK_POLLY_INTO_TOOLS: Static link Polly into tools ON
+HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_LINK_INTO_TOOLS=ON
+
+# * LLVM_INCLUDE_TOOLS: Generate build targets for the LLVM tools ON
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
+
+# * LLVM_BUILD_TOOLS: Build the LLVM tools
+#   Enabled for host
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TOOLS=ON
+
+# * LLVM_INCLUDE_UTILS: Generate build targets for the LLVM utils.
+#   Enabled for host, disabled for the target.
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=ON
+
+# Do not build llvm runtime libraries
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
+	-DLLVM_INCLUDE_RUNTIMES=OFF
+
+# * LLVM_BUILD_EXAMPLES: Build the LLVM example programs OFF
+#   Don't build examples
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXAMPLES=OFF \
+	-DLLVM_INCLUDE_EXAMPLES=OFF
+
+# * LLVM_BUILD_TESTS: Build LLVM unit tests OFF
+#   Don't build tests
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TESTS=OFF
+
+# * LLVM_INCLUDE_TESTS: Generate build targets for the LLVM unit tests OFF
+#   Don't build llvm unit tests
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
+
+# * LLVM_INCLUDE_GO_TESTS: Include the Go bindings tests in test build targets OFF
+#   Don't build Go tests
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_GO_TESTS=OFF
+
+# * LLVM_BUILD_DOCS: Build the llvm documentation OFF
+#   Disable llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_DOCS=OFF
+
+# * LLVM_INCLUDE_DOCS: Generate build targets for llvm documentation OFF
+#   Don't build llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_DOCS=OFF
+
+# * LLVM_ENABLE_DOXYGEN: Use doxygen to generate llvm API documentation OFF
+#   Don't build llvm API documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_DOXYGEN=OFF
+
+# * LLVM_ENABLE_SPHINX: Use Sphinx to generate llvm documentation OFF
+#   Don't build llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_SPHINX=OFF
+
+# * LLVM_ENABLE_OCAMLDOC: Use OCaml bindings documentation OFF
+#   Don't build llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_OCAMLDOC=OFF
+
+# * LLVM_BUILD_EXTERNAL_COMPILER_RT: Build compiler-rt as an external project OFF
+#   Keep rt compiler disabled
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
+
+# Get target architecture
+HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
+
+# Build backend for target architecture
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
+
+# LLVM target to use for native code generation.
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
+
+# * LLVM_ENABLE_CXX1Y: Compile with C++1y enabled OFF
+#   Enable C++ and C++11 support if BR2_INSTALL_LIBSTDCPP=y
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
+
+# * LLVM_ENABLE_MODULES: Compile with C++ modules enabled 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_ENABLE_LIBCXX: Use libc++ if available OFF
+#   Use -stdlib=libc++ compiler flag, use libc++ as C++ standard library
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBCXX=OFF
+
+# * LLVM_ENABLE_LLD: Use lld as C and C++ linker. OFF
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LLD=OFF
+
+# * LLVM_DEFAULT_TARGET_TRIPLE: by default, generate code for the target
+HOST_LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_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 tablegen that gets used during the LLVM build.
+HOST_LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
+
+# * Generate libLLVM.so. This library contains a default set of LLVM components
+# that can be overridden 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
+
+# * Link tools with libLLVM shared library. If set to ON, it sets
+# 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
+
+# Install libLLVM and tools in HOST_DIR/usr
+HOST_LLVM_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr
+
+$(eval $(host-cmake-package))
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 01/11] package/llvm: new host package Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-04-01 20:46   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU Valentin Korenblit
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch installs libLLVM.so on the target.

As option LLVM_BUILD_LLVM_DYLIB is enabled, a single shared library
containing all LLVM components is built. This option is not compatible
with BUILD_SHARED_LIBS, which generates on .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

This patch copies llvm-config from HOST_DIR/usr/bin to STAGING_DIR/usr/in,
so that it can be used by packages that link with LLVM libraries.

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

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/Config.in           |  1 +
 package/llvm/Config.in      | 18 +++++++++++
 package/llvm/Config.in.host |  9 ------
 package/llvm/llvm.mk        | 79 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+), 9 deletions(-)
 create mode 100644 package/llvm/Config.in

diff --git a/package/Config.in b/package/Config.in
index 2f9210a04e..47e5b3d1b4 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1540,6 +1540,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..1d80498d53
--- /dev/null
+++ b/package/llvm/Config.in
@@ -0,0 +1,18 @@
+config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	bool
+	default y if BR2_i386 || BR2_x86_64
+	depends on BR2_HOST_GCC_AT_LEAST_4_8
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH
+	string
+	default "X86" if BR2_i386 || BR2_x86_64
+
+config BR2_PACKAGE_LLVM
+	bool "llvm"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	select BR2_PACKAGE_HOST_LLVM
+	help
+	  The LLVM Project is a collection of modular and reusable
+	  compiler and toolchain technologies.
+
+	  http://llvm.org
diff --git a/package/llvm/Config.in.host b/package/llvm/Config.in.host
index 26ee7e28bb..fc46535fad 100644
--- a/package/llvm/Config.in.host
+++ b/package/llvm/Config.in.host
@@ -1,12 +1,3 @@
-config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
-	bool
-	default y if BR2_i386 || BR2_x86_64
-	depends on BR2_HOST_GCC_AT_LEAST_4_8
-
-config BR2_PACKAGE_LLVM_TARGET_ARCH
-	string
-	default "X86" if BR2_i386 || BR2_x86_64
-
 config BR2_PACKAGE_HOST_LLVM
 	bool "host llvm"
 	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 71fcaa2b8e..4e58c96e0f 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -10,13 +10,16 @@ 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-zlib: Optional, adds compression / uncompression capabilities to selected LLVM tools.
 HOST_LLVM_DEPENDENCIES = host-python host-zlib
+LLVM_DEPENDENCIES = host-llvm zlib
 
 # 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=""
 
 # Disable CCACHE
@@ -28,166 +31,238 @@ HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
 # * Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
 #   Ninja is not supported yet by Buildroot
 HOST_LLVM_CONF_OPTS += -G "Unix Makefiles"
+LLVM_CONF_OPTS += -G "Unix Makefiles"
+
+# Use native llvm-tblgen from host-llvm (needed for cross-compilation)
+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) returns 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
+
+# Make it explicit that we are cross-compiling
+LLVM_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
 
 # * LLVM_BUILD_UTILS: Build LLVM utility binaries. If OFF, just generate build targets.
+#   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
+LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=OFF
 
 # * LLVM_INSTALL_UTILS: Include utility binaries in the 'install' target. ON for host.
 #   Utils : FileCheck, KillTheDoctor, llvm-PerfectShuffle, count, not, yaml-bench
 HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=ON
+LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=OFF
 
 # * LLVM_ENABLE_LIBEDIT: Use libedit if available
 #   Disabled since no host-libedit
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
 
 # * LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target. OFF
 #   We also want llvm libraries and modules.
 HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
+LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
 
 # * LLVM_APPEND_VC_REV "Append the version control system revision id to LLVM version OFF
 #   We build from a release archive without vcs
 HOST_LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
+LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
 
 # * BUILD_SHARED_LIBS Build all libraries as shared libraries instead of static
 #   It is only recommended to be used by LLVM developers.To build LLVM as a single
 #   shared library, we should use the LLVM_BUILD_LLVM_DYLIB option.
 HOST_LLVM_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+LLVM_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
 
 # * LLVM_ENABLE_BACKTRACES: Enable embedding backtraces on crash ON
 #   Use backtraces on crash to report toolchain issue.
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_BACKTRACES=ON
+LLVM_CONF_OPTS += -DLLVM_ENABLE_BACKTRACES=OFF
 
 # * ENABLE_CRASH_OVERRIDES: Enable crash overrides ON
 #   Keep the possibility to install or overrides signal handlers
 HOST_LLVM_CONF_OPTS += -DENABLE_CRASH_OVERRIDES=ON
+LLVM_CONF_OPTS += -DENABLE_CRASH_OVERRIDES=ON
 
 # * LLVM_ENABLE_FFI: Use libffi to call external functions from the interpreter OFF
 #   Keep ffi disabled for now
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=OFF
 
 # * LLVM_ENABLE_TERMINFO: Use terminfo database if available.
 #   Disable terminfo database (needs ncurses libtinfo.so)
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_TERMINFO=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_TERMINFO=OFF
 
 # * LLVM_ENABLE_THREADS: Use threads if available ON
 #   Keep threads enabled
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON
+LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON
 
 # * LLVM_ENABLE_ZLIB: Use zlib for compression/decompression if available ON
 #   Keep zlib support enabled
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_ZLIB=ON
+LLVM_CONF_OPTS += -DLLVM_ENABLE_ZLIB=ON
 
 # * LLVM_ENABLE_PIC: Build Position-Independent Code ON
 #   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
 
 # * LLVM_ENABLE_WARNINGS: Enable compiler warnings ON
 #   Keep compiler warning enabled
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WARNINGS=ON
+LLVM_CONF_OPTS += -DLLVM_ENABLE_WARNINGS=ON
 
 # * LLVM_ENABLE_PEDANTIC: Compile with pedantic enabled ON
 #   Keep pedantic enabled
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PEDANTIC=ON
+LLVM_CONF_OPTS += -DLLVM_ENABLE_PEDANTIC=ON
 
 # * LLVM_ENABLE_WERROR: Fail and stop if a warning is triggered OFF
 #   Keep Werror disabled
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WERROR=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_WERROR=OFF
 
 # * CMAKE_BUILD_TYPE: Set build type Debug, Release, RelWithDebInfo, and MinSizeRel.
 #   Default is Debug. Use the Release build which requires considerably less space.
 HOST_LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
 
 # * LLVM_POLLY_BUILD: Build LLVM with Polly ON
 #   Keep it enabled, if POLLY is not in-tree it will not be built
 HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_BUILD=ON
+LLVM_CONF_OPTS += -DLLVM_POLLY_BUILD=ON
 
 # * LINK_POLLY_INTO_TOOLS: Static link Polly into tools ON
 HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_LINK_INTO_TOOLS=ON
+LLVM_CONF_OPTS += -DLLVM_POLLY_LINK_INTO_TOOLS=ON
 
 # * LLVM_INCLUDE_TOOLS: Generate build targets for the LLVM tools ON
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
 
 # * LLVM_BUILD_TOOLS: Build the LLVM tools
 #   Enabled for host
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TOOLS=ON
+LLVM_CONF_OPTS += -DLLVM_BUILD_TOOLS=OFF
 
 # * LLVM_INCLUDE_UTILS: Generate build targets for the LLVM utils.
 #   Enabled for host, disabled for the target.
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=ON
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=OFF
 
 # Do not build llvm runtime libraries
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
 	-DLLVM_INCLUDE_RUNTIMES=OFF
+LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
+	-DLLVM_INCLUDE_RUNTIMES=OFF
 
 # * LLVM_BUILD_EXAMPLES: Build the LLVM example programs OFF
 #   Don't build examples
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXAMPLES=OFF \
 	-DLLVM_INCLUDE_EXAMPLES=OFF
+LLVM_CONF_OPTS += -DLLVM_BUILD_EXAMPLES=OFF \
+	-DLLVM_INCLUDE_EXAMPLES=OFF
 
 # * LLVM_BUILD_TESTS: Build LLVM unit tests OFF
 #   Don't build tests
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TESTS=OFF
+LLVM_CONF_OPTS += -DLLVM_BUILD_TESTS=OFF
 
 # * LLVM_INCLUDE_TESTS: Generate build targets for the LLVM unit tests OFF
 #   Don't build llvm unit tests
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
 
 # * LLVM_INCLUDE_GO_TESTS: Include the Go bindings tests in test build targets OFF
 #   Don't build Go tests
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_GO_TESTS=OFF
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_GO_TESTS=OFF
 
 # * LLVM_BUILD_DOCS: Build the llvm documentation OFF
 #   Disable llvm documentation
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_DOCS=OFF
+LLVM_CONF_OPTS += -DLLVM_BUILD_DOCS=OFF
 
 # * LLVM_INCLUDE_DOCS: Generate build targets for llvm documentation OFF
 #   Don't build llvm documentation
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_DOCS=OFF
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_DOCS=OFF
 
 # * LLVM_ENABLE_DOXYGEN: Use doxygen to generate llvm API documentation OFF
 #   Don't build llvm API documentation
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_DOXYGEN=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_DOXYGEN=OFF
 
 # * LLVM_ENABLE_SPHINX: Use Sphinx to generate llvm documentation OFF
 #   Don't build llvm documentation
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_SPHINX=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_SPHINX=OFF
 
 # * LLVM_ENABLE_OCAMLDOC: Use OCaml bindings documentation OFF
 #   Don't build llvm documentation
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_OCAMLDOC=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_OCAMLDOC=OFF
 
 # * LLVM_BUILD_EXTERNAL_COMPILER_RT: Build compiler-rt as an external project OFF
 #   Keep rt compiler disabled
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
+LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
 
 # Get target architecture
 HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
 
 # Build backend for target architecture
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
+LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
 
 # 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)
 
 # * LLVM_ENABLE_CXX1Y: Compile with C++1y enabled OFF
 #   Enable C++ and C++11 support if BR2_INSTALL_LIBSTDCPP=y
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
+LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
 
 # * LLVM_ENABLE_MODULES: Compile with C++ modules enabled 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
 
 # * LLVM_ENABLE_LIBCXX: Use libc++ if available OFF
 #   Use -stdlib=libc++ compiler flag, use libc++ as C++ standard library
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBCXX=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBCXX=OFF
 
 # * LLVM_ENABLE_LLD: Use lld as C and C++ linker. OFF
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LLD=OFF
+LLVM_CONF_OPTS += -DLLVM_ENABLE_LLD=OFF
 
 # * LLVM_DEFAULT_TARGET_TRIPLE: by default, generate code for the target
 HOST_LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+
+# Need to specify triple for native code generation
+# 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.
@@ -197,11 +272,13 @@ HOST_LLVM_CONF_OPTS += \
 
 # Builds a release tablegen that gets used during the LLVM build.
 HOST_LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
+LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
 
 # * Generate libLLVM.so. This library contains a default set of LLVM components
 # that can be overridden 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
 
 # * Link tools with libLLVM shared library. If set to ON, it sets
 # LLVM_BUILD_LLVM_DYLIB to ON. We need to enable this option for the
@@ -210,8 +287,10 @@ HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_LLVM_DYLIB=ON
 # 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
 
 # Install libLLVM and tools in HOST_DIR/usr
 HOST_LLVM_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr
 
+$(eval $(cmake-package))
 $(eval $(host-cmake-package))
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 01/11] package/llvm: new host package Valentin Korenblit
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-03-30  9:02   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support Valentin Korenblit
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 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 | 7 +++++++
 package/llvm/llvm.mk   | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index 1d80498d53..7f36bc802b 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -16,3 +16,10 @@ config BR2_PACKAGE_LLVM
 	  compiler and toolchain technologies.
 
 	  http://llvm.org
+
+config BR2_PACKAGE_LLVM_AMDGPU
+	bool "AMDGPU backend"
+	depends on BR2_PACKAGE_LLVM
+	help
+	  Build AMDGPU target. Select this option if you are going
+	  to install mesa3d with llvm and use Gallium Radeon driver.
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 4e58c96e0f..c819487bdf 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -226,9 +226,15 @@ LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
 # Get target architecture
 HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
 
+# Build AMDGPU backend
+ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
+LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
+else
 # Build backend for target architecture
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
 LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
+endif
 
 # LLVM target to use for native code generation.
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (2 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-04-01 20:53   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 05/11] package/llvm: enable ARM Valentin Korenblit
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch provides LLVM support for Mesa3D, enabling llvmpipe
software rasterizer.

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>
---

Once the system has llvm, radeonsi Gallium driver could be added to support
Southern Islands and newer GPUs. I haven't done it because I don't have the
hardware to test it yet.

 package/mesa3d/Config.in |  8 ++++++++
 package/mesa3d/mesa3d.mk | 17 ++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
index f141587c4d..e99e737d31 100644
--- a/package/mesa3d/Config.in
+++ b/package/mesa3d/Config.in
@@ -25,6 +25,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 llvm"
+	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
diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
index 8e4aa7d5ac..498ad57eed 100644
--- a/package/mesa3d/mesa3d.mk
+++ b/package/mesa3d/mesa3d.mk
@@ -32,6 +32,20 @@ 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 += \
+	--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.
@@ -219,7 +233,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] 42+ messages in thread

* [Buildroot] [PATCH v4 05/11] package/llvm: enable ARM
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (3 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-04-01 20:53   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 06/11] package/llvm: enable AArch64 Valentin Korenblit
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch adds LLVM support for ARM

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---

Tested llvmpipe running glmark2-es2 on Raspberry Pi 2 and 3(32-bit)

 package/llvm/Config.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index 7f36bc802b..e695017da3 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -1,10 +1,12 @@
 config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 	bool
+	default y if BR2_arm || BR2_armeb
 	default y if BR2_i386 || BR2_x86_64
 	depends on BR2_HOST_GCC_AT_LEAST_4_8
 
 config BR2_PACKAGE_LLVM_TARGET_ARCH
 	string
+	default "ARM" if BR2_arm || BR2_armeb
 	default "X86" if BR2_i386 || BR2_x86_64
 
 config BR2_PACKAGE_LLVM
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 06/11] package/llvm: enable AArch64
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (4 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 05/11] package/llvm: enable ARM Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 07/11] package/clang: new host package Valentin Korenblit
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch adds LLVM support for AArch64

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---

Tested llvmpipe running glmark2-es2 on Raspberry Pi 3(64-bit)

 package/llvm/Config.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index e695017da3..dc631dad83 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -1,11 +1,13 @@
 config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 	bool
+	default y if BR2_aarch64
 	default y if BR2_arm || BR2_armeb
 	default y if BR2_i386 || BR2_x86_64
 	depends on BR2_HOST_GCC_AT_LEAST_4_8
 
 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
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 07/11] package/clang: new host package
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (5 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 06/11] package/llvm: enable AArch64 Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-03-30 16:56   ` Matthew Weber
  2018-04-01 20:56   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 08/11] package/clang: enable target variant Valentin Korenblit
                   ` (3 subsequent siblings)
  10 siblings, 2 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch provides Clang for the host, tools and libraries.

Clang is needed to build libclc, which is also provided in this
series.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 DEVELOPERS                   |  1 +
 package/Config.in.host       |  1 +
 package/clang/Config.in.host |  8 ++++++++
 package/clang/clang.hash     |  3 +++
 package/clang/clang.mk       | 40 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 53 insertions(+)
 create mode 100644 package/clang/Config.in.host
 create mode 100644 package/clang/clang.hash
 create mode 100644 package/clang/clang.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 3ed9407670..47aa2dd82a 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1859,6 +1859,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.host b/package/Config.in.host
index 9a6227174b..09e00a2b45 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -5,6 +5,7 @@ menu "Host utilities"
 	source "package/cargo/Config.in.host"
 	source "package/cbootimage/Config.in.host"
 	source "package/checkpolicy/Config.in.host"
+	source "package/clang/Config.in.host"
 	source "package/cmake/Config.in.host"
 	source "package/cramfs/Config.in.host"
 	source "package/cryptsetup/Config.in.host"
diff --git a/package/clang/Config.in.host b/package/clang/Config.in.host
new file mode 100644
index 0000000000..61a7ed59f0
--- /dev/null
+++ b/package/clang/Config.in.host
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_HOST_CLANG
+	bool "host clang"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	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..7e7584ced7
--- /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..5ea0bb05f9
--- /dev/null
+++ b/package/clang/clang.mk
@@ -0,0 +1,40 @@
+################################################################################
+#
+# 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
+
+HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
+
+# Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
+HOST_CLANG_CONF_OPTS += -G "Unix Makefiles"
+
+# Select Release build
+HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+# Build tools enabled
+HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
+
+# Don't build examples
+HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
+
+# Don't build doc
+HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
+
+# Don't build tests
+HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF
+
+# Specify path to host's llvm-config
+HOST_CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(HOST_DIR)/bin/llvm-config
+
+# Install clang in  HOST_DIR/usr
+HOST_CLANG_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr
+
+$(eval $(host-cmake-package))
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 08/11] package/clang: enable target variant
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (6 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 07/11] package/clang: new host package Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-03-30  9:07   ` Thomas Petazzoni
                     ` (2 more replies)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 09/11] package/libclc: new package Valentin Korenblit
                   ` (2 subsequent siblings)
  10 siblings, 3 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch provides Clang for the target, tools and libraries.

In this package we have to deal with the same kind of problem we encountered
when building mesa3d with llvm support: llvm-config (host-version) had to be
copied to STAGING_DIR/usr/bin. In this case, we need llvm-tblgen from host
to be installed in STAGING_DIR/usr/bin for cross-compiling clang.

We need libclang for the target because it is used by all OpenCL implementations.
In this series, Clover is provided.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/Config.in       |  1 +
 package/clang/Config.in |  8 ++++++++
 package/clang/clang.mk  | 30 ++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+)
 create mode 100644 package/clang/Config.in

diff --git a/package/Config.in b/package/Config.in
index 47e5b3d1b4..4d32d749fb 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1474,6 +1474,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..e2e53dcbc8
--- /dev/null
+++ b/package/clang/Config.in
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_CLANG
+	bool "clang"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	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.mk b/package/clang/clang.mk
index 5ea0bb05f9..c2b83a8e60 100644
--- a/package/clang/clang.mk
+++ b/package/clang/clang.mk
@@ -10,31 +10,61 @@ 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 = host-clang llvm
 
 # Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
 HOST_CLANG_CONF_OPTS += -G "Unix Makefiles"
+CLANG_CONF_OPTS += -G "Unix Makefiles"
+
+# This option is needed. Otherwise multiple shared libs (libclangAST.so,
+# libclangBasic.so, libclangFrontend.so, etc.) will 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
+
+# Copy llvm-tblgen (host variant) to STAGING_DIR
+define CLANG_COPY_LLVM_TBLGEN_TO_STAGING_DIR
+	$(INSTALL) -D -m 0755 $(HOST_DIR)/bin/llvm-tblgen $(STAGING_DIR)/usr/bin/llvm-tblgen
+endef
+CLANG_PRE_CONFIGURE_HOOKS = CLANG_COPY_LLVM_TBLGEN_TO_STAGING_DIR
 
 # Select Release build
 HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+# Make it explicit that we are cross-compiling
+CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
 
 # Build tools enabled
 HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
+CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
 
 # Don't build examples
 HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
+CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
 
 # Don't build doc
 HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
+CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
 
 # Don't build tests
 HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF
+CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF
 
 # Specify path to host's llvm-config
 HOST_CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(HOST_DIR)/bin/llvm-config
+CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(STAGING_DIR)/usr/bin/llvm-config
 
 # Install clang in  HOST_DIR/usr
 HOST_CLANG_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr
 
+$(eval $(cmake-package))
 $(eval $(host-cmake-package))
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 09/11] package/libclc: new package
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (7 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 08/11] package/clang: enable target variant Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-04-01 21:29   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support Valentin Korenblit
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 11/11] package/clinfo: new package Valentin Korenblit
  10 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 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>
---
 DEVELOPERS               |  1 +
 package/Config.in        |  1 +
 package/libclc/Config.in |  9 +++++++++
 package/libclc/libclc.mk | 38 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 49 insertions(+)
 create mode 100644 package/libclc/Config.in
 create mode 100644 package/libclc/libclc.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 47aa2dd82a..6bcafb6d2a 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1860,6 +1860,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 4d32d749fb..bc2228ed17 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.mk b/package/libclc/libclc.mk
new file mode 100644
index 0000000000..b8b4dca273
--- /dev/null
+++ b/package/libclc/libclc.mk
@@ -0,0 +1,38 @@
+################################################################################
+#
+# libclc
+#
+################################################################################
+
+LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
+LIBCLC_SITE = https://git.llvm.org/git/libclc
+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 built 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" \
+	--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))
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (8 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 09/11] package/libclc: new package Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  2018-04-01 21:32   ` Thomas Petazzoni
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 11/11] package/clinfo: new package Valentin Korenblit
  10 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 UTC (permalink / raw)
  To: buildroot

This patch provides Clover, the OpenCL 1.1 API implementation by Mesa
for AMD GPUs. It generates libOpenCL.so.

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 | 16 ++++++++++++++++
 package/mesa3d/mesa3d.mk |  9 +++++++++
 2 files changed, 25 insertions(+)

diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
index e99e737d31..bad7ac4339 100644
--- a/package/mesa3d/Config.in
+++ b/package/mesa3d/Config.in
@@ -33,6 +33,22 @@ config BR2_PACKAGE_MESA3D_LLVM
 comment "mesa3d w/ llvm needs llvm"
 	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 
+config BR2_PACKAGE_MESA3D_OPENCL
+	bool "mesa3d OpenCL"
+	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_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 498ad57eed..1df28c43cb 100644
--- a/package/mesa3d/mesa3d.mk
+++ b/package/mesa3d/mesa3d.mk
@@ -233,4 +233,13 @@ 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 \
+	--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] 42+ messages in thread

* [Buildroot] [PATCH v4 11/11] package/clinfo: new package
  2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
                   ` (9 preceding siblings ...)
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support Valentin Korenblit
@ 2018-03-29 11:33 ` Valentin Korenblit
  10 siblings, 0 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-29 11:33 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   |  7 +++++++
 package/clinfo/clinfo.hash |  2 ++
 package/clinfo/clinfo.mk   | 23 +++++++++++++++++++++++
 5 files changed, 34 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 6bcafb6d2a..adedae9219 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1860,6 +1860,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 bc2228ed17..9d529b4a4e 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1478,6 +1478,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..ce6c8bccae
--- /dev/null
+++ b/package/clinfo/Config.in
@@ -0,0 +1,7 @@
+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.
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..04000247bc
--- /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] 42+ messages in thread

* [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU Valentin Korenblit
@ 2018-03-30  9:02   ` Thomas Petazzoni
  2018-03-30 11:33     ` Valentin Korenblit
  2018-03-30 18:08     ` Arnout Vandecappelle
  0 siblings, 2 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-03-30  9:02 UTC (permalink / raw)
  To: buildroot

Hello Valentin,

On Thu, 29 Mar 2018 13:33:38 +0200, Valentin Korenblit wrote:

> +config BR2_PACKAGE_LLVM_AMDGPU
> +	bool "AMDGPU backend"
> +	depends on BR2_PACKAGE_LLVM
> +	help
> +	  Build AMDGPU target. Select this option if you are going
> +	  to install mesa3d with llvm and use Gallium Radeon driver.
> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
> index 4e58c96e0f..c819487bdf 100644
> --- a/package/llvm/llvm.mk
> +++ b/package/llvm/llvm.mk
> @@ -226,9 +226,15 @@ LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
>  # Get target architecture
>  HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
>  
> +# Build AMDGPU backend
> +ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
> +HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
> +LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"

It feels non-natural that a target Config.in option
(BR2_PACKAGE_LLVM_AMDGPU) affect the build of the host variant of the
LLVM package. Is this really intended and necessary ? I.e do you need
AMDGPU support in the host LLVM variant for it to work in the target
LLVM ?

> +else
>  # Build backend for target architecture
>  HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
>  LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
> +endif

This doesn't look like a very extensible solution.

What about instead:

LLVM_TARGETS_TO_BUILD = $(HOST_LLVM_TARGET_ARCH)

ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
LLVM_TARGETS_TO_BUILD := $(LLVM_TARGETS_TO_BUILD);AMDGPU
endif

and then use LLVM_TARGETS_TO_BUILD to pass -DLLVM_TARGETS_TO_BUILD.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 08/11] package/clang: enable target variant
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 08/11] package/clang: enable target variant Valentin Korenblit
@ 2018-03-30  9:07   ` Thomas Petazzoni
  2018-03-30 12:16     ` Valentin Korenblit
  2018-03-30 17:58   ` Matthew Weber
  2018-04-01 21:25   ` Thomas Petazzoni
  2 siblings, 1 reply; 42+ messages in thread
From: Thomas Petazzoni @ 2018-03-30  9:07 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:43 +0200, Valentin Korenblit wrote:
> This patch provides Clang for the target, tools and libraries.
> 
> In this package we have to deal with the same kind of problem we encountered
> when building mesa3d with llvm support: llvm-config (host-version) had to be
> copied to STAGING_DIR/usr/bin. In this case, we need llvm-tblgen from host
> to be installed in STAGING_DIR/usr/bin for cross-compiling clang.
> 
> We need libclang for the target because it is used by all OpenCL implementations.
> In this series, Clover is provided.

I'm not sure to understand why you need Clang on the target, and what
Clover is. Maybe I missed it, but I don't see where the target Clang is
used in the rest of your series.

In addition, we don't support gcc on the target, so having clang on the
target raises a red flag for me.

Could you explain a bit more why this is needed/useful ?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU
  2018-03-30  9:02   ` Thomas Petazzoni
@ 2018-03-30 11:33     ` Valentin Korenblit
  2018-03-30 18:08     ` Arnout Vandecappelle
  1 sibling, 0 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-30 11:33 UTC (permalink / raw)
  To: buildroot


Hello Thomas,

On 30/03/2018 11:02, Thomas Petazzoni wrote:
> Hello Valentin,
>
> On Thu, 29 Mar 2018 13:33:38 +0200, Valentin Korenblit wrote:
>
>> +config BR2_PACKAGE_LLVM_AMDGPU
>> +	bool "AMDGPU backend"
>> +	depends on BR2_PACKAGE_LLVM
>> +	help
>> +	  Build AMDGPU target. Select this option if you are going
>> +	  to install mesa3d with llvm and use Gallium Radeon driver.
>> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
>> index 4e58c96e0f..c819487bdf 100644
>> --- a/package/llvm/llvm.mk
>> +++ b/package/llvm/llvm.mk
>> @@ -226,9 +226,15 @@ LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
>>   # Get target architecture
>>   HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
>>   
>> +# Build AMDGPU backend
>> +ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
>> +HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
>> +LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
> It feels non-natural that a target Config.in option
> (BR2_PACKAGE_LLVM_AMDGPU) affect the build of the host variant of the
> LLVM package. Is this really intended and necessary ? I.e do you need
> AMDGPU support in the host LLVM variant for it to work in the target
> LLVM ?
>
As you say, it is a mistake. We don't need amdgpu backend for the host, actually we
need host-llvm just to cross-compile llvm.

>> +else
>>   # Build backend for target architecture
>>   HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
>>   LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
>> +endif
> This doesn't look like a very extensible solution.
>
> What about instead:
>
> LLVM_TARGETS_TO_BUILD = $(HOST_LLVM_TARGET_ARCH)
>
> ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
> LLVM_TARGETS_TO_BUILD := $(LLVM_TARGETS_TO_BUILD);AMDGPU
> endif
>
> and then use LLVM_TARGETS_TO_BUILD to pass -DLLVM_TARGETS_TO_BUILD.

That's much better, I'll do that.

> Best regards,
>
> Thomas

Best regards and thanks for the review,

Valentin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 08/11] package/clang: enable target variant
  2018-03-30  9:07   ` Thomas Petazzoni
@ 2018-03-30 12:16     ` Valentin Korenblit
  2018-03-30 12:37       ` Thomas Petazzoni
  0 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-30 12:16 UTC (permalink / raw)
  To: buildroot


Hello Thomas,

On 30/03/2018 11:07, Thomas Petazzoni wrote:
> Hello,
>
> On Thu, 29 Mar 2018 13:33:43 +0200, Valentin Korenblit wrote:
>> This patch provides Clang for the target, tools and libraries.
>>
>> In this package we have to deal with the same kind of problem we encountered
>> when building mesa3d with llvm support: llvm-config (host-version) had to be
>> copied to STAGING_DIR/usr/bin. In this case, we need llvm-tblgen from host
>> to be installed in STAGING_DIR/usr/bin for cross-compiling clang.
>>
>> We need libclang for the target because it is used by all OpenCL implementations.
>> In this series, Clover is provided.
> I'm not sure to understand why you need Clang on the target, and what
> Clover is. Maybe I missed it, but I don't see where the target Clang is
> used in the rest of your series.

What we need is libclang, we don't need the binaries. But as libclang is a tool,
I need to set CLANG_BUILD_TOOLS to ON, what will build everything.

Clover is the OpenCL implementation provided with Mesa. It uses libclang as a frontend
for OpenCL C and libLLVM for code generation.

> In addition, we don't support gcc on the target, so having clang on the
> target raises a red flag for me.
>
> Could you explain a bit more why this is needed/useful ?

As explained above, we don't need it. I could add a hook to erase all unnecessary
binaries from the target if that is ok.

>
> Thanks!
>
> Thomas

Best regards,

Valentin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 08/11] package/clang: enable target variant
  2018-03-30 12:16     ` Valentin Korenblit
@ 2018-03-30 12:37       ` Thomas Petazzoni
  0 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-03-30 12:37 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 30 Mar 2018 14:16:00 +0200, Valentin Korenblit wrote:

> What we need is libclang, we don't need the binaries. But as libclang is a tool,
> I need to set CLANG_BUILD_TOOLS to ON, what will build everything.
> 
> Clover is the OpenCL implementation provided with Mesa. It uses libclang as a frontend
> for OpenCL C and libLLVM for code generation.

OK.

> > In addition, we don't support gcc on the target, so having clang on the
> > target raises a red flag for me.
> >
> > Could you explain a bit more why this is needed/useful ?  
> 
> As explained above, we don't need it. I could add a hook to erase all unnecessary
> binaries from the target if that is ok.

That's indeed a possibility.

I was a bit confused, because I missed which patch was actually using
the target clang package, but I didn't read PATCH 10/11 carefully
enough, and it does use the target clang, so it makes perfect sense.

Adjusting the target clang package to remove stuff that is not used is
indeed a good idea.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 07/11] package/clang: new host package
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 07/11] package/clang: new host package Valentin Korenblit
@ 2018-03-30 16:56   ` Matthew Weber
  2018-03-30 20:24     ` Valentin Korenblit
  2018-04-01 20:56   ` Thomas Petazzoni
  1 sibling, 1 reply; 42+ messages in thread
From: Matthew Weber @ 2018-03-30 16:56 UTC (permalink / raw)
  To: buildroot

Valentin,

On Thu, Mar 29, 2018 at 6:33 AM, Valentin Korenblit
<valentin.korenblit@smile.fr> wrote:
> This patch provides Clang for the host, tools and libraries.
>
> Clang is needed to build libclc, which is also provided in this
> series.
>
> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
> ---
>  DEVELOPERS                   |  1 +
>  package/Config.in.host       |  1 +
>  package/clang/Config.in.host |  8 ++++++++
>  package/clang/clang.hash     |  3 +++
>  package/clang/clang.mk       | 40 ++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 53 insertions(+)
>  create mode 100644 package/clang/Config.in.host
>  create mode 100644 package/clang/clang.hash
>  create mode 100644 package/clang/clang.mk
>
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 3ed9407670..47aa2dd82a 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1859,6 +1859,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.host b/package/Config.in.host
> index 9a6227174b..09e00a2b45 100644
> --- a/package/Config.in.host
> +++ b/package/Config.in.host
> @@ -5,6 +5,7 @@ menu "Host utilities"
>         source "package/cargo/Config.in.host"
>         source "package/cbootimage/Config.in.host"
>         source "package/checkpolicy/Config.in.host"
> +       source "package/clang/Config.in.host"
>         source "package/cmake/Config.in.host"
>         source "package/cramfs/Config.in.host"
>         source "package/cryptsetup/Config.in.host"
> diff --git a/package/clang/Config.in.host b/package/clang/Config.in.host
> new file mode 100644
> index 0000000000..61a7ed59f0
> --- /dev/null
> +++ b/package/clang/Config.in.host
> @@ -0,0 +1,8 @@
> +config BR2_PACKAGE_HOST_CLANG

When I just select host and target clang, I get the dependency chain error.

Makefile:569: *** llvm is in the dependency chain of clang that has
added it to its _DEPENDENCIES variable without selecting it or
depending on it from Config.in.  Stop.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 08/11] package/clang: enable target variant
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 08/11] package/clang: enable target variant Valentin Korenblit
  2018-03-30  9:07   ` Thomas Petazzoni
@ 2018-03-30 17:58   ` Matthew Weber
  2018-04-01 21:25   ` Thomas Petazzoni
  2 siblings, 0 replies; 42+ messages in thread
From: Matthew Weber @ 2018-03-30 17:58 UTC (permalink / raw)
  To: buildroot

Valentin,

On Thu, Mar 29, 2018 at 6:33 AM, Valentin Korenblit
<valentin.korenblit@smile.fr> wrote:
> This patch provides Clang for the target, tools and libraries.
>
> In this package we have to deal with the same kind of problem we encountered
> when building mesa3d with llvm support: llvm-config (host-version) had to be
> copied to STAGING_DIR/usr/bin. In this case, we need llvm-tblgen from host
> to be installed in STAGING_DIR/usr/bin for cross-compiling clang.
>
> We need libclang for the target because it is used by all OpenCL implementations.
> In this series, Clover is provided.
>


I'm building a basic x86 system  (I can work on reproducing this
failure in a generic QEMU build if you need that).  My build just
enabled a host and target versions of llvm and clang (no sub options).

2018-03-30T12:39:37 /bin/sh: clang-tblgen: command not found
2018-03-30T12:39:37 make[4]: *** [lib/Headers/arm_neon.h.tmp] Error 127
2018-03-30T12:39:37 make[4]: *** Waiting for unfinished jobs....
2018-03-30T12:39:37 make[3]: ***
[lib/Headers/CMakeFiles/clang-headers.dir/all] Error 2
2018-03-30T12:39:37 make[2]: *** [all] Error 2
2018-03-30T12:39:37 make[1]: ***
[/accts/mlweber1//target_build/qemu_x86_defconfig/build/clang-5.0.1/.stamp_built]
Error 2
2018-03-30T12:39:37 make: *** [_all] Error 2

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU
  2018-03-30  9:02   ` Thomas Petazzoni
  2018-03-30 11:33     ` Valentin Korenblit
@ 2018-03-30 18:08     ` Arnout Vandecappelle
  2018-03-30 19:06       ` Thomas Petazzoni
  1 sibling, 1 reply; 42+ messages in thread
From: Arnout Vandecappelle @ 2018-03-30 18:08 UTC (permalink / raw)
  To: buildroot



On 30-03-18 11:02, Thomas Petazzoni wrote:
> Hello Valentin,
> 
> On Thu, 29 Mar 2018 13:33:38 +0200, Valentin Korenblit wrote:
> 
>> +config BR2_PACKAGE_LLVM_AMDGPU
>> +	bool "AMDGPU backend"
>> +	depends on BR2_PACKAGE_LLVM
>> +	help
>> +	  Build AMDGPU target. Select this option if you are going
>> +	  to install mesa3d with llvm and use Gallium Radeon driver.
>> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
>> index 4e58c96e0f..c819487bdf 100644
>> --- a/package/llvm/llvm.mk
>> +++ b/package/llvm/llvm.mk
>> @@ -226,9 +226,15 @@ LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
>>  # Get target architecture
>>  HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
>>  
>> +# Build AMDGPU backend
>> +ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
>> +HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
>> +LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
> 
> It feels non-natural that a target Config.in option
> (BR2_PACKAGE_LLVM_AMDGPU) affect the build of the host variant of the
> LLVM package. Is this really intended and necessary ? I.e do you need
> AMDGPU support in the host LLVM variant for it to work in the target
> LLVM ?
> 
>> +else
>>  # Build backend for target architecture
>>  HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
>>  LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
>> +endif
> 
> This doesn't look like a very extensible solution.
> 
> What about instead:
> 
> LLVM_TARGETS_TO_BUILD = $(HOST_LLVM_TARGET_ARCH)
> 
> ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
> LLVM_TARGETS_TO_BUILD := $(LLVM_TARGETS_TO_BUILD);AMDGPU
> endif
> 
> and then use LLVM_TARGETS_TO_BUILD to pass -DLLVM_TARGETS_TO_BUILD.

 Or maybe

LLVM_TARGETS_TO_BUILD = $(HOST_LLVM_TARGET_ARCH)

ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
LLVM_TARGETS_TO_BUILD += AMDGPU
endif

LLVM_CONF_OPTS = -DLLVM_TARGETS_TO_BUILD=$(subst
$(space),;,$(LLVM_TARGETS_TO_BUILD))


 Or is that too much GNUmake black magic?

 Regards,
 Arnout


-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU
  2018-03-30 18:08     ` Arnout Vandecappelle
@ 2018-03-30 19:06       ` Thomas Petazzoni
  2018-03-30 20:33         ` Valentin Korenblit
  0 siblings, 1 reply; 42+ messages in thread
From: Thomas Petazzoni @ 2018-03-30 19:06 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 30 Mar 2018 20:08:28 +0200, Arnout Vandecappelle wrote:

>  Or maybe
> 
> LLVM_TARGETS_TO_BUILD = $(HOST_LLVM_TARGET_ARCH)
> 
> ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
> LLVM_TARGETS_TO_BUILD += AMDGPU
> endif
> 
> LLVM_CONF_OPTS = -DLLVM_TARGETS_TO_BUILD=$(subst
> $(space),;,$(LLVM_TARGETS_TO_BUILD))
> 
> 
>  Or is that too much GNUmake black magic?

No, that's good.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 07/11] package/clang: new host package
  2018-03-30 16:56   ` Matthew Weber
@ 2018-03-30 20:24     ` Valentin Korenblit
  0 siblings, 0 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-30 20:24 UTC (permalink / raw)
  To: buildroot


Hello Matthew,

On 30/03/2018 18:56, Matthew Weber wrote:
> Valentin,
>
> On Thu, Mar 29, 2018 at 6:33 AM, Valentin Korenblit
> <valentin.korenblit@smile.fr> wrote:
>> This patch provides Clang for the host, tools and libraries.
>>
>> Clang is needed to build libclc, which is also provided in this
>> series.
>>
>> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
>> ---
>>   DEVELOPERS                   |  1 +
>>   package/Config.in.host       |  1 +
>>   package/clang/Config.in.host |  8 ++++++++
>>   package/clang/clang.hash     |  3 +++
>>   package/clang/clang.mk       | 40 ++++++++++++++++++++++++++++++++++++++++
>>   5 files changed, 53 insertions(+)
>>   create mode 100644 package/clang/Config.in.host
>>   create mode 100644 package/clang/clang.hash
>>   create mode 100644 package/clang/clang.mk
>>
>> diff --git a/DEVELOPERS b/DEVELOPERS
>> index 3ed9407670..47aa2dd82a 100644
>> --- a/DEVELOPERS
>> +++ b/DEVELOPERS
>> @@ -1859,6 +1859,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.host b/package/Config.in.host
>> index 9a6227174b..09e00a2b45 100644
>> --- a/package/Config.in.host
>> +++ b/package/Config.in.host
>> @@ -5,6 +5,7 @@ menu "Host utilities"
>>          source "package/cargo/Config.in.host"
>>          source "package/cbootimage/Config.in.host"
>>          source "package/checkpolicy/Config.in.host"
>> +       source "package/clang/Config.in.host"
>>          source "package/cmake/Config.in.host"
>>          source "package/cramfs/Config.in.host"
>>          source "package/cryptsetup/Config.in.host"
>> diff --git a/package/clang/Config.in.host b/package/clang/Config.in.host
>> new file mode 100644
>> index 0000000000..61a7ed59f0
>> --- /dev/null
>> +++ b/package/clang/Config.in.host
>> @@ -0,0 +1,8 @@
>> +config BR2_PACKAGE_HOST_CLANG
> When I just select host and target clang, I get the dependency chain error.
>
> Makefile:569: *** llvm is in the dependency chain of clang that has
> added it to its _DEPENDENCIES variable without selecting it or
> depending on it from Config.in.  Stop.

Thanks, I've just added the correct select in Config.in and Config.in.host.

Valentin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU
  2018-03-30 19:06       ` Thomas Petazzoni
@ 2018-03-30 20:33         ` Valentin Korenblit
  2018-04-01 20:47           ` Thomas Petazzoni
  0 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-03-30 20:33 UTC (permalink / raw)
  To: buildroot

Hello all,

On 30/03/2018 21:06, Thomas Petazzoni wrote:
> Hello,
>
> On Fri, 30 Mar 2018 20:08:28 +0200, Arnout Vandecappelle wrote:
>
>>   Or maybe
>>
>> LLVM_TARGETS_TO_BUILD = $(HOST_LLVM_TARGET_ARCH)
>>
>> ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
>> LLVM_TARGETS_TO_BUILD += AMDGPU
>> endif
>>
>> LLVM_CONF_OPTS = -DLLVM_TARGETS_TO_BUILD=$(subst
>> $(space),;,$(LLVM_TARGETS_TO_BUILD))
>>
>>
>>   Or is that too much GNUmake black magic?

I've just tested your suggestions, but finally we also need to build amdgpu target for host. The reason is that
llvm-config (host version installed in STAGING) will output only x86 when executing llvm-config --targets-built.
This is because it stores information related to the build where it comes from.

This fails when Mesa looks for amdgpu backend:

llvm_add_target() {
     new_llvm_target=$1
     driver_name=$2

     if $LLVM_CONFIG --targets-built | grep -iqw $new_llvm_target ; then
         llvm_add_component $new_llvm_target $driver_name
     else
         AC_MSG_ERROR([LLVM target '$new_llvm_target' not enabled in your LLVM build. Required by $driver_name.])
     fi
}

> No, that's good.
>
> Thomas

Best regards,

Valentin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 01/11] package/llvm: new host package
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 01/11] package/llvm: new host package Valentin Korenblit
@ 2018-04-01 20:36   ` Thomas Petazzoni
  0 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:36 UTC (permalink / raw)
  To: buildroot

Hello Valentin,

Here is a review. I guess I'll see with Romain tomorrow how to handle
this. Perhaps we can fix most of the things during the hackathon, but
it would be nice if you could answer the questions in the e-mail below.
Thanks!

On Thu, 29 Mar 2018 13:33:36 +0200, Valentin Korenblit wrote:
> This patch installs LLVM on the host machine: tools and libraries.
> 
> 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 option LLVM_TABLEGEN.

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 componentes. However,

componentes -> components

> 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, what has the following problems:

"what has" ? Probably you wanted to use "that has" or "which has"

> 
> llvm-config --shared mode outputs static (even if LLVM is built as
> one shared library)
> 
> llvm-config --libs outputs all LLVM tiny libs: -lLLVMLTO, -lLLVMPasses,etc.

And ?

> 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, what is going to be added in a future patch.

what -> that or which

> As this package is intended to be used together with Mesa3D to enable llvmpipe,
> we target x86 architecture.

I'm not sure what this means, especially because your patch series
later adds support for ARM, AArch64, etc.

> Mesa strongly recommends support for SSE2. Support for SSE3 and
> SSE4.1 will yield the most efficient code.

And ?

> diff --git a/package/llvm/Config.in.host b/package/llvm/Config.in.host
> new file mode 100644
> index 0000000000..26ee7e28bb
> --- /dev/null
> +++ b/package/llvm/Config.in.host
> @@ -0,0 +1,17 @@
> +config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> +	bool
> +	default y if BR2_i386 || BR2_x86_64

	default y if BR2_i386
	default y if BR2_x86_64

> +	depends on BR2_HOST_GCC_AT_LEAST_4_8

This is not an architecture dependency, and we generally have a
Config.in comment for it.

> +config BR2_PACKAGE_HOST_LLVM
> +	bool "host llvm"

Do we really need a visible Config.in.host option for this? In this
patch series, host-llvm is merely needed as a build dependency of the
target llvm, so I don't think we need a visible Config.in.host option.

> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
> new file mode 100644
> index 0000000000..71fcaa2b8e
> --- /dev/null
> +++ b/package/llvm/llvm.mk
> @@ -0,0 +1,217 @@
> +################################################################################
> +#
> +# 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

In the rest of this file, you've decided to document each and every
configure option, and why it was set to its value. I don't think we do
this in any other package in Buildroot. I find that pretty verbose, but
on the other hand, it indeed gives lots of interesting details. So I'm
personally OK with this.

> +# http://llvm.org/docs/GettingStarted.html#software
> +# host-python: Python interpreter 2.7 or newer is required for builds and testing.
> +# host-zlib: Optional, adds compression / uncompression capabilities to selected LLVM tools.

If it's optional, why do we enable it ?

> +HOST_LLVM_DEPENDENCIES = host-python host-zlib
> +
> +# Don't build clang libcxx libcxxabi lldb compiler-rt lld polly as llvm subprojects
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PROJECTS=""
> +
> +# Disable CCACHE
> +HOST_LLVM_CONF_OPTS += -DLLVM_CCACHE_BUILD=OFF

Why do we disable ccache ? Buildroot has ccache support, and for
something big like LLVM, it seems useful to use it.

> +
> +# Disable Build GlobalIsel

This comment is really useless: it doesn't explain *anything* more than
what the code show. So either don't put such a comment, or make it
actually useful by explaining what GlobalIsel is.

> +HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
> +
> +# * Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
> +#   Ninja is not supported yet by Buildroot

This is not correct, we do have host-ninja, and a number of meson-based
packages are using ninja. I'm a bit surprised that you need to pass
this, since we're not passing it for any other CMake-based package in
Buildroot. Is this really needed ?

> +HOST_LLVM_CONF_OPTS += -G "Unix Makefiles"
> +
> +# * LLVM_BUILD_UTILS: Build LLVM utility binaries. If OFF, just generate build targets.

This comment is also not very useful. Explain *why* we are doing
things, not what we are doing, because it's obvious that
LLVM_BUILD_UTILS=ON will build the LLVM utility binaries.

> +HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=ON
> +
> +# * LLVM_INSTALL_UTILS: Include utility binaries in the 'install' target. ON for host.
> +#   Utils : FileCheck, KillTheDoctor, llvm-PerfectShuffle, count, not, yaml-bench
> +HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=ON
> +
> +# * LLVM_ENABLE_LIBEDIT: Use libedit if available

Do we really need to replicate the documentation of each option ?

> +#   Disabled since no host-libedit
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
> +
> +# * LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target. OFF
> +#   We also want llvm libraries and modules.

In fact I'm not sure I like the fact that you have the option
documentation, and then the explanation of what we're doing with it.
It's very verbose for no good reason. Probably something like this
would be sufficient:

# We to install llvm libraries and modules.

> +HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
> +
> +# * LLVM_APPEND_VC_REV "Append the version control system revision id to LLVM version OFF
> +#   We build from a release archive without vcs

Ditto.

> +# * LLVM_ENABLE_BACKTRACES: Enable embedding backtraces on crash ON
> +#   Use backtraces on crash to report toolchain issue.

issues.

> +# * LLVM_ENABLE_THREADS: Use threads if available ON
> +#   Keep threads enabled

Why "Keep" ? Just "Enable thread support"

> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON
> +
> +# * LLVM_ENABLE_ZLIB: Use zlib for compression/decompression if available ON
> +#   Keep zlib support enabled

Same.

> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_ZLIB=ON
> +
> +# * LLVM_ENABLE_PIC: Build Position-Independent Code ON
> +#   We don't use llvm for static only build, so enable PIC
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PIC=ON
> +
> +# * LLVM_ENABLE_WARNINGS: Enable compiler warnings ON
> +#   Keep compiler warning enabled
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WARNINGS=ON
> +
> +# * LLVM_ENABLE_PEDANTIC: Compile with pedantic enabled ON
> +#   Keep pedantic enabled
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PEDANTIC=ON
> +
> +# * LLVM_ENABLE_WERROR: Fail and stop if a warning is triggered OFF
> +#   Keep Werror disabled
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WERROR=OFF

Again, all of those descriptions are too verbose IMO.

> +# * LLVM_POLLY_BUILD: Build LLVM with Polly ON
> +#   Keep it enabled, if POLLY is not in-tree it will not be built
> +HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_BUILD=ON

At the beginning of the .mk file in a comment you say " Don't build
clang libcxx libcxxabi lldb compiler-rt lld polly as llvm subprojects".
And here you say you want to build Polly. I have no idea what Polly is,
but it doesn't seem very consistent.

> +# * LINK_POLLY_INTO_TOOLS: Static link Polly into tools ON

Also: don't repeat the option name in the comment, that's really
useless.

> +HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_LINK_INTO_TOOLS=ON
> +
> +# * LLVM_INCLUDE_TOOLS: Generate build targets for the LLVM tools ON
> +HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
> +
> +# * LLVM_BUILD_TOOLS: Build the LLVM tools

That's another example of a totally useless comment. BUILD_TOOLS=ON is
clear that you enable the tools.

> +# * LLVM_INCLUDE_UTILS: Generate build targets for the LLVM utils.
> +#   Enabled for host, disabled for the target.

That's all obvious from LLVM_INCLUDE_UTILS=ON. A comment is useful if
it says *why* we are doing something, not *what* we are doing.

> +HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=ON
> +
> +# Do not build llvm runtime libraries
> +HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
> +	-DLLVM_INCLUDE_RUNTIMES=OFF
> +
> +# * LLVM_BUILD_EXAMPLES: Build the LLVM example programs OFF
> +#   Don't build examples
> +HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXAMPLES=OFF \
> +	-DLLVM_INCLUDE_EXAMPLES=OFF
> +
> +# * LLVM_BUILD_TESTS: Build LLVM unit tests OFF
> +#   Don't build tests
> +HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TESTS=OFF
> +
> +# * LLVM_INCLUDE_TESTS: Generate build targets for the LLVM unit tests OFF
> +#   Don't build llvm unit tests
> +HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
> +
> +# * LLVM_INCLUDE_GO_TESTS: Include the Go bindings tests in test build targets OFF
> +#   Don't build Go tests
> +HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_GO_TESTS=OFF
> +
> +# * LLVM_BUILD_DOCS: Build the llvm documentation OFF
> +#   Disable llvm documentation
> +HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_DOCS=OFF
> +
> +# * LLVM_INCLUDE_DOCS: Generate build targets for llvm documentation OFF
> +#   Don't build llvm documentation
> +HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_DOCS=OFF
> +
> +# * LLVM_ENABLE_DOXYGEN: Use doxygen to generate llvm API documentation OFF
> +#   Don't build llvm API documentation
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_DOXYGEN=OFF
> +
> +# * LLVM_ENABLE_SPHINX: Use Sphinx to generate llvm documentation OFF
> +#   Don't build llvm documentation
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_SPHINX=OFF
> +
> +# * LLVM_ENABLE_OCAMLDOC: Use OCaml bindings documentation OFF
> +#   Don't build llvm documentation
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_OCAMLDOC=OFF

This is really verbose, and could be done in one assignment of
HOST_LLVM_CONF_OPTS, since it's obvious why we disable all this stuff.

> +# * LLVM_ENABLE_CXX1Y: Compile with C++1y enabled OFF
> +#   Enable C++ and C++11 support if BR2_INSTALL_LIBSTDCPP=y
> +HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)

This looks weird. Is LLVM_ENABLE_CXX1Y about LLVM using C++11 ? If so
then it doesn't make sense to look at BR2_INSTALL_LIBSTDCPP, because
this option indicates a property of the target toolchain.

> +# Install libLLVM and tools in HOST_DIR/usr
> +HOST_LLVM_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr

This is not useful as CMAKE_INSTALL_PREFIX is already passed by the
package infrastructure, and it's actually wrong because the prefix for
all host tools should now be $(HOST_DIR).

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant Valentin Korenblit
@ 2018-04-01 20:46   ` Thomas Petazzoni
  2018-04-01 22:50     ` Arnout Vandecappelle
  0 siblings, 1 reply; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:46 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:37 +0200, Valentin Korenblit wrote:

> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
> index 71fcaa2b8e..4e58c96e0f 100644
> --- a/package/llvm/llvm.mk
> +++ b/package/llvm/llvm.mk
> @@ -10,13 +10,16 @@ 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-zlib: Optional, adds compression / uncompression capabilities to selected LLVM tools.
>  HOST_LLVM_DEPENDENCIES = host-python host-zlib
> +LLVM_DEPENDENCIES = host-llvm zlib
>  
>  # 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

And ? I also don't understand why this comment is added in PATCH 02 and
not PATCH 01.

>  HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PROJECTS=""
>  
>  # Disable CCACHE
> @@ -28,166 +31,238 @@ HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
>  # * Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
>  #   Ninja is not supported yet by Buildroot
>  HOST_LLVM_CONF_OPTS += -G "Unix Makefiles"
> +LLVM_CONF_OPTS += -G "Unix Makefiles"

Same comment as for PATCH 01, do we really need to pass this
explicitly ? How do all other CMake packages in Buildroot work ?

> +# Use native llvm-tblgen from host-llvm (needed for cross-compilation)
> +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) returns 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

istalled -> installed

> +# 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

I don't understand why this is done as a post-install staging hook. Is
llvm-config build by host-llvm or llvm ? Is it needed for the build of
llvm, or for the build of stuff (like mesa3d) that will link against
the llvm library ?

>  # * LLVM_BUILD_UTILS: Build LLVM utility binaries. If OFF, just generate build targets.
> +#   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
> +LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=OFF

Seeing all of this, I am not longer sure I like this per-option
explanations anymore.

Maybe something like:

# FOO_BAZ=ON, because ...
# BAZ_BAR=OFF, because ...
HOST_LLVM_CONF_OPTS = \
	... \
	...

# BAZ_BLEH=OFF, because ...
LLVM_CONF_OPTS = \
	... \
	...

And by having comments only for the interesting options, not only for
the obvious stuff.

>  # * BUILD_SHARED_LIBS Build all libraries as shared libraries instead of static
>  #   It is only recommended to be used by LLVM developers.To build LLVM as a single
>  #   shared library, we should use the LLVM_BUILD_LLVM_DYLIB option.

I know this comment was already there in PATCH 01, but I believe a more
useful explanation would be:

BUILD_SHARED_LIBS has a misleading name. It is in fact an option for
LLVM developers to build all LLVM libraries are 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.


>  # * CMAKE_BUILD_TYPE: Set build type Debug, Release, RelWithDebInfo, and MinSizeRel.
>  #   Default is Debug. Use the Release build which requires considerably less space.
>  HOST_LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
> +LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release

CMAKE_BUILD_TYPE for target package is already passed by the
cmake-package infrastructure, so you shouldn't override that.

>  # Get target architecture
>  HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
>  
>  # Build backend for target architecture
>  HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
> +LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
>  
>  # 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)

Is there a difference between -DLLVM_TARGETS_TO_BUILD and
-DLLVM_TARGET_ARCH ? You pass the same value to both ?

>  # * LLVM_ENABLE_CXX1Y: Compile with C++1y enabled OFF
>  #   Enable C++ and C++11 support if BR2_INSTALL_LIBSTDCPP=y
>  HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
> +LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)

This time, this line makes sense (for the target LLVM).

>  # Builds a release tablegen that gets used during the LLVM build.
>  HOST_LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
> +LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON

You need to build tablegen in the target llvm ?

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU
  2018-03-30 20:33         ` Valentin Korenblit
@ 2018-04-01 20:47           ` Thomas Petazzoni
  0 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:47 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri, 30 Mar 2018 22:33:49 +0200, Valentin Korenblit wrote:

> I've just tested your suggestions, but finally we also need to build amdgpu target for host. The reason is that
> llvm-config (host version installed in STAGING) will output only x86 when executing llvm-config --targets-built.
> This is because it stores information related to the build where it comes from.

OK. Then just add a comment in the .mk file that explains this.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support Valentin Korenblit
@ 2018-04-01 20:53   ` Thomas Petazzoni
  2018-04-02 10:05     ` Valentin Korenblit
  0 siblings, 1 reply; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:53 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:39 +0200, Valentin Korenblit wrote:

> +config BR2_PACKAGE_MESA3D_LLVM
> +	bool "mesa3d w/ llvm"

We're already under the mesa3d option, so repeating mesa3d in the
prompt is not useless. Just "llvm support" is enough.

Should the option be: bool "llvmpipe" ? Or is LLVM used by mesa3d for
something else ?

> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> +	select BR2_PACKAGE_LLVM
> +
> +comment "mesa3d w/ llvm needs llvm"
> +	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS

This comment doesn't make sense: BR2_PACKAGE_LLVM_ARCH_SUPPORTS is an
architecture limitation, and therefore that the user can do about it.
Just drop this comment.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 05/11] package/llvm: enable ARM
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 05/11] package/llvm: enable ARM Valentin Korenblit
@ 2018-04-01 20:53   ` Thomas Petazzoni
  0 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:53 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:40 +0200, Valentin Korenblit wrote:
> This patch adds LLVM support for ARM
> 
> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>

To be honest, I don't really see why PATCH 05 and PATCH 06 are not
directly part of PATCH 01 introducing llvm. They don't do anything
except adding new architectures in the list.

But that's a minor nit, and it's OK to keep things as-is.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 07/11] package/clang: new host package
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 07/11] package/clang: new host package Valentin Korenblit
  2018-03-30 16:56   ` Matthew Weber
@ 2018-04-01 20:56   ` Thomas Petazzoni
  1 sibling, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 20:56 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:42 +0200, Valentin Korenblit wrote:

> diff --git a/package/clang/Config.in.host b/package/clang/Config.in.host
> new file mode 100644
> index 0000000000..61a7ed59f0
> --- /dev/null
> +++ b/package/clang/Config.in.host
> @@ -0,0 +1,8 @@
> +config BR2_PACKAGE_HOST_CLANG
> +	bool "host clang"
> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> +	help
> +	  Clang is a C/C++, Objective C/C++ and OpenCL C front-end
> +	  for the LLVM compiler.
> +
> +	  http://clang.llvm.org/

Do we need a visible Config.in.host option ? I don't think we need it,
since host-clang is merely a build dependency of clang.

> +# Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
> +HOST_CLANG_CONF_OPTS += -G "Unix Makefiles"

Why do we need this ? No other CMake package has that.

> +# Select Release build
> +HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release

Do we need to do that in the cmake-package infrastructure instead ?

> +# Build tools enabled
> +HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
> +
> +# Don't build examples
> +HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
> +
> +# Don't build doc
> +HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
> +
> +# Don't build tests
> +HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF
> +
> +# Specify path to host's llvm-config
> +HOST_CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(HOST_DIR)/bin/llvm-config

All that stuff it too verbose, the comments are not useful at all, just
do a single HOST_CLANG_CONF_OPTS assignment.

> +# Install clang in  HOST_DIR/usr
> +HOST_CLANG_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr

Like for LLVM, this is not needed as it is passed by the cmake-package
infrastructure, and the correct value is $(HOST_DIR), not
$(HOST_DIR)/usr.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 08/11] package/clang: enable target variant
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 08/11] package/clang: enable target variant Valentin Korenblit
  2018-03-30  9:07   ` Thomas Petazzoni
  2018-03-30 17:58   ` Matthew Weber
@ 2018-04-01 21:25   ` Thomas Petazzoni
  2 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 21:25 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:43 +0200, Valentin Korenblit wrote:
> This patch provides Clang for the target, tools and libraries.
> 
> In this package we have to deal with the same kind of problem we encountered
> when building mesa3d with llvm support: llvm-config (host-version) had to be
> copied to STAGING_DIR/usr/bin.

I don't see why it's a problem in mesa3d and in this package. Having
the <foo>-config stuff in $(STAGING_DIR) is the standard thing in
Buildroot, so there's nothing crazy or unusual about it.

> In this case, we need llvm-tblgen from host
> to be installed in STAGING_DIR/usr/bin for cross-compiling clang.

This is however a bit unusual, and perhaps we should keep llvm-tlbgen
only in $(HOST_DIR).

> We need libclang for the target because it is used by all OpenCL implementations.

I find this assertion a bit affirmative. Do *all* OpenCL
implementations in the world need clang ? Probably not.

> In this series, Clover is provided.

Perhaps a better wording is needed:

We need libclang to build a number of OpenCL implementations. A later
patch in this series will enable Clover, the OpenCL implementation part
of Mesa3D, which requires libclang.

> diff --git a/package/clang/clang.mk b/package/clang/clang.mk
> index 5ea0bb05f9..c2b83a8e60 100644
> --- a/package/clang/clang.mk
> +++ b/package/clang/clang.mk
> @@ -10,31 +10,61 @@ 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 = host-clang llvm
>  
>  # Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
>  HOST_CLANG_CONF_OPTS += -G "Unix Makefiles"
> +CLANG_CONF_OPTS += -G "Unix Makefiles"
> +
> +# This option is needed. Otherwise multiple shared libs (libclangAST.so,
> +# libclangBasic.so, libclangFrontend.so, etc.) will generated. As a final

will *be* generated

> +# 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
> +
> +# Copy llvm-tblgen (host variant) to STAGING_DIR
> +define CLANG_COPY_LLVM_TBLGEN_TO_STAGING_DIR
> +	$(INSTALL) -D -m 0755 $(HOST_DIR)/bin/llvm-tblgen $(STAGING_DIR)/usr/bin/llvm-tblgen
> +endef
> +CLANG_PRE_CONFIGURE_HOOKS = CLANG_COPY_LLVM_TBLGEN_TO_STAGING_DIR

Why does llvm-tblgen *has* to be in STAGING_DIR ?

>  # Select Release build
>  HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
> +CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release

Not needed, it's passed by the package infrastructure.

> +
> +# Make it explicit that we are cross-compiling
> +CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
>  
>  # Build tools enabled
>  HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
> +CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
>  
>  # Don't build examples
>  HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
> +CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
>  
>  # Don't build doc
>  HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
> +CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
>  
>  # Don't build tests
>  HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF
> +CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF

This is also too verbose.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 09/11] package/libclc: new package
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 09/11] package/libclc: new package Valentin Korenblit
@ 2018-04-01 21:29   ` Thomas Petazzoni
  2018-04-03 12:27     ` Valentin Korenblit
  0 siblings, 1 reply; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 21:29 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:44 +0200, Valentin Korenblit wrote:
> 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.

I don't see where your .mk file is doing this. And it wouldn't work
because Buildroot removes $(TARGET_DIR)/usr/include entirely in its
target-finalize step.

When you say "manually", do you mean that you have to
copy /usr/include/clc from your build machine to your target once the
target has booted ? If that's the case, then we really have a problem
here, the target should just work.

> +LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
> +LIBCLC_SITE = https://git.llvm.org/git/libclc
> +LIBCLC_SITE_METHOD = git

I assume they don't have a stable release you could use ?

This lacks LICENSE and LICENSE_FILES.

> +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, simply use
> +# HOSTCXX_NOCCACHE.

Why not HOSTCXX ?

> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \

Why are you using the version in HOST_DIR, and not the one in
STAGING_DIR ?

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support
  2018-03-29 11:33 ` [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support Valentin Korenblit
@ 2018-04-01 21:32   ` Thomas Petazzoni
  2018-04-02  5:23     ` Erik Larsson
  2018-04-02 10:36     ` Valentin Korenblit
  0 siblings, 2 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-01 21:32 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 29 Mar 2018 13:33:45 +0200, Valentin Korenblit wrote:

> diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
> index e99e737d31..bad7ac4339 100644
> --- a/package/mesa3d/Config.in
> +++ b/package/mesa3d/Config.in
> @@ -33,6 +33,22 @@ config BR2_PACKAGE_MESA3D_LLVM
>  comment "mesa3d w/ llvm needs llvm"
>  	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
>  
> +config BR2_PACKAGE_MESA3D_OPENCL
> +	bool "mesa3d OpenCL"

Just:

	bool "OpenCL"

> +	depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600

This is certainly not really understanding how OpenCL works, but why do
you need this Gallium driver compiled in? Does the result only works on
a system with an AMD GPU ?

> +	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_ELFUTILS

Interesting that elfutils is needed here.

> diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
> index 498ad57eed..1df28c43cb 100644
> --- a/package/mesa3d/mesa3d.mk
> +++ b/package/mesa3d/mesa3d.mk
> @@ -233,4 +233,13 @@ else
>  MESA3D_CONF_OPTS += --disable-lmsensors
>  endif
>  
> +# Clover requires libelf

Comment not really useful, it's obvious from the code below.

> +ifeq ($(BR2_PACKAGE_MESA3D_OPENCL),y)
> +MESA3D_DEPENDENCIES += clang elfutils libclc
> +MESA3D_CONF_OPTS += --enable-opencl \
> +	--with-clang-libdir=$(STAGING_DIR)/usr/lib
> +else
> +MESA3D_CONF_OPTS += --disable-opencl
> +endif
> +
>  $(eval $(autotools-package))

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant
  2018-04-01 20:46   ` Thomas Petazzoni
@ 2018-04-01 22:50     ` Arnout Vandecappelle
  0 siblings, 0 replies; 42+ messages in thread
From: Arnout Vandecappelle @ 2018-04-01 22:50 UTC (permalink / raw)
  To: buildroot



On 01-04-18 22:46, Thomas Petazzoni wrote:
>>  # * LLVM_ENABLE_CXX1Y: Compile with C++1y enabled OFF
>>  #   Enable C++ and C++11 support if BR2_INSTALL_LIBSTDCPP=y
>>  HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
>> +LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
> This time, this line makes sense (for the target LLVM).

 Actually, no. I assume that LLVM_ENABLE_CXX1Y enables C++11 features, but
LIBSTDCPP can still be on for gcc <= 4.8 which has no or little support for C++11.

 Regards,
 Arnout

-- 
Arnout Vandecappelle                          arnout@mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support
  2018-04-01 21:32   ` Thomas Petazzoni
@ 2018-04-02  5:23     ` Erik Larsson
  2018-04-02  6:51       ` Thomas Petazzoni
  2018-04-02 10:36     ` Valentin Korenblit
  1 sibling, 1 reply; 42+ messages in thread
From: Erik Larsson @ 2018-04-02  5:23 UTC (permalink / raw)
  To: buildroot

Hi Valentin, Thomas, all!

2018-04-01 23:32 GMT+02:00 Thomas Petazzoni <thomas.petazzoni@bootlin.com>:
> Hello,
>
> On Thu, 29 Mar 2018 13:33:45 +0200, Valentin Korenblit wrote:
>
>> diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
>> index e99e737d31..bad7ac4339 100644
>> --- a/package/mesa3d/Config.in
>> +++ b/package/mesa3d/Config.in
>> @@ -33,6 +33,22 @@ config BR2_PACKAGE_MESA3D_LLVM
>>  comment "mesa3d w/ llvm needs llvm"
>>       depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
>>
>> +config BR2_PACKAGE_MESA3D_OPENCL
>> +     bool "mesa3d OpenCL"
>
> Just:
>
>         bool "OpenCL"
>
>> +     depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600
>
> This is certainly not really understanding how OpenCL works, but why do
> you need this Gallium driver compiled in? Does the result only works on
> a system with an AMD GPU ?

What about creating a virtual package for OpenCL just as with OpenVG?

I've started to work on patch series were OpenCL is a virtual package
but I'm not 100% finished. I still need more testing and add some
packages that do not use the new virtual package of OpenCL. I also
need to add more platforms that provide OpenCL. I've pushed some
patches to GitHub that is my draft/work-in-progress branch,
https://github.com/ortogonal/buildroot/commits/wip/opencl. If you like
it I can speed up the work with it!

>
>> +     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_ELFUTILS
>
> Interesting that elfutils is needed here.
>
>> diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
>> index 498ad57eed..1df28c43cb 100644
>> --- a/package/mesa3d/mesa3d.mk
>> +++ b/package/mesa3d/mesa3d.mk
>> @@ -233,4 +233,13 @@ else
>>  MESA3D_CONF_OPTS += --disable-lmsensors
>>  endif
>>
>> +# Clover requires libelf
>
> Comment not really useful, it's obvious from the code below.
>
>> +ifeq ($(BR2_PACKAGE_MESA3D_OPENCL),y)
>> +MESA3D_DEPENDENCIES += clang elfutils libclc
>> +MESA3D_CONF_OPTS += --enable-opencl \
>> +     --with-clang-libdir=$(STAGING_DIR)/usr/lib
>> +else
>> +MESA3D_CONF_OPTS += --disable-opencl
>> +endif
>> +
>>  $(eval $(autotools-package))
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
> Embedded Linux and Kernel engineering
> https://bootlin.com
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

Regards,
Erik

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support
  2018-04-02  5:23     ` Erik Larsson
@ 2018-04-02  6:51       ` Thomas Petazzoni
  0 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-02  6:51 UTC (permalink / raw)
  To: buildroot

Hello Erik,

On Mon, 2 Apr 2018 07:23:23 +0200, Erik Larsson wrote:

> > This is certainly not really understanding how OpenCL works, but why do
> > you need this Gallium driver compiled in? Does the result only works on
> > a system with an AMD GPU ?  
> 
> What about creating a virtual package for OpenCL just as with OpenVG?

We will certainly need something like this at some point. Though I
believe it can be handled separately from Valentin's series. I think in
Valentin's series the only package that will need to be reworked to
make use of an opencl virtual package is clinfo, and it will be
trivial to convert it to use the opencl virtual package instead of
directly mesa3d.

> I've started to work on patch series were OpenCL is a virtual package
> but I'm not 100% finished. I still need more testing and add some
> packages that do not use the new virtual package of OpenCL. I also
> need to add more platforms that provide OpenCL. I've pushed some
> patches to GitHub that is my draft/work-in-progress branch,
> https://github.com/ortogonal/buildroot/commits/wip/opencl. If you like
> it I can speed up the work with it!

This definitely looks nice to have. You forgot to update the
<pkg>_PROVIDES line in the OpenCL providers. For example:

IMX_GPU_VIV_PROVIDES = libegl libgles libopenvg

must be updated to:

IMX_GPU_VIV_PROVIDES = libegl libgles libopenvg libopencl

Your tesseract-ocr change doesn't look good:

+config BR2_PACKAGE_TESSERACT_OCR_OPENCL_SUPPORT
+	bool "tesseract-ocr with OpenCL support"
+	depends on BR2_PACKAGE_HAS_LIBOPENVG

The last line should be about BR2_PACKAGE_HAS_LIBOPENCL.

Also, in all packages, we want to pass an explicit --enable-<foo> to
enable the feature, instead of letting the autodetection do its work.
So typically, we want:

ifeq ($(BR2_<pkg>_FEATURE),y)
<pkg>_DEPENDENCIES += libfeature
<pkg>_CONF_OPTS += --enable-feature
else
<pkg>_CONF_OPTS += disable-feature
endif

There are a few other nits here and there that will be either to point
when the series gets posted. But generally, it looks simple and
straightforward, so it's on the right track!

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support
  2018-04-01 20:53   ` Thomas Petazzoni
@ 2018-04-02 10:05     ` Valentin Korenblit
  2018-04-02 12:01       ` Thomas Petazzoni
  0 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-04-02 10:05 UTC (permalink / raw)
  To: buildroot


Hello Thomas,

On 01/04/2018 22:53, Thomas Petazzoni wrote:
> Hello,
>
> On Thu, 29 Mar 2018 13:33:39 +0200, Valentin Korenblit wrote:
>
>> +config BR2_PACKAGE_MESA3D_LLVM
>> +	bool "mesa3d w/ llvm"
> We're already under the mesa3d option, so repeating mesa3d in the
> prompt is not useless. Just "llvm support" is enough.
>
> Should the option be: bool "llvmpipe" ? Or is LLVM used by mesa3d for
> something else ?

We could leave "LLVM" because llvmpipe is not the only feature, r600 needs
llvm AMDGPU backend when llvm is selected, and then we could add radeonsi
Gallium Driver for newer GPUs.

>> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
>> +	select BR2_PACKAGE_LLVM
>> +
>> +comment "mesa3d w/ llvm needs llvm"
>> +	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> This comment doesn't make sense: BR2_PACKAGE_LLVM_ARCH_SUPPORTS is an
> architecture limitation, and therefore that the user can do about it.
> Just drop this comment.

Ok, perfect.

>
> Thanks,
>
> Thomas

Thanks,

Valentin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support
  2018-04-01 21:32   ` Thomas Petazzoni
  2018-04-02  5:23     ` Erik Larsson
@ 2018-04-02 10:36     ` Valentin Korenblit
  2018-04-02 12:03       ` Thomas Petazzoni
  1 sibling, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-04-02 10:36 UTC (permalink / raw)
  To: buildroot


Hello Thomas,

On 01/04/2018 23:32, Thomas Petazzoni wrote:
> Hello,
>
> On Thu, 29 Mar 2018 13:33:45 +0200, Valentin Korenblit wrote:
>
>> diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
>> index e99e737d31..bad7ac4339 100644
>> --- a/package/mesa3d/Config.in
>> +++ b/package/mesa3d/Config.in
>> @@ -33,6 +33,22 @@ config BR2_PACKAGE_MESA3D_LLVM
>>   comment "mesa3d w/ llvm needs llvm"
>>   	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
>>   
>> +config BR2_PACKAGE_MESA3D_OPENCL
>> +	bool "mesa3d OpenCL"
> Just:
>
> 	bool "OpenCL"
>
>> +	depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600
> This is certainly not really understanding how OpenCL works, but why do
> you need this Gallium driver compiled in? Does the result only works on
> a system with an AMD GPU ?

Mesa's OpenCL implementation works only on AMD GPUs using Gallium Drivers.

>> +	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_ELFUTILS
> Interesting that elfutils is needed here.
>
>> diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
>> index 498ad57eed..1df28c43cb 100644
>> --- a/package/mesa3d/mesa3d.mk
>> +++ b/package/mesa3d/mesa3d.mk
>> @@ -233,4 +233,13 @@ else
>>   MESA3D_CONF_OPTS += --disable-lmsensors
>>   endif
>>   
>> +# Clover requires libelf
> Comment not really useful, it's obvious from the code below.
>
>> +ifeq ($(BR2_PACKAGE_MESA3D_OPENCL),y)
>> +MESA3D_DEPENDENCIES += clang elfutils libclc
>> +MESA3D_CONF_OPTS += --enable-opencl \
>> +	--with-clang-libdir=$(STAGING_DIR)/usr/lib
>> +else
>> +MESA3D_CONF_OPTS += --disable-opencl
>> +endif
>> +
>>   $(eval $(autotools-package))
> Thanks!
>
> Thomas

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support
  2018-04-02 10:05     ` Valentin Korenblit
@ 2018-04-02 12:01       ` Thomas Petazzoni
  0 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-02 12:01 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 2 Apr 2018 12:05:51 +0200, Valentin Korenblit wrote:

> > Should the option be: bool "llvmpipe" ? Or is LLVM used by mesa3d for
> > something else ?  
> 
> We could leave "LLVM" because llvmpipe is not the only feature, r600 needs
> llvm AMDGPU backend when llvm is selected, and then we could add radeonsi
> Gallium Driver for newer GPUs.

OK, so "llvm support" would be appropriate.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support
  2018-04-02 10:36     ` Valentin Korenblit
@ 2018-04-02 12:03       ` Thomas Petazzoni
  0 siblings, 0 replies; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-02 12:03 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 2 Apr 2018 12:36:05 +0200, Valentin Korenblit wrote:

> > 	bool "OpenCL"
> >  
> >> +	depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600  
> > This is certainly not really understanding how OpenCL works, but why do
> > you need this Gallium driver compiled in? Does the result only works on
> > a system with an AMD GPU ?  
> 
> Mesa's OpenCL implementation works only on AMD GPUs using Gallium Drivers.

OK. Maybe a comment on top of this dependency would make sense then,
and perhaps the commit title should be "enable OpenCL on AMD GPUs" or
something like that.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 09/11] package/libclc: new package
  2018-04-01 21:29   ` Thomas Petazzoni
@ 2018-04-03 12:27     ` Valentin Korenblit
  2018-04-03 15:17       ` Thomas Petazzoni
  0 siblings, 1 reply; 42+ messages in thread
From: Valentin Korenblit @ 2018-04-03 12:27 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

On 01/04/2018 23:29, Thomas Petazzoni wrote:
> Hello,
>
> On Thu, 29 Mar 2018 13:33:44 +0200, Valentin Korenblit wrote:
>> 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.
> I don't see where your .mk file is doing this. And it wouldn't work
> because Buildroot removes $(TARGET_DIR)/usr/include entirely in its
> target-finalize step.
>
> When you say "manually", do you mean that you have to
> copy /usr/include/clc from your build machine to your target once the
> target has booted ? If that's the case, then we really have a problem
> here, the target should just work.

Exactly, I was doing it manually after booting. Mesa uses pkg-config to
get the includedir of libclc: https://pastebin.com/adzL8vd4

Do you think it is ok to override configure.ac from Mesa to specify
another path? And in that case, where should I place all these headers?

>
>> +LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
>> +LIBCLC_SITE = https://git.llvm.org/git/libclc
>> +LIBCLC_SITE_METHOD = git
> I assume they don't have a stable release you could use ?

There is release_38, but the last commit is from 2 years ago. Master
has some recent activity.

>
> This lacks LICENSE and LICENSE_FILES.
>
>> +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, simply use
>> +# HOSTCXX_NOCCACHE.
> Why not HOSTCXX ?
>
>> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> Why are you using the version in HOST_DIR, and not the one in
> STAGING_DIR ?

I will check this.

>
> Best regards,
>
> Thomas

Best regards,

Valentin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 09/11] package/libclc: new package
  2018-04-03 12:27     ` Valentin Korenblit
@ 2018-04-03 15:17       ` Thomas Petazzoni
  2018-04-03 16:26         ` Valentin Korenblit
  0 siblings, 1 reply; 42+ messages in thread
From: Thomas Petazzoni @ 2018-04-03 15:17 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue, 3 Apr 2018 14:27:16 +0200, Valentin Korenblit wrote:

> >> 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.  
> > I don't see where your .mk file is doing this. And it wouldn't work
> > because Buildroot removes $(TARGET_DIR)/usr/include entirely in its
> > target-finalize step.
> >
> > When you say "manually", do you mean that you have to
> > copy /usr/include/clc from your build machine to your target once the
> > target has booted ? If that's the case, then we really have a problem
> > here, the target should just work.  
> 
> Exactly, I was doing it manually after booting. Mesa uses pkg-config to
> get the includedir of libclc: https://pastebin.com/adzL8vd4
> 
> Do you think it is ok to override configure.ac from Mesa to specify
> another path? And in that case, where should I place all these headers?

Most likely yes, they should be in another folder, but I would need to
have a look. Could you push to some public Git repository the latest
status of your LLVM patch series, so that I can do a build, and see
what it looks like ?

> >> +LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
> >> +LIBCLC_SITE = https://git.llvm.org/git/libclc
> >> +LIBCLC_SITE_METHOD = git  
> > I assume they don't have a stable release you could use ?  
> 
> There is release_38, but the last commit is from 2 years ago. Master
> has some recent activity.

OK. Then just add a comment above that says exactly this.

> >> +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, simply use
> >> +# HOSTCXX_NOCCACHE.  
> > Why not HOSTCXX ?

Did you notice this comment as well ? :-)

> >> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \  
> > Why are you using the version in HOST_DIR, and not the one in
> > STAGING_DIR ?  
> 
> I will check this.

OK. Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Buildroot] [PATCH v4 09/11] package/libclc: new package
  2018-04-03 15:17       ` Thomas Petazzoni
@ 2018-04-03 16:26         ` Valentin Korenblit
  0 siblings, 0 replies; 42+ messages in thread
From: Valentin Korenblit @ 2018-04-03 16:26 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

On 03/04/2018 17:17, Thomas Petazzoni wrote:
> Hello,
>
> On Tue, 3 Apr 2018 14:27:16 +0200, Valentin Korenblit wrote:
>
>>>> 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.
>>> I don't see where your .mk file is doing this. And it wouldn't work
>>> because Buildroot removes $(TARGET_DIR)/usr/include entirely in its
>>> target-finalize step.
>>>
>>> When you say "manually", do you mean that you have to
>>> copy /usr/include/clc from your build machine to your target once the
>>> target has booted ? If that's the case, then we really have a problem
>>> here, the target should just work.
>> Exactly, I was doing it manually after booting. Mesa uses pkg-config to
>> get the includedir of libclc: https://pastebin.com/adzL8vd4
>>
>> Do you think it is ok to override configure.ac from Mesa to specify
>> another path? And in that case, where should I place all these headers?
> Most likely yes, they should be in another folder, but I would need to
> have a look. Could you push to some public Git repository the latest
> status of your LLVM patch series, so that I can do a build, and see
> what it looks like ?

I've just done it: https://github.com/vkorenblit/buildroot , branch llvm-v5.

>>>> +LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
>>>> +LIBCLC_SITE = https://git.llvm.org/git/libclc
>>>> +LIBCLC_SITE_METHOD = git
>>> I assume they don't have a stable release you could use ?
>> There is release_38, but the last commit is from 2 years ago. Master
>> has some recent activity.
> OK. Then just add a comment above that says exactly this.

Done

>
>>>> +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, simply use
>>>> +# HOSTCXX_NOCCACHE.
>>> Why not HOSTCXX ?
> Did you notice this comment as well ? :-)

Changed it to HOSTCXX.

>
>>>> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
>>> Why are you using the version in HOST_DIR, and not the one in
>>> STAGING_DIR ?
>> I will check this.

We need to use HOST_DIR because for compiling libclc a full installation of llvm/clang
is necessary. When STAGING_DIR is specified, the build stops as it cannot found llvm
binaries.

> OK. Thanks!
>
> Thomas

Best regards and thanks,

Valentin

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2018-04-03 16:26 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
2018-03-29 11:33 ` [Buildroot] [PATCH v4 01/11] package/llvm: new host package Valentin Korenblit
2018-04-01 20:36   ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant Valentin Korenblit
2018-04-01 20:46   ` Thomas Petazzoni
2018-04-01 22:50     ` Arnout Vandecappelle
2018-03-29 11:33 ` [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU Valentin Korenblit
2018-03-30  9:02   ` Thomas Petazzoni
2018-03-30 11:33     ` Valentin Korenblit
2018-03-30 18:08     ` Arnout Vandecappelle
2018-03-30 19:06       ` Thomas Petazzoni
2018-03-30 20:33         ` Valentin Korenblit
2018-04-01 20:47           ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support Valentin Korenblit
2018-04-01 20:53   ` Thomas Petazzoni
2018-04-02 10:05     ` Valentin Korenblit
2018-04-02 12:01       ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 05/11] package/llvm: enable ARM Valentin Korenblit
2018-04-01 20:53   ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 06/11] package/llvm: enable AArch64 Valentin Korenblit
2018-03-29 11:33 ` [Buildroot] [PATCH v4 07/11] package/clang: new host package Valentin Korenblit
2018-03-30 16:56   ` Matthew Weber
2018-03-30 20:24     ` Valentin Korenblit
2018-04-01 20:56   ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 08/11] package/clang: enable target variant Valentin Korenblit
2018-03-30  9:07   ` Thomas Petazzoni
2018-03-30 12:16     ` Valentin Korenblit
2018-03-30 12:37       ` Thomas Petazzoni
2018-03-30 17:58   ` Matthew Weber
2018-04-01 21:25   ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 09/11] package/libclc: new package Valentin Korenblit
2018-04-01 21:29   ` Thomas Petazzoni
2018-04-03 12:27     ` Valentin Korenblit
2018-04-03 15:17       ` Thomas Petazzoni
2018-04-03 16:26         ` Valentin Korenblit
2018-03-29 11:33 ` [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support Valentin Korenblit
2018-04-01 21:32   ` Thomas Petazzoni
2018-04-02  5:23     ` Erik Larsson
2018-04-02  6:51       ` Thomas Petazzoni
2018-04-02 10:36     ` Valentin Korenblit
2018-04-02 12:03       ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 11/11] package/clinfo: new package Valentin Korenblit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.