llvm for mesa3d
v4 cover llvm for mesa3d
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
Signature · 1 line
2.14.3
PATCH v4 1/11 package/llvm: new host package
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.
--- 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
DEVELOPERS +3 -0
@@ -1858,6 +1858,9 @@ N: Tzu-Jung Lee <[email protected]> F: package/dropwatch/ F: package/tstools/ +N: Valentin Korenblit <[email protected]> +F: package/llvm/ + N: Vanya Sergeev <[email protected]> F: package/lua-periphery/
package/Config.in.host +1 -0
@@ -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"
package/llvm/Config.in.host new file +17 -0
@@ -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
package/llvm/llvm.hash new file +3 -0
@@ -0,0 +1,3 @@ +# locally calculated +sha256 5fa7489fc0225b11821cab0362f5813a05f2bcf2533e8a4ea9c9c860168807b0 llvm-5.0.1.src.tar.xz +sha256 abd4d8794808bacb1eb6924d49efafd9ab6eef88faaaeb5d3cfa13ee3670d672 LICENSE.TXT
package/llvm/llvm.mk new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH v4 1/11 package/llvm: new host package
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!
Quoted 6 lines · Valentin Korenblit
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.
Quoted 9 lines
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.
Quoted 4 lines
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
Quoted 11 lines
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"
Quoted 5 lines
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 ?
Quoted 7 lines
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
Quoted 2 lines
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.
Quoted 2 lines
Mesa strongly recommends support for SSE2. Support for SSE3 and SSE4.1 will yield the most efficient code.
And ?
package/llvm/Config.in.host line 3
Quoted 9 lines
package/llvm/Config.in.host new file +3
-0@@ -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
package/llvm/Config.in.host line 4
Quoted 1 line
package/llvm/Config.in.host new file +1
-0+ 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.
package/llvm/Config.in.host line 11
Quoted 2 lines
package/llvm/Config.in.host new file +2
-0+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.
Quoted 8 lines
package/llvm/llvm.mk new file +2
-0@@ -0,0 +1,217 @@ +################################################################################ +#
package/llvm/llvm.mk line 12
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+# 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.
package/llvm/llvm.mk line 16
Quoted 3 lines
package/llvm/llvm.mk new file +3
-0+# 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 ?
package/llvm/llvm.mk line 23
Quoted 7 lines
package/llvm/llvm.mk new file +7
-0+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.
package/llvm/llvm.mk line 24
Quoted 2 lines
package/llvm/llvm.mk new file +2
-0+ +# 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.
package/llvm/llvm.mk line 29
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+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 ?
package/llvm/llvm.mk line 32
Quoted 3 lines
package/llvm/llvm.mk new file +3
-0+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.
package/llvm/llvm.mk line 39
Quoted 7 lines
package/llvm/llvm.mk new file +7
-0+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 ?
package/llvm/llvm.mk line 44
Quoted 5 lines
package/llvm/llvm.mk new file +5
-0+# 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.
package/llvm/llvm.mk line 48
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+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.
package/llvm/llvm.mk line 57
Quoted 2 lines
package/llvm/llvm.mk new file +2
-0+# * LLVM_ENABLE_BACKTRACES: Enable embedding backtraces on crash ON +# Use backtraces on crash to report toolchain issue.
issues.
package/llvm/llvm.mk line 73
Quoted 2 lines
package/llvm/llvm.mk new file +2
-0+# * LLVM_ENABLE_THREADS: Use threads if available ON +# Keep threads enabled
Why "Keep" ? Just "Enable thread support"
package/llvm/llvm.mk line 77
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON + +# * LLVM_ENABLE_ZLIB: Use zlib for compression/decompression if available ON +# Keep zlib support enabled
Same.
Quoted 7 lines
package/llvm/llvm.mk new file +7
-0+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
package/llvm/llvm.mk line 94
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+# 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.
package/llvm/llvm.mk line 102
Quoted 3 lines
package/llvm/llvm.mk new file +3
-0+# * 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.
package/llvm/llvm.mk line 104
Quoted 1 line
package/llvm/llvm.mk new file +1
-0+# * LINK_POLLY_INTO_TOOLS: Static link Polly into tools ON
Also: don't repeat the option name in the comment, that's really useless.
package/llvm/llvm.mk line 110
Quoted 6 lines
package/llvm/llvm.mk new file +6
-0+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.
package/llvm/llvm.mk line 115
Quoted 2 lines
package/llvm/llvm.mk new file +2
-0+# * 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.
Quoted 32 lines
package/llvm/llvm.mk new file +32
-0+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
package/llvm/llvm.mk line 157
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+# 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.
package/llvm/llvm.mk line 174
Quoted 3 lines
package/llvm/llvm.mk new file +3
-0+# * 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.
package/llvm/llvm.mk line 215
Quoted 2 lines
package/llvm/llvm.mk new file +2
-0+# 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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 2/11 package/llvm: enable target variant
In reply to Valentin KorenblitThis 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_TABLEGENCMAKE_CROSSCOMPILINGLLVM_DEFAULT_TARGET_TRIPLELLVM_HOST_TRIPLELLVM_TARGET_ARCHLLVM_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.
--- 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
package/Config.in +1 -0
@@ -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"
package/llvm/Config.in new file +18 -0
@@ -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
package/llvm/Config.in.host +0 -9
@@ -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
package/llvm/llvm.mk +79 -0
277 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH v4 2/11 package/llvm: enable target variant
Hello,
Quoted 8 lines · Valentin Korenblit
package/llvm/llvm.mk +0
-0@@ -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
package/llvm/llvm.mk LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz · line 22
Quoted 10 lines
package/llvm/llvm.mk +3
-0+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.
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 34
Quoted 8 lines
package/llvm/llvm.mk +1
-0HOST_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 ?
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 45
Quoted 10 lines
package/llvm/llvm.mk +10
-0+# 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
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 53
Quoted 8 lines
package/llvm/llvm.mk +8
-0+# 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 ?
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 62
Quoted 5 lines
package/llvm/llvm.mk +3
-0# * 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.
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 86
Quoted 3 lines
package/llvm/llvm.mk +0
-0# * 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.
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 143
Quoted 4 lines
package/llvm/llvm.mk +1
-0# * 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.
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 235
Quoted 10 lines
package/llvm/llvm.mk +2
-0# 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 ?
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF · line 240
Quoted 4 lines
package/llvm/llvm.mk +1
-0# * 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).
package/llvm/llvm.mk HOST_LLVM_CONF_OPTS += \ · line 275
Quoted 3 lines
package/llvm/llvm.mk +1
-0# 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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 2/11 package/llvm: enable target variant
Quoted 5 lines · Thomas Petazzoni
Quoted 4 lines
# *
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
Signature · 6 lines
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
PATCH v4 3/11 package/llvm: enable AMDGPU
In reply to Valentin KorenblitThe 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
---
Tested on HD6480 using Gallium Radeon R600 driver.
package/llvm/Config.in | 7 +++++++ package/llvm/llvm.mk | 6 ++++++ 2 files changed, 13 insertions(+)
package/llvm/Config.in +7 -0
@@ -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.
package/llvm/llvm.mk +6 -0
@@ -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)
Signature · 1 line
2.14.3
PATCH v4 3/11 package/llvm: enable AMDGPU
Hello Valentin,
Quoted 11 lines · Valentin Korenblit
package/llvm/Config.in +6
-0+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.package/llvm/llvm.mk +0
-0
package/llvm/llvm.mk LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF · line 232
Quoted 7 lines
package/llvm/llvm.mk +4
-0@@ -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 ?
package/llvm/llvm.mk LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF · line 237
Quoted 5 lines
package/llvm/llvm.mk +2
-0+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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 3/11 package/llvm: enable AMDGPU
Hello Thomas,
Quoted 18 lines · Thomas Petazzoni
Hello Valentin,
Quoted 14 lines · Valentin Korenblit
package/llvm/Config.in +6
-0+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.package/llvm/llvm.mk +0
-0@@ -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))
Quoted 10 lines
package/llvm/llvm.mk LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF · line 232
Quoted 4 lines
package/llvm/llvm.mk +4
-0+# 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.
Quoted 9 lines
package/llvm/llvm.mk LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF · line 237
Quoted 5 lines
package/llvm/llvm.mk +2
-0+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)" +endifThis doesn't look like a very extensible solution.
What about instead:
Quoted 7 lines
LLVM_TARGETS_TO_BUILD= $(HOST_LLVM_TARGET_ARCH)ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
LLVM_TARGETS_TO_BUILD:= $(LLVM_TARGETS_TO_BUILD);AMDGPU endifand then use
LLVM_TARGETS_TO_BUILDto pass -DLLVM_TARGETS_TO_BUILD.
That's much better, I'll do that.
Quoted 3 lines
Best regards,
Thomas
Best regards and thanks for the review,
Valentin
PATCH v4 3/11 package/llvm: enable AMDGPU
In reply to Thomas PetazzoniQuoted 39 lines · Thomas Petazzoni
Hello Valentin,
Quoted 11 lines · Valentin Korenblit
package/llvm/Config.in +6
-0+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.package/llvm/llvm.mk +0
-0package/llvm/llvm.mk LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF · line 232
Quoted 7 lines
package/llvm/llvm.mk +4
-0@@ -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 ?package/llvm/llvm.mk LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF · line 237
Quoted 5 lines
package/llvm/llvm.mk +2
-0+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)" +endifThis doesn't look like a very extensible solution.
What about instead:
Quoted 7 lines
LLVM_TARGETS_TO_BUILD= $(HOST_LLVM_TARGET_ARCH)ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
LLVM_TARGETS_TO_BUILD:= $(LLVM_TARGETS_TO_BUILD);AMDGPU endifand then use
LLVM_TARGETS_TO_BUILDto 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
Signature · 6 lines
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
PATCH v4 3/11 package/llvm: enable AMDGPU
Hello,
Quoted 8 lines · Arnout Vandecappelle
Or maybe
LLVM_TARGETS_TO_BUILD= $(HOST_LLVM_TARGET_ARCH)ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
LLVM_TARGETS_TO_BUILD+= AMDGPU
endif
Quoted 5 lines
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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 3/11 package/llvm: enable AMDGPU
Hello all,
Quoted 17 lines · Thomas Petazzoni
Hello,
Quoted 13 lines · Arnout Vandecappelle
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
}Quoted 3 lines
No, that's good.
Thomas
Best regards,
Valentin
PATCH v4 3/11 package/llvm: enable AMDGPU
Hello,
Quoted 3 lines · Valentin Korenblit
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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 4/11 package/mesa3d: enable llvm support
In reply to Valentin KorenblitThis 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.
---
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(-)
package/mesa3d/Config.in +8 -0
@@ -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
package/mesa3d/mesa3d.mk +14 -3
@@ -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))
Signature · 1 line
2.14.3
PATCH v4 4/11 package/mesa3d: enable llvm support
Hello,
package/mesa3d/Config.in menuconfig BR2_PACKAGE_MESA3D · line 29
Quoted 2 lines · Valentin Korenblit
package/mesa3d/Config.in +2
-0+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 ?
package/mesa3d/Config.in menuconfig BR2_PACKAGE_MESA3D · line 34
Quoted 5 lines
package/mesa3d/Config.in +5
-0+ 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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 4/11 package/mesa3d: enable llvm support
Hello Thomas,
Quoted 11 lines · Thomas Petazzoni
Hello,
package/mesa3d/Config.in menuconfig BR2_PACKAGE_MESA3D · line 29
Quoted 2 lines · Valentin Korenblit
package/mesa3d/Config.in +2
-0+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.
Quoted 8 lines
package/mesa3d/Config.in menuconfig BR2_PACKAGE_MESA3D · line 34
Quoted 5 lines
package/mesa3d/Config.in +5
-0+ depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS + select BR2_PACKAGE_LLVM + +comment "mesa3d w/ llvm needs llvm" + depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTSThis comment doesn't make sense:
BR2_PACKAGE_LLVM_ARCH_SUPPORTSis an architecture limitation, and therefore that the user can do about it. Just drop this comment.
Ok, perfect.
Quoted 4 lines
Thanks,
Thomas
Thanks,
Valentin
PATCH v4 4/11 package/mesa3d: enable llvm support
Hello,
Quoted 6 lines · Valentin Korenblit
Quoted 2 lines
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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 5/11 package/llvm: enable ARM
In reply to Valentin KorenblitThis patch adds LLVM support for ARM
---
Tested llvmpipe running glmark2-es2 on Raspberry Pi 2 and 3(32-bit)
package/llvm/Config.in | 2 ++ 1 file changed, 2 insertions(+)
package/llvm/Config.in +2 -0
@@ -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
Signature · 1 line
2.14.3
PATCH v4 5/11 package/llvm: enable ARM
Hello,
Quoted 3 lines · Valentin Korenblit
This patch adds LLVM support for ARM
Signed-off-by Valentin Korenblit <[email protected]>
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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 6/11 package/llvm: enable AArch64
In reply to Valentin KorenblitThis patch adds LLVM support for AArch64
---
Tested llvmpipe running glmark2-es2 on Raspberry Pi 3(64-bit)
package/llvm/Config.in | 2 ++ 1 file changed, 2 insertions(+)
package/llvm/Config.in +2 -0
@@ -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
Signature · 1 line
2.14.3
PATCH v4 7/11 package/clang: new host package
In reply to Valentin KorenblitThis patch provides Clang for the host, tools and libraries.
Clang is needed to build libclc, which is also provided in this series.
--- 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
DEVELOPERS +1 -0
@@ -1859,6 +1859,7 @@ F: package/dropwatch/ F: package/tstools/ N: Valentin Korenblit <[email protected]> +F: package/clang/ F: package/llvm/ N: Vanya Sergeev <[email protected]>
package/Config.in.host +1 -0
@@ -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"
package/clang/Config.in.host new file +8 -0
@@ -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/
package/clang/clang.hash new file +3 -0
@@ -0,0 +1,3 @@ +# locally calculated +sha256 135f6c9b0cd2da1aff2250e065946258eb699777888df39ca5a5b4fe5e23d0ff cfe-5.0.1.src.tar.xz +sha256 de4c79665f0f5688b0ace17cba6f8e0343925bb95e0949d66d47bbd4527310d6 LICENSE.txt
package/clang/clang.mk new file +40 -0
@@ -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))
Signature · 1 line
2.14.3
PATCH v4 7/11 package/clang: new host package
Valentin,
Quoted 47 lines · Valentin Korenblit
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 <[email protected]>--- 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.mkDEVELOPERS +1
-0@@ -1859,6 +1859,7 @@ F: package/dropwatch/ F: package/tstools/ N: Valentin Korenblit <[email protected]> +F: package/clang/ F: package/llvm/ N: Vanya Sergeev <[email protected]>package/Config.in.host +1
-0@@ -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"package/clang/Config.in.host new file +0
-0
package/clang/Config.in.host line 1
Quoted 1 line
package/clang/Config.in.host new file +1
-0@@ -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.
PATCH v4 7/11 package/clang: new host package
Hello Matthew,
Quoted 54 lines · Matthew Weber
Valentin,
Quoted 47 lines · Valentin Korenblit
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 <[email protected]>--- 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 100644package/clang/clang.mkDEVELOPERS +1
-0@@ -1859,6 +1859,7 @@ F: package/dropwatch/ F: package/tstools/ N: Valentin Korenblit <[email protected]> +F: package/clang/ F: package/llvm/ N: Vanya Sergeev <[email protected]>package/Config.in.host +1
-0@@ -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"package/clang/Config.in.host new file +0
-0package/clang/Config.in.host line 1
Quoted 1 line
package/clang/Config.in.host new file +1
-0@@ -0,0 +1,8 @@ +config BR2_PACKAGE_HOST_CLANGWhen I just select host and target clang, I get the dependency chain error.
Quoted 3 lines
Makefile:569: *** llvm is in the dependency chain of clang that has added it to its
_DEPENDENCIESvariable 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
PATCH v4 7/11 package/clang: new host package
In reply to Valentin KorenblitHello,
Quoted 6 lines · Valentin Korenblit
package/clang/Config.in.host new file +0
-0
package/clang/Config.in.host line 8
Quoted 8 lines
package/clang/Config.in.host new file +8
-0@@ -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.
package/clang/Config.in.host
Quoted 2 lines
package/clang/Config.in.host new file +2
-0+# 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.
package/clang/Config.in.host
Quoted 2 lines
package/clang/Config.in.host new file +2
-0+# Select Release build +HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
Do we need to do that in the cmake-package infrastructure instead ?
Quoted 4 lines
package/clang/Config.in.host new file +4
-0+# Build tools enabled +HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON + +# Don't build examples
package/clang/Config.in.host
Quoted 10 lines
package/clang/Config.in.host new file +10
-0+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.
package/clang/Config.in.host
Quoted 2 lines
package/clang/Config.in.host new file +2
-0+# 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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 8/11 package/clang: enable target variant
In reply to Valentin KorenblitThis 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.
--- 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
package/Config.in +1 -0
@@ -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"
package/clang/Config.in new file +8 -0
@@ -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/
package/clang/clang.mk +30 -0
@@ -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))
Signature · 1 line
2.14.3
PATCH v4 8/11 package/clang: enable target variant
Hello,
Quoted 9 lines · Valentin Korenblit
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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 8/11 package/clang: enable target variant
Hello Thomas,
Quoted 10 lines · Thomas Petazzoni
Hello,
Quoted 7 lines · Valentin Korenblit
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.
Quoted 5 lines
Quoted 2 lines
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.
Quoted 4 lines
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.
Quoted 4 lines
Thanks!
Thomas
Best regards,
Valentin
PATCH v4 8/11 package/clang: enable target variant
Hello,
Quoted 5 lines · Valentin Korenblit
What we need is libclang, we don't need the binaries. But as libclang is a tool, I need to set
CLANG_BUILD_TOOLSto 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.
Quoted 7 lines
Quoted 4 lines
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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 8/11 package/clang: enable target variant
In reply to Valentin KorenblitValentin,
Quoted 10 lines · Valentin Korenblit
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
PATCH v4 8/11 package/clang: enable target variant
In reply to Valentin KorenblitHello,
Quoted 5 lines · Valentin Korenblit
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.
Quoted 2 lines
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).
Quoted 1 line
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.
Quoted 1 line
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.
Quoted 9 lines
package/clang/clang.mk +1
-0@@ -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
package/clang/clang.mk CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz · line 23
Quoted 10 lines
package/clang/clang.mk +5
-0HOST_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
Quoted 4 lines
package/clang/clang.mk +4
-0+# 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
package/clang/clang.mk CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz · line 37
Quoted 10 lines
package/clang/clang.mk +10
-0+# 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 ?
package/clang/clang.mk CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz · line 41
Quoted 3 lines
package/clang/clang.mk +1
-0# 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.
Quoted 9 lines
package/clang/clang.mk +4
-0+ +# 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
package/clang/clang.mk CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz · line 60
Quoted 10 lines
package/clang/clang.mk +3
-0HOST_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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 9/11 package/libclc: new package
In reply to Valentin KorenblitThis 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.
--- 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
DEVELOPERS +1 -0
@@ -1860,6 +1860,7 @@ F: package/tstools/ N: Valentin Korenblit <[email protected]> F: package/clang/ +F: package/libclc/ F: package/llvm/ N: Vanya Sergeev <[email protected]>
package/Config.in +1 -0
@@ -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"
package/libclc/Config.in new file +9 -0
@@ -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/
package/libclc/libclc.mk new file +38 -0
@@ -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))
Signature · 1 line
2.14.3
PATCH v4 9/11 package/libclc: new package
Hello,
Quoted 5 lines · Valentin Korenblit
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.
Quoted 8 lines
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/clcfromSTAGING_DIRto 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.
package/libclc/libclc.mk line 9
Quoted 3 lines
package/libclc/libclc.mk new file +3
-0+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.
package/libclc/libclc.mk line 16
Quoted 6 lines
package/libclc/libclc.mk new file +6
-0+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 ?
Quoted 1 line
+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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 9/11 package/libclc: new package
Hello Thomas,
Quoted 16 lines · Thomas Petazzoni
Hello,
Quoted 5 lines · Valentin Korenblit
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.
Quoted 8 lines
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/clcfromSTAGING_DIRto the target manually, as Buildroot doesn't include this directory.
Quoted 8 lines
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/clcfrom 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?
Quoted 5 lines
package/libclc/libclc.mk line 9
Quoted 4 lines
package/libclc/libclc.mk new file +3
-0+LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795 +LIBCLC_SITE = https://git.llvm.org/git/libclc +LIBCLC_SITE_METHOD = gitI 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.
Quoted 11 lines
This lacks LICENSE and
LICENSE_FILES.package/libclc/libclc.mk line 16
Quoted 6 lines
package/libclc/libclc.mk new file +6
-0+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 ?
Quoted 3 lines
Quoted 1 line
+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 inSTAGING_DIR?
I will check this.
Quoted 4 lines
Best regards,
Thomas
Best regards,
Valentin
PATCH v4 9/11 package/libclc: new package
Hello,
Quoted 12 lines · Valentin Korenblit
Quoted 11 lines
Quoted 3 lines
As OpenCL kernels are built dynamically on the target using libClang and libLLVM, it is necessary to copy
/usr/include/clcfromSTAGING_DIRto 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/clcfrom 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.
Quoted 5 lines
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 ?
Quoted 7 lines
Quoted 4 lines
package/libclc/libclc.mk line 9
Quoted 3 lines
package/libclc/libclc.mk new file +3
-0+LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795 +LIBCLC_SITE = https://git.llvm.org/git/libclc +LIBCLC_SITE_METHOD = gitI 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.
Quoted 7 lines
Quoted 7 lines
package/libclc/libclc.mk line 16
Quoted 6 lines
package/libclc/libclc.mk new file +6
-0+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 ? :-)
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+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 inSTAGING_DIR?I will check this.
OK. Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 9/11 package/libclc: new package
Hello Thomas,
Quoted 18 lines · Thomas Petazzoni
Hello,
Quoted 14 lines · Valentin Korenblit
Quoted 11 lines
Quoted 3 lines
As OpenCL kernels are built dynamically on the target using libClang and libLLVM, it is necessary to copy
/usr/include/clcfromSTAGING_DIRto 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/clcfrom 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
Quoted 6 lines
Quoted 2 lines
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.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
package/libclc/libclc.mk line 9
Quoted 3 lines
package/libclc/libclc.mk new file +3
-0+LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795 +LIBCLC_SITE = https://git.llvm.org/git/libclc +LIBCLC_SITE_METHOD = gitI 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
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
package/libclc/libclc.mk line 16
Quoted 7 lines
package/libclc/libclc.mk new file +6
-0+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.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
+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 inSTAGING_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.
Quoted 3 lines
OK. Thanks!
Thomas
Best regards and thanks,
Valentin
PATCH v4 10/11 package/mesa3d: enable OpenCL support
In reply to Valentin KorenblitThis patch provides Clover, the OpenCL 1.1 API implementation by Mesa for AMD GPUs. It generates libOpenCL.so.
---
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(+)
package/mesa3d/Config.in +16 -0
@@ -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
package/mesa3d/mesa3d.mk +9 -0
@@ -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))
Signature · 1 line
2.14.3
PATCH v4 10/11 package/mesa3d: enable OpenCL support
Hello,
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 37
Quoted 10 lines · Valentin Korenblit
package/mesa3d/Config.in +2
-0@@ -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"
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 38
Quoted 1 line
package/mesa3d/Config.in +1
-0+ 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 ?
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 43
Quoted 5 lines
package/mesa3d/Config.in +5
-0+ 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.
package/mesa3d/mesa3d.mk else · line 236
Quoted 9 lines
package/mesa3d/mesa3d.mk +1
-0@@ -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.
package/mesa3d/mesa3d.mk else · line 245
Quoted 9 lines
package/mesa3d/mesa3d.mk +8
-0+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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 10/11 package/mesa3d: enable OpenCL support
Hi Valentin, Thomas, all!
2018-04-01 23:32 GMT+02:00 Thomas Petazzoni <[email protected]>:
Quoted 17 lines
Hello,
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 37
Quoted 10 lines · Valentin Korenblit
package/mesa3d/Config.in +2
-0@@ -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:
Quoted 7 lines
bool "OpenCL"
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 38
Quoted 1 line
package/mesa3d/Config.in +1
-0+ depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600This 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!
Quoted 33 lines
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 43
Quoted 6 lines
package/mesa3d/Config.in +5
-0+ 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_ELFUTILSInteresting that elfutils is needed here.
package/mesa3d/mesa3d.mk else · line 236
Quoted 9 lines
package/mesa3d/mesa3d.mk +1
-0@@ -233,4 +233,13 @@ else MESA3D_CONF_OPTS += --disable-lmsensors endif +# Clover requires libelfComment not really useful, it's obvious from the code below.
package/mesa3d/mesa3d.mk else · line 245
Quoted 9 lines
package/mesa3d/mesa3d.mk +8
-0+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!
Quoted 9 lines
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
PATCH v4 10/11 package/mesa3d: enable OpenCL support
Hello Erik,
Quoted 5 lines · Erik Larsson
Quoted 3 lines
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.
Quoted 7 lines
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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 10/11 package/mesa3d: enable OpenCL support
In reply to Thomas PetazzoniHello Thomas,
Quoted 16 lines · Thomas Petazzoni
Hello,
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 37
Quoted 10 lines · Valentin Korenblit
package/mesa3d/Config.in +2
-0@@ -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:
Quoted 6 lines
bool "OpenCL"
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 38
Quoted 1 line
package/mesa3d/Config.in +1
-0+ depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600This 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.
Quoted 30 lines
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 43
Quoted 5 lines
package/mesa3d/Config.in +5
-0+ 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_ELFUTILSInteresting that elfutils is needed here.
package/mesa3d/mesa3d.mk else · line 236
Quoted 9 lines
package/mesa3d/mesa3d.mk +1
-0@@ -233,4 +233,13 @@ else MESA3D_CONF_OPTS += --disable-lmsensors endif +# Clover requires libelfComment not really useful, it's obvious from the code below.
package/mesa3d/mesa3d.mk else · line 245
Quoted 9 lines
package/mesa3d/mesa3d.mk +8
-0+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
PATCH v4 10/11 package/mesa3d: enable OpenCL support
Hello,
Quoted 8 lines · Valentin Korenblit
Quoted 6 lines
bool "OpenCL"
package/mesa3d/Config.in config BR2_PACKAGE_MESA3D_LLVM · line 38
Quoted 1 line
package/mesa3d/Config.in +1
-0+ depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600This 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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 11/11 package/clinfo: new package
In reply to Valentin KorenblitThis tool allows to verify if the OpenCL environment is set up correctly and output information related to the supported OpenCL platforms.
--- 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
DEVELOPERS +1 -0
@@ -1860,6 +1860,7 @@ F: package/tstools/ N: Valentin Korenblit <[email protected]> F: package/clang/ +F: package/clinfo/ F: package/libclc/ F: package/llvm/
package/Config.in +1 -0
@@ -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"
package/clinfo/Config.in new file +7 -0
@@ -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.
package/clinfo/clinfo.hash new file +2 -0
@@ -0,0 +1,2 @@ +# locally calculated +sha256 64b02e68ccff3b95437bd0bd70dcb88438c58adec16a7145a5d4e5c26a898ccf clinfo-2.2.18.03.26.tar.gz
package/clinfo/clinfo.mk new file +23 -0
@@ -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))
Signature · 1 line
2.14.3