All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v6 0/4] llvm for mesa3d
@ 2018-04-11 16:14 Valentin Korenblit
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 1/4] package/clang: new package Valentin Korenblit
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-11 16:14 UTC (permalink / raw)
  To: buildroot

Hello all,

This series provides llvm support for Mesa 3D:


Changes v1 -> v2:

The series has been simplified:

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

Changes v2 -> v3:

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

Changes v3 -> v4:

This series is focused on OpenCL support

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

Changes v4 -> v5:

The changes suggested after the Buildroot hackathon were applied:

* No Config.in.host for llvm and clang.
* ARM and Aarch64 now in PATCH 1
* Unnecessary comments were removed
* clang-tblgen wasn't being installed in HOST_DIR, now solved
* LLVM_TARGETS_TO_BUILD is now easily extensible for new backends
* llvm-tblgen was being installed on the target, now removed

Changes v5 -> v6:

With LLVM package applied to master and while some bugs are being
fixed, this series provides OpenCL support for AMD GPUs using Gallium
R600 driver.

* LLVM dependencies propagated to clang and libclc
* Use llvm-tblgen from host to cross-compile clang. 
* libclc headers now installed to /usr/local/include


Regards,

Valent?n


Valentin Korenblit (4):
  package/clang: new package
  package/libclc: new package
  package/mesa3d: enable OpenCL support
  package/clinfo: new package

 DEVELOPERS                 |  3 ++
 package/Config.in          |  3 ++
 package/clang/Config.in    | 22 ++++++++++++++
 package/clang/clang.hash   |  3 ++
 package/clang/clang.mk     | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 package/clinfo/Config.in   |  9 ++++++
 package/clinfo/clinfo.hash |  2 ++
 package/clinfo/clinfo.mk   | 23 +++++++++++++++
 package/libclc/Config.in   | 22 ++++++++++++++
 package/libclc/libclc.hash |  3 ++
 package/libclc/libclc.mk   | 42 +++++++++++++++++++++++++++
 package/mesa3d/Config.in   |  8 ++++++
 package/mesa3d/mesa3d.mk   |  9 ++++++
 13 files changed, 221 insertions(+)
 create mode 100644 package/clang/Config.in
 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.hash
 create mode 100644 package/libclc/libclc.mk

-- 
2.14.3

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

* [Buildroot] [PATCH v6 1/4] package/clang: new package
  2018-04-11 16:14 [Buildroot] [PATCH v6 0/4] llvm for mesa3d Valentin Korenblit
@ 2018-04-11 16:14 ` Valentin Korenblit
  2018-04-28 12:51   ` Thomas Petazzoni
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 2/4] package/libclc: " Valentin Korenblit
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-11 16:14 UTC (permalink / raw)
  To: buildroot

This patch provides Clang tools and libraries for the host and libclang
for the target.

host-clang is needed to build libclc, which is also provided in a follup patch.

We need libclang for the target because it is used by most of OpenCL implementations.

A later patch in this series will enable Clover, the OpenCl implementation part
of Mesa3D, which requires libclang.

clang-tblgen must be copied to HOST_DIR as it is not installed by default but is needed
for cross-compilation: http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.html

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

diff --git a/DEVELOPERS b/DEVELOPERS
index 85e22c2e71..da1c6fa58e 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1906,6 +1906,7 @@ F:	package/dropwatch/
 F:	package/tstools/
 
 N:	Valentin Korenblit <valentin.korenblit@smile.fr>
+F:	package/clang/
 F:	package/llvm/
 
 N:	Vanya Sergeev <vsergeev@gmail.com>
diff --git a/package/Config.in b/package/Config.in
index e48d0b4c64..62770790a1 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1481,6 +1481,7 @@ menu "Other"
 	source "package/bctoolbox/Config.in"
 	source "package/bdwgc/Config.in"
 	source "package/boost/Config.in"
+	source "package/clang/Config.in"
 	source "package/clapack/Config.in"
 	source "package/classpath/Config.in"
 	source "package/cppcms/Config.in"
diff --git a/package/clang/Config.in b/package/clang/Config.in
new file mode 100644
index 0000000000..f94ddfdc21
--- /dev/null
+++ b/package/clang/Config.in
@@ -0,0 +1,22 @@
+config BR2_PACKAGE_CLANG
+	bool "clang"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on BR2_HOST_GCC_AT_LEAST_4_8
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future
+	depends on !BR2_STATIC_LIBS
+	depends on BR2_USE_WCHAR # std::wstring
+	select BR2_PACKAGE_LLVM
+	help
+	  Clang is a C/C++, Objective C/C++ and OpenCL C front-end
+	  for the LLVM compiler.
+
+	  http://clang.llvm.org
+
+comment "clang needs a toolchain w/ wchar, threads, C++, gcc >= 4.8, host gcc >= 4.8, dynamic library"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_INSTALL_LIBSTDCPP || \
+		!BR2_HOST_GCC_AT_LEAST_4_8 || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 \
+		|| BR2_STATIC_LIBS || !BR2_USE_WCHAR
diff --git a/package/clang/clang.hash b/package/clang/clang.hash
new file mode 100644
index 0000000000..a5bf909814
--- /dev/null
+++ b/package/clang/clang.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 135f6c9b0cd2da1aff2250e065946258eb699777888df39ca5a5b4fe5e23d0ff cfe-5.0.1.src.tar.xz
+sha256 de4c79665f0f5688b0ace17cba6f8e0343925bb95e0949d66d47bbd4527310d6 LICENSE.TXT
diff --git a/package/clang/clang.mk b/package/clang/clang.mk
new file mode 100644
index 0000000000..d5f378b7f1
--- /dev/null
+++ b/package/clang/clang.mk
@@ -0,0 +1,72 @@
+################################################################################
+#
+# clang
+#
+################################################################################
+
+CLANG_VERSION = 5.0.1
+CLANG_SITE = http://llvm.org/releases/$(CLANG_VERSION)
+CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz
+CLANG_LICENSE = NCSA
+CLANG_LICENSE_FILES = LICENSE.TXT
+CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
+CLANG_INSTALL_STAGING = YES
+
+HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
+CLANG_DEPENDENCIES = llvm host-clang
+
+# This option is needed. Otherwise multiple shared libs (libclangAST.so,
+# libclangBasic.so, libclangFrontend.so, etc.) will be generated. As a final
+# shared lib containing all these components (libclang.so) is also generated, this
+# resulted in the following error when trying to use tools that use libclang:
+# $ CommandLine Error: Option 'track-memory' registered more than once!
+# $ LLVM ERROR: inconsistency in registered CommandLine options
+# By setting BUILD_SHARED_LIBS to OFF, we generate multiple static libraries
+# (the same way as host's clang build) and finally libclang.so to be installed on the
+# target.
+CLANG_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+
+# Default is Debug build, which requires considerably more disk space and
+# build time. Release build is selected for host and target because the linker
+# can run out of memory in Debug mode.
+HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
+
+# We need to build tools because libclang is a tool
+HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
+CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
+
+HOST_CLANG_CONF_OPTS += \
+	-DCLANG_BUILD_EXAMPLES=OFF \
+	-DCLANG_INCLUDE_DOCS=OFF \
+	-DCLANG_INCLUDE_TESTS=OFF
+
+CLANG_CONF_OPTS += \
+	-DCLANG_BUILD_EXAMPLES=OFF \
+	-DCLANG_INCLUDE_DOCS=OFF \
+	-DCLANG_INCLUDE_TESTS=OFF
+
+HOST_CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(HOST_DIR)/bin/llvm-config
+CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(STAGING_DIR)/usr/bin/llvm-config \
+	-DCLANG_TABLEGEN:FILEPATH=$(HOST_DIR)/usr/bin/clang-tblgen \
+	-DLLVM_TABLEGEN_EXE:FILEPATH=$(HOST_DIR)/usr/bin/llvm-tblgen
+
+# Clang can't be used as compiler on the target since there are no development files
+# (headers) and other build tools. So remove clang binaries from target.
+define CLANG_DELETE_BINARIES_FROM_TARGET
+	rm -f $(TARGET_DIR)/usr/bin/clang*
+endef
+CLANG_POST_INSTALL_TARGET_HOOKS += CLANG_DELETE_BINARIES_FROM_TARGET
+
+# clang-tblgen is not installed by default, however it is necessary for
+# cross-compiling clang
+define HOST_CLANG_INSTALL_CLANG_TBLGEN
+	$(INSTALL) -D -m 0755 $(HOST_CLANG_BUILDDIR)/bin/clang-tblgen \
+		$(HOST_DIR)/usr/bin/clang-tblgen
+endef
+HOST_CLANG_POST_INSTALL_HOOKS = HOST_CLANG_INSTALL_CLANG_TBLGEN
+
+$(eval $(cmake-package))
+$(eval $(host-cmake-package))
-- 
2.14.3

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

* [Buildroot] [PATCH v6 2/4] package/libclc: new package
  2018-04-11 16:14 [Buildroot] [PATCH v6 0/4] llvm for mesa3d Valentin Korenblit
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 1/4] package/clang: new package Valentin Korenblit
@ 2018-04-11 16:14 ` Valentin Korenblit
  2018-04-28 13:06   ` Thomas Petazzoni
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 3/4] package/mesa3d: enable OpenCL support Valentin Korenblit
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-11 16:14 UTC (permalink / raw)
  To: buildroot

This patch provides libclc, an open source implementation of the
library requirements of the OpenCL C programming language, as
specified by the OpenCL 1.1 Specification. It is intended to be used
with Mesa Clover.

It needs to be compiled with host-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 have clc headers on the target. Buildroot removes
/usr/include in its target-finalize step, so clc headers are installed to
/usr/local/include.

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

diff --git a/DEVELOPERS b/DEVELOPERS
index da1c6fa58e..cc68bf2487 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1907,6 +1907,7 @@ F:	package/tstools/
 
 N:	Valentin Korenblit <valentin.korenblit@smile.fr>
 F:	package/clang/
+F:	package/libclc/
 F:	package/llvm/
 
 N:	Vanya Sergeev <vsergeev@gmail.com>
diff --git a/package/Config.in b/package/Config.in
index 62770790a1..f376fad3a2 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -283,6 +283,7 @@ comment "Graphic libraries"
 	source "package/fbv/Config.in"
 	source "package/freerdp/Config.in"
 	source "package/imagemagick/Config.in"
+	source "package/libclc/Config.in"
 	source "package/linux-fusion/Config.in"
 	source "package/lite/Config.in"
 	source "package/mesa3d/Config.in"
diff --git a/package/libclc/Config.in b/package/libclc/Config.in
new file mode 100644
index 0000000000..a0f388c4e1
--- /dev/null
+++ b/package/libclc/Config.in
@@ -0,0 +1,22 @@
+config BR2_PACKAGE_LIBCLC
+	bool "libclc"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on BR2_HOST_GCC_AT_LEAST_4_8
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future
+	depends on !BR2_STATIC_LIBS
+	depends on BR2_USE_WCHAR # std::wstring
+	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/
+
+comment "libclc needs a toolchain w/ wchar, threads, C++, gcc >= 4.8, host gcc >= 4.8, dynamic library"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_INSTALL_LIBSTDCPP || \
+		!BR2_HOST_GCC_AT_LEAST_4_8 || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 \
+		|| BR2_STATIC_LIBS || !BR2_USE_WCHAR
diff --git a/package/libclc/libclc.hash b/package/libclc/libclc.hash
new file mode 100644
index 0000000000..c5bf5a668c
--- /dev/null
+++ b/package/libclc/libclc.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 e2f1f294f93695f2d1f87ccb9760231b435702dd0c27abeb38baa97186674d9e  libclc-00236279a293b3737dee08c14f25923a889d2795.tar.gz
+sha256 c66aa55d8478b45f1018500af9f433dd271444ad304d683dd49ff2a42f30dad1  LICENSE.TXT
diff --git a/package/libclc/libclc.mk b/package/libclc/libclc.mk
new file mode 100644
index 0000000000..93726a22b5
--- /dev/null
+++ b/package/libclc/libclc.mk
@@ -0,0 +1,42 @@
+################################################################################
+#
+# libclc
+#
+################################################################################
+
+# There are only two releases: release_35 and release_38, but the last
+# commit is from 2 years ago. Master has some recent activity.
+LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
+LIBCLC_SITE = https://git.llvm.org/git/libclc
+LIBCLC_SITE_METHOD = git
+LIBCLC_LICENSE = NCSA
+LIBCLC_LICENSE_FILES = LICENSE.TXT
+
+LIBCLC_DEPENDENCIES = host-clang host-llvm
+LIBCLC_INSTALL_STAGING = YES
+
+# C++ compiler is used to build a small tool (prepare-builtins) for the host.
+# It must be built with the C++ compiler from the host
+LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
+	--prefix="/usr" \
+	--includedir="/usr/local/include" \
+	--pkgconfigdir="/usr/lib/pkgconfig" \
+	--with-cxx-compiler=$(HOSTCXX)
+
+define LIBCLC_CONFIGURE_CMDS
+	(cd $(@D); $(TARGET_CONFIGURE_OPTS) ./configure.py $(LIBCLC_CONF_OPTS))
+endef
+
+define LIBCLC_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
+endef
+
+define LIBCLC_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
+endef
+
+define LIBCLC_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
+endef
+
+$(eval $(generic-package))
-- 
2.14.3

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

* [Buildroot] [PATCH v6 3/4] package/mesa3d: enable OpenCL support
  2018-04-11 16:14 [Buildroot] [PATCH v6 0/4] llvm for mesa3d Valentin Korenblit
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 1/4] package/clang: new package Valentin Korenblit
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 2/4] package/libclc: " Valentin Korenblit
@ 2018-04-11 16:14 ` Valentin Korenblit
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 4/4] package/clinfo: new package Valentin Korenblit
  2018-04-23 16:14 ` [Buildroot] [PATCH v6 0/4] llvm for mesa3d Romain Naour
  4 siblings, 0 replies; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-11 16:14 UTC (permalink / raw)
  To: buildroot

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

Add --disable-opencl-icd because in Mesa 18 it defaults to on.
When disabled, the shared library is named libOpenCL instead
of libMesaOpenCL and CL headers are installed.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/mesa3d/Config.in | 8 ++++++++
 package/mesa3d/mesa3d.mk | 9 +++++++++
 2 files changed, 17 insertions(+)

diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
index bd3d050e29..f27aed949a 100644
--- a/package/mesa3d/Config.in
+++ b/package/mesa3d/Config.in
@@ -47,6 +47,14 @@ comment "llvm support needs a toolchain not affected by GCC bug 64735"
 	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 	depends on BR2_TOOLCHAIN_HAS_GCC_BUG_64735
 
+#clang and libclc dependencies are satisfied by BR2_PACKAGE_MESA3D_LLVM
+config BR2_PACKAGE_MESA3D_OPENCL
+	bool "OpenCL support"
+	depends on BR2_PACKAGE_MESA3D_LLVM
+	depends on BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_R600
+	select BR2_PACKAGE_CLANG
+	select BR2_PACKAGE_LIBCLC
+
 # inform the .mk file of gallium, dri or vulkan driver selection
 config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
 	bool
diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
index 506f84274f..11245be2ba 100644
--- a/package/mesa3d/mesa3d.mk
+++ b/package/mesa3d/mesa3d.mk
@@ -230,4 +230,13 @@ else
 MESA3D_CONF_OPTS += --disable-lmsensors
 endif
 
+ifeq ($(BR2_PACKAGE_MESA3D_OPENCL),y)
+MESA3D_DEPENDENCIES += clang elfutils libclc
+MESA3D_CONF_OPTS += --enable-opencl \
+	--disable-opencl-icd \
+	--with-clang-libdir=$(STAGING_DIR)/usr/lib
+else
+MESA3D_CONF_OPTS += --disable-opencl
+endif
+
 $(eval $(autotools-package))
-- 
2.14.3

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

* [Buildroot] [PATCH v6 4/4] package/clinfo: new package
  2018-04-11 16:14 [Buildroot] [PATCH v6 0/4] llvm for mesa3d Valentin Korenblit
                   ` (2 preceding siblings ...)
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 3/4] package/mesa3d: enable OpenCL support Valentin Korenblit
@ 2018-04-11 16:14 ` Valentin Korenblit
  2018-04-23 16:14 ` [Buildroot] [PATCH v6 0/4] llvm for mesa3d Romain Naour
  4 siblings, 0 replies; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-11 16:14 UTC (permalink / raw)
  To: buildroot

This tool allows to verify if the OpenCL environment is set up correctly and
output information related to the supported OpenCL platforms.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 DEVELOPERS                 |  1 +
 package/Config.in          |  1 +
 package/clinfo/Config.in   |  9 +++++++++
 package/clinfo/clinfo.hash |  2 ++
 package/clinfo/clinfo.mk   | 23 +++++++++++++++++++++++
 5 files changed, 36 insertions(+)
 create mode 100644 package/clinfo/Config.in
 create mode 100644 package/clinfo/clinfo.hash
 create mode 100644 package/clinfo/clinfo.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index cc68bf2487..b5a45628f1 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1907,6 +1907,7 @@ F:	package/tstools/
 
 N:	Valentin Korenblit <valentin.korenblit@smile.fr>
 F:	package/clang/
+F:	package/clinfo/
 F:	package/libclc/
 F:	package/llvm/
 
diff --git a/package/Config.in b/package/Config.in
index f376fad3a2..dc3e7a925c 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1485,6 +1485,7 @@ menu "Other"
 	source "package/clang/Config.in"
 	source "package/clapack/Config.in"
 	source "package/classpath/Config.in"
+	source "package/clinfo/Config.in"
 	source "package/cppcms/Config.in"
 	source "package/cracklib/Config.in"
 	source "package/dawgdic/Config.in"
diff --git a/package/clinfo/Config.in b/package/clinfo/Config.in
new file mode 100644
index 0000000000..279b5acbfb
--- /dev/null
+++ b/package/clinfo/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_CLINFO
+	bool "clinfo"
+	depends on BR2_PACKAGE_MESA3D_OPENCL
+	help
+	  clinfo is a simple command-line application that enumerates
+	  all possible (known) properties of the OpenCL platform and
+	  devices available on the system.
+
+	  https://github.com/Oblomov/clinfo
diff --git a/package/clinfo/clinfo.hash b/package/clinfo/clinfo.hash
new file mode 100644
index 0000000000..e1c10afc9e
--- /dev/null
+++ b/package/clinfo/clinfo.hash
@@ -0,0 +1,2 @@
+# locally calculated
+sha256 64b02e68ccff3b95437bd0bd70dcb88438c58adec16a7145a5d4e5c26a898ccf clinfo-2.2.18.03.26.tar.gz
diff --git a/package/clinfo/clinfo.mk b/package/clinfo/clinfo.mk
new file mode 100644
index 0000000000..1477b76946
--- /dev/null
+++ b/package/clinfo/clinfo.mk
@@ -0,0 +1,23 @@
+################################################################################
+#
+# clinfo
+#
+################################################################################
+
+CLINFO_VERSION = 2.2.18.03.26
+CLINFO_SITE = $(call github,Oblomov,clinfo,$(CLINFO_VERSION))
+CLINFO_LICENSE = CC0-1.0
+CLINFO_LICENSE_FILES = legalcode.txt
+
+# libOpenCL is needed
+CLINFO_DEPENDENCIES = mesa3d
+
+define CLINFO_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
+endef
+
+define CLINFO_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 755 $(@D)/clinfo $(TARGET_DIR)/usr/bin/clinfo
+endef
+
+$(eval $(generic-package))
-- 
2.14.3

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

* [Buildroot] [PATCH v6 0/4] llvm for mesa3d
  2018-04-11 16:14 [Buildroot] [PATCH v6 0/4] llvm for mesa3d Valentin Korenblit
                   ` (3 preceding siblings ...)
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 4/4] package/clinfo: new package Valentin Korenblit
@ 2018-04-23 16:14 ` Romain Naour
  4 siblings, 0 replies; 12+ messages in thread
From: Romain Naour @ 2018-04-23 16:14 UTC (permalink / raw)
  To: buildroot

Hi All,

Le 11/04/2018 ? 18:14, Valentin Korenblit a ?crit?:
> Hello all,
> 
[...]
> 
> 
> Valentin Korenblit (4):
>   package/clang: new package
>   package/libclc: new package
>   package/mesa3d: enable OpenCL support
>   package/clinfo: new package

The next 2018.05-rc1 is near, it would be great if the remaining patches from
llvm/clang series can be reviewed or merged :)

I know there are some annoying issues with dl cache infra and a lot of patches
to review but the llvm/clang series should be ok for 2018.05.

Best regards,
Romain

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

* [Buildroot] [PATCH v6 1/4] package/clang: new package
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 1/4] package/clang: new package Valentin Korenblit
@ 2018-04-28 12:51   ` Thomas Petazzoni
  2018-04-30  7:20     ` Valentin Korenblit
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Petazzoni @ 2018-04-28 12:51 UTC (permalink / raw)
  To: buildroot

Hello Valentin,

On Wed, 11 Apr 2018 18:14:49 +0200, Valentin Korenblit wrote:
> This patch provides Clang tools and libraries for the host and libclang
> for the target.
> 
> host-clang is needed to build libclc, which is also provided in a follup patch.
> 
> We need libclang for the target because it is used by most of OpenCL implementations.
> 
> A later patch in this series will enable Clover, the OpenCl implementation part
> of Mesa3D, which requires libclang.
> 
> clang-tblgen must be copied to HOST_DIR as it is not installed by default but is needed
> for cross-compilation: http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.html
> 
> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
> ---
>  DEVELOPERS               |  1 +
>  package/Config.in        |  1 +
>  package/clang/Config.in  | 22 +++++++++++++++
>  package/clang/clang.hash |  3 ++
>  package/clang/clang.mk   | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 99 insertions(+)
>  create mode 100644 package/clang/Config.in
>  create mode 100644 package/clang/clang.hash
>  create mode 100644 package/clang/clang.mk

I've applied to master, after doing the following changes:

    [Thomas:
     - Add Config.in comment about BR2_TOOLCHAIN_HAS_GCC_BUG_64735
     - Minor reformatting/rewrapping of comments in .mk file]

However, I've noticed that a lot of stuff gets installed in the target,
which doesn't seem very useful (see below). At least the heders
in /usr/lib/clang don't see very useful. There's a bunch of Python
script and Javascript files as well. Do you think some of these could
be removed, perhaps through post-install target hooks ?

`-- usr
    |-- bin
    |   |-- c-index-test
    |   |-- git-clang-format
    |   |-- scan-build
    |   `-- scan-view
    |-- lib
    |   |-- LLVMHello.so
    |   |-- clang
    |   |   `-- 5.0.1
    |   |       `-- include
    |   |           |-- __clang_cuda_builtin_vars.h
    |   |           |-- __clang_cuda_cmath.h
    |   |           |-- __clang_cuda_complex_builtins.h
    |   |           |-- __clang_cuda_intrinsics.h
    |   |           |-- __clang_cuda_math_forward_declares.h
    |   |           |-- __clang_cuda_runtime_wrapper.h
    |   |           |-- __stddef_max_align_t.h
    |   |           |-- __wmmintrin_aes.h
    |   |           |-- __wmmintrin_pclmul.h
    |   |           |-- adxintrin.h
    |   |           |-- altivec.h
    |   |           |-- ammintrin.h
    |   |           |-- arm_acle.h
    |   |           |-- arm_neon.h
    |   |           |-- armintr.h
    |   |           |-- avx2intrin.h
    |   |           |-- avx512bwintrin.h
    |   |           |-- avx512cdintrin.h
    |   |           |-- avx512dqintrin.h
    |   |           |-- avx512erintrin.h
    |   |           |-- avx512fintrin.h
    |   |           |-- avx512ifmaintrin.h
    |   |           |-- avx512ifmavlintrin.h
    |   |           |-- avx512pfintrin.h
    |   |           |-- avx512vbmiintrin.h
    |   |           |-- avx512vbmivlintrin.h
    |   |           |-- avx512vlbwintrin.h
    |   |           |-- avx512vlcdintrin.h
    |   |           |-- avx512vldqintrin.h
    |   |           |-- avx512vlintrin.h
    |   |           |-- avx512vpopcntdqintrin.h
    |   |           |-- avxintrin.h
    |   |           |-- bmi2intrin.h
    |   |           |-- bmiintrin.h
    |   |           |-- clflushoptintrin.h
    |   |           |-- clzerointrin.h
    |   |           |-- cpuid.h
    |   |           |-- cuda_wrappers
    |   |           |   |-- algorithm
    |   |           |   |-- complex
    |   |           |   `-- new
    |   |           |-- emmintrin.h
    |   |           |-- f16cintrin.h
    |   |           |-- float.h
    |   |           |-- fma4intrin.h
    |   |           |-- fmaintrin.h
    |   |           |-- fxsrintrin.h
    |   |           |-- htmintrin.h
    |   |           |-- htmxlintrin.h
    |   |           |-- ia32intrin.h
    |   |           |-- immintrin.h
    |   |           |-- intrin.h
    |   |           |-- inttypes.h
    |   |           |-- iso646.h
    |   |           |-- limits.h
    |   |           |-- lwpintrin.h
    |   |           |-- lzcntintrin.h
    |   |           |-- mm3dnow.h
    |   |           |-- mm_malloc.h
    |   |           |-- mmintrin.h
    |   |           |-- module.modulemap
    |   |           |-- msa.h
    |   |           |-- mwaitxintrin.h
    |   |           |-- nmmintrin.h
    |   |           |-- opencl-c.h
    |   |           |-- pkuintrin.h
    |   |           |-- pmmintrin.h
    |   |           |-- popcntintrin.h
    |   |           |-- prfchwintrin.h
    |   |           |-- rdseedintrin.h
    |   |           |-- rtmintrin.h
    |   |           |-- s390intrin.h
    |   |           |-- shaintrin.h
    |   |           |-- smmintrin.h
    |   |           |-- stdalign.h
    |   |           |-- stdarg.h
    |   |           |-- stdatomic.h
    |   |           |-- stdbool.h
    |   |           |-- stddef.h
    |   |           |-- stdint.h
    |   |           |-- stdnoreturn.h
    |   |           |-- tbmintrin.h
    |   |           |-- tgmath.h
    |   |           |-- tmmintrin.h
    |   |           |-- unwind.h
    |   |           |-- vadefs.h
    |   |           |-- varargs.h
    |   |           |-- vecintrin.h
    |   |           |-- wmmintrin.h
    |   |           |-- x86intrin.h
    |   |           |-- xmmintrin.h
    |   |           |-- xopintrin.h
    |   |           |-- xsavecintrin.h
    |   |           |-- xsaveintrin.h
    |   |           |-- xsaveoptintrin.h
    |   |           |-- xsavesintrin.h
    |   |           `-- xtestintrin.h
    |   |-- libLLVM-5.0.1.so -> libLLVM-5.0.so
    |   |-- libLLVM-5.0.so
    |   |-- libLLVM.so -> libLLVM-5.0.so
    |   |-- libLTO.so -> libLTO.so.5
    |   |-- libLTO.so.5 -> libLTO.so.5.0.1
    |   |-- libLTO.so.5.0.1
    |   |-- libclang.so -> libclang.so.5
    |   |-- libclang.so.5 -> libclang.so.5.0
    |   |-- libclang.so.5.0
    |   |-- libstdc++.so.6 -> libstdc++.so.6.0.22
    |   |-- libstdc++.so.6.0.22
    |   |-- libstdc++.so.6.0.22-gdb.py
    |   `-- os-release
    |-- lib64 -> lib
    |-- libexec
    |   |-- c++-analyzer
    |   `-- ccc-analyzer
    |-- sbin
    `-- share
        |-- clang
        |   |-- bash-autocomplete.sh
        |   |-- clang-format-bbedit.applescript
        |   |-- clang-format-diff.py
        |   |-- clang-format-sublime.py
        |   |-- clang-format.el
        |   |-- clang-format.py
        |   |-- clang-rename.el
        |   `-- clang-rename.py
        |-- opt-viewer
        |   |-- opt-diff.py
        |   |-- opt-stats.py
        |   |-- opt-viewer.py
        |   |-- optpmap.py
        |   |-- optrecord.py
        |   `-- style.css
        |-- scan-build
        |   |-- scanview.css
        |   `-- sorttable.js
        `-- scan-view
            |-- FileRadar.scpt
            |-- GetRadarVersion.scpt
            |-- Reporter.py
            |-- ScanView.py
            |-- bugcatcher.ico
            `-- startfile.py

Also, I must say I was impressed by the size of the libLLVM and
libclang libraries. libLLVM is 23MB, while libclang is 22MB. What seems
weird however is that libclang is not linked against libLLVM:

$ readelf -d libclang.so.5.0   

Dynamic section at offset 0x15ebbd0 contains 31 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [ld64-uClibc.so.1]
 0x000000000000000e (SONAME)             Library soname: [libclang.so.5]
 0x000000000000001d (RUNPATH)            Library runpath: []

Is libclang statically linked against libLLVM, causing a huge
duplication of code size ?

Looking at the build output of libclang, it indeed seems like it uses
the .a libraries from LLVM, and not the dynamic library. So the LLVM
code is present twice: once in libLLVM.so, and a second time in
libclang.so. This isn't nice at all. Could you look into this ?

I've pasted the command line used by the clang package to produce its
libclang.so library at http://code.bulix.org/li1n6r-325499?raw. You can
see it uses the LLVM .a files directly.

My defconfig was:

BR2_x86_64=y
BR2_x86_core2=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-x86-64-core2-full-2018.02-891-g046c5e2.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_16=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_CLANG=y
# BR2_TARGET_ROOTFS_TAR is not set

Thanks!

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

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

* [Buildroot] [PATCH v6 2/4] package/libclc: new package
  2018-04-11 16:14 ` [Buildroot] [PATCH v6 2/4] package/libclc: " Valentin Korenblit
@ 2018-04-28 13:06   ` Thomas Petazzoni
  2018-04-30  7:54     ` Valentin Korenblit
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Petazzoni @ 2018-04-28 13:06 UTC (permalink / raw)
  To: buildroot

Hello,

On Wed, 11 Apr 2018 18:14:50 +0200, Valentin Korenblit wrote:

> diff --git a/package/Config.in b/package/Config.in
> index 62770790a1..f376fad3a2 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -283,6 +283,7 @@ comment "Graphic libraries"
>  	source "package/fbv/Config.in"
>  	source "package/freerdp/Config.in"
>  	source "package/imagemagick/Config.in"
> +	source "package/libclc/Config.in"
>  	source "package/linux-fusion/Config.in"
>  	source "package/lite/Config.in"
>  	source "package/mesa3d/Config.in"
> diff --git a/package/libclc/Config.in b/package/libclc/Config.in
> new file mode 100644
> index 0000000000..a0f388c4e1
> --- /dev/null
> +++ b/package/libclc/Config.in
> @@ -0,0 +1,22 @@
> +config BR2_PACKAGE_LIBCLC
> +	bool "libclc"
> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> +	depends on BR2_HOST_GCC_AT_LEAST_4_8
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
> +	depends on BR2_TOOLCHAIN_HAS_THREADS
> +	depends on BR2_INSTALL_LIBSTDCPP
> +	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future
> +	depends on !BR2_STATIC_LIBS
> +	depends on BR2_USE_WCHAR # std::wstring

You seem to have replicated here all the dependencies of the target
LLVM package. However, you only depend on host-llvm and host-clang. Are
you sure all those dependencies are needed by libclc ?

> +# There are only two releases: release_35 and release_38, but the last
> +# commit is from 2 years ago. Master has some recent activity.
> +LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
> +LIBCLC_SITE = https://git.llvm.org/git/libclc
> +LIBCLC_SITE_METHOD = git
> +LIBCLC_LICENSE = NCSA
> +LIBCLC_LICENSE_FILES = LICENSE.TXT
> +
> +LIBCLC_DEPENDENCIES = host-clang host-llvm
> +LIBCLC_INSTALL_STAGING = YES
> +
> +# C++ compiler is used to build a small tool (prepare-builtins) for the host.
> +# It must be built with the C++ compiler from the host
> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> +	--prefix="/usr" \
> +	--includedir="/usr/local/include" \

I'm not a big fan of /usr/local/include. Perhaps we should use
something really special like /usr/share/libclc/ or something like
this ?

> +	--pkgconfigdir="/usr/lib/pkgconfig" \
> +	--with-cxx-compiler=$(HOSTCXX)

Weird for a target package to use the host compiler, no ?

> +define LIBCLC_CONFIGURE_CMDS
> +	(cd $(@D); $(TARGET_CONFIGURE_OPTS) ./configure.py $(LIBCLC_CONF_OPTS))

Is the configure.py script compatible with both Python 2.x and Python
3.x ?

Best regards,

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

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

* [Buildroot] [PATCH v6 1/4] package/clang: new package
  2018-04-28 12:51   ` Thomas Petazzoni
@ 2018-04-30  7:20     ` Valentin Korenblit
  0 siblings, 0 replies; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-30  7:20 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

On 28/04/2018 14:51, Thomas Petazzoni wrote:
> Hello Valentin,
>
> On Wed, 11 Apr 2018 18:14:49 +0200, Valentin Korenblit wrote:
>> This patch provides Clang tools and libraries for the host and libclang
>> for the target.
>>
>> host-clang is needed to build libclc, which is also provided in a follup patch.
>>
>> We need libclang for the target because it is used by most of OpenCL implementations.
>>
>> A later patch in this series will enable Clover, the OpenCl implementation part
>> of Mesa3D, which requires libclang.
>>
>> clang-tblgen must be copied to HOST_DIR as it is not installed by default but is needed
>> for cross-compilation: http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.html
>>
>> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
>> ---
>>   DEVELOPERS               |  1 +
>>   package/Config.in        |  1 +
>>   package/clang/Config.in  | 22 +++++++++++++++
>>   package/clang/clang.hash |  3 ++
>>   package/clang/clang.mk   | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
>>   5 files changed, 99 insertions(+)
>>   create mode 100644 package/clang/Config.in
>>   create mode 100644 package/clang/clang.hash
>>   create mode 100644 package/clang/clang.mk
> I've applied to master, after doing the following changes:
>
>      [Thomas:
>       - Add Config.in comment about BR2_TOOLCHAIN_HAS_GCC_BUG_64735
>       - Minor reformatting/rewrapping of comments in .mk file]
>
> However, I've noticed that a lot of stuff gets installed in the target,
> which doesn't seem very useful (see below). At least the heders
> in /usr/lib/clang don't see very useful. There's a bunch of Python
> script and Javascript files as well. Do you think some of these could
> be removed, perhaps through post-install target hooks ?

I'll check this today, I think the binaries and scripts shouldn't be necessary,
but I am not completely sure about the includes when using OpenCL. I will test what
happens at runtime.

>
> `-- usr
>      |-- bin
>      |   |-- c-index-test
>      |   |-- git-clang-format
>      |   |-- scan-build
>      |   `-- scan-view
>      |-- lib
>      |   |-- LLVMHello.so
>      |   |-- clang
>      |   |   `-- 5.0.1
>      |   |       `-- include
>      |   |           |-- __clang_cuda_builtin_vars.h
>      |   |           |-- __clang_cuda_cmath.h
>      |   |           |-- __clang_cuda_complex_builtins.h
>      |   |           |-- __clang_cuda_intrinsics.h
>      |   |           |-- __clang_cuda_math_forward_declares.h
>      |   |           |-- __clang_cuda_runtime_wrapper.h
>      |   |           |-- __stddef_max_align_t.h
>      |   |           |-- __wmmintrin_aes.h
>      |   |           |-- __wmmintrin_pclmul.h
>      |   |           |-- adxintrin.h
>      |   |           |-- altivec.h
>      |   |           |-- ammintrin.h
>      |   |           |-- arm_acle.h
>      |   |           |-- arm_neon.h
>      |   |           |-- armintr.h
>      |   |           |-- avx2intrin.h
>      |   |           |-- avx512bwintrin.h
>      |   |           |-- avx512cdintrin.h
>      |   |           |-- avx512dqintrin.h
>      |   |           |-- avx512erintrin.h
>      |   |           |-- avx512fintrin.h
>      |   |           |-- avx512ifmaintrin.h
>      |   |           |-- avx512ifmavlintrin.h
>      |   |           |-- avx512pfintrin.h
>      |   |           |-- avx512vbmiintrin.h
>      |   |           |-- avx512vbmivlintrin.h
>      |   |           |-- avx512vlbwintrin.h
>      |   |           |-- avx512vlcdintrin.h
>      |   |           |-- avx512vldqintrin.h
>      |   |           |-- avx512vlintrin.h
>      |   |           |-- avx512vpopcntdqintrin.h
>      |   |           |-- avxintrin.h
>      |   |           |-- bmi2intrin.h
>      |   |           |-- bmiintrin.h
>      |   |           |-- clflushoptintrin.h
>      |   |           |-- clzerointrin.h
>      |   |           |-- cpuid.h
>      |   |           |-- cuda_wrappers
>      |   |           |   |-- algorithm
>      |   |           |   |-- complex
>      |   |           |   `-- new
>      |   |           |-- emmintrin.h
>      |   |           |-- f16cintrin.h
>      |   |           |-- float.h
>      |   |           |-- fma4intrin.h
>      |   |           |-- fmaintrin.h
>      |   |           |-- fxsrintrin.h
>      |   |           |-- htmintrin.h
>      |   |           |-- htmxlintrin.h
>      |   |           |-- ia32intrin.h
>      |   |           |-- immintrin.h
>      |   |           |-- intrin.h
>      |   |           |-- inttypes.h
>      |   |           |-- iso646.h
>      |   |           |-- limits.h
>      |   |           |-- lwpintrin.h
>      |   |           |-- lzcntintrin.h
>      |   |           |-- mm3dnow.h
>      |   |           |-- mm_malloc.h
>      |   |           |-- mmintrin.h
>      |   |           |-- module.modulemap
>      |   |           |-- msa.h
>      |   |           |-- mwaitxintrin.h
>      |   |           |-- nmmintrin.h
>      |   |           |-- opencl-c.h
>      |   |           |-- pkuintrin.h
>      |   |           |-- pmmintrin.h
>      |   |           |-- popcntintrin.h
>      |   |           |-- prfchwintrin.h
>      |   |           |-- rdseedintrin.h
>      |   |           |-- rtmintrin.h
>      |   |           |-- s390intrin.h
>      |   |           |-- shaintrin.h
>      |   |           |-- smmintrin.h
>      |   |           |-- stdalign.h
>      |   |           |-- stdarg.h
>      |   |           |-- stdatomic.h
>      |   |           |-- stdbool.h
>      |   |           |-- stddef.h
>      |   |           |-- stdint.h
>      |   |           |-- stdnoreturn.h
>      |   |           |-- tbmintrin.h
>      |   |           |-- tgmath.h
>      |   |           |-- tmmintrin.h
>      |   |           |-- unwind.h
>      |   |           |-- vadefs.h
>      |   |           |-- varargs.h
>      |   |           |-- vecintrin.h
>      |   |           |-- wmmintrin.h
>      |   |           |-- x86intrin.h
>      |   |           |-- xmmintrin.h
>      |   |           |-- xopintrin.h
>      |   |           |-- xsavecintrin.h
>      |   |           |-- xsaveintrin.h
>      |   |           |-- xsaveoptintrin.h
>      |   |           |-- xsavesintrin.h
>      |   |           `-- xtestintrin.h
>      |   |-- libLLVM-5.0.1.so -> libLLVM-5.0.so
>      |   |-- libLLVM-5.0.so
>      |   |-- libLLVM.so -> libLLVM-5.0.so
>      |   |-- libLTO.so -> libLTO.so.5
>      |   |-- libLTO.so.5 -> libLTO.so.5.0.1
>      |   |-- libLTO.so.5.0.1
>      |   |-- libclang.so -> libclang.so.5
>      |   |-- libclang.so.5 -> libclang.so.5.0
>      |   |-- libclang.so.5.0
>      |   |-- libstdc++.so.6 -> libstdc++.so.6.0.22
>      |   |-- libstdc++.so.6.0.22
>      |   |-- libstdc++.so.6.0.22-gdb.py
>      |   `-- os-release
>      |-- lib64 -> lib
>      |-- libexec
>      |   |-- c++-analyzer
>      |   `-- ccc-analyzer
>      |-- sbin
>      `-- share
>          |-- clang
>          |   |-- bash-autocomplete.sh
>          |   |-- clang-format-bbedit.applescript
>          |   |-- clang-format-diff.py
>          |   |-- clang-format-sublime.py
>          |   |-- clang-format.el
>          |   |-- clang-format.py
>          |   |-- clang-rename.el
>          |   `-- clang-rename.py
>          |-- opt-viewer
>          |   |-- opt-diff.py
>          |   |-- opt-stats.py
>          |   |-- opt-viewer.py
>          |   |-- optpmap.py
>          |   |-- optrecord.py
>          |   `-- style.css
>          |-- scan-build
>          |   |-- scanview.css
>          |   `-- sorttable.js
>          `-- scan-view
>              |-- FileRadar.scpt
>              |-- GetRadarVersion.scpt
>              |-- Reporter.py
>              |-- ScanView.py
>              |-- bugcatcher.ico
>              `-- startfile.py
>
> Also, I must say I was impressed by the size of the libLLVM and
> libclang libraries. libLLVM is 23MB, while libclang is 22MB. What seems
> weird however is that libclang is not linked against libLLVM:
>
> $ readelf -d libclang.so.5.0
>
> Dynamic section at offset 0x15ebbd0 contains 31 entries:
>    Tag        Type                         Name/Value
>   0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
>   0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
>   0x0000000000000001 (NEEDED)             Shared library: [libc.so.0]
>   0x0000000000000001 (NEEDED)             Shared library: [ld64-uClibc.so.1]
>   0x000000000000000e (SONAME)             Library soname: [libclang.so.5]
>   0x000000000000001d (RUNPATH)            Library runpath: []
>
> Is libclang statically linked against libLLVM, causing a huge
> duplication of code size ?
>
> Looking at the build output of libclang, it indeed seems like it uses
> the .a libraries from LLVM, and not the dynamic library. So the LLVM
> code is present twice: once in libLLVM.so, and a second time in
> libclang.so. This isn't nice at all. Could you look into this ?

Yes, I've just checked with nm that functions are duplicated. I'll try to
fix this.

> I've pasted the command line used by the clang package to produce its
> libclang.so library at http://code.bulix.org/li1n6r-325499?raw. You can
> see it uses the LLVM .a files directly.
>
> My defconfig was:
>
> BR2_x86_64=y
> BR2_x86_core2=y
> BR2_TOOLCHAIN_EXTERNAL=y
> BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
> BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-x86-64-core2-full-2018.02-891-g046c5e2.tar.bz2"
> BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
> BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_16=y
> BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
> # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
> BR2_TOOLCHAIN_EXTERNAL_CXX=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> # BR2_PACKAGE_BUSYBOX is not set
> BR2_PACKAGE_CLANG=y
> # BR2_TARGET_ROOTFS_TAR is not set
>
> Thanks!
>
> Thomas

Best regards,

Valentin

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

* [Buildroot] [PATCH v6 2/4] package/libclc: new package
  2018-04-28 13:06   ` Thomas Petazzoni
@ 2018-04-30  7:54     ` Valentin Korenblit
  2018-04-30  8:02       ` Thomas Petazzoni
  0 siblings, 1 reply; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-30  7:54 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

On 28/04/2018 15:06, Thomas Petazzoni wrote:
> Hello,
>
> On Wed, 11 Apr 2018 18:14:50 +0200, Valentin Korenblit wrote:
>
>> diff --git a/package/Config.in b/package/Config.in
>> index 62770790a1..f376fad3a2 100644
>> --- a/package/Config.in
>> +++ b/package/Config.in
>> @@ -283,6 +283,7 @@ comment "Graphic libraries"
>>   	source "package/fbv/Config.in"
>>   	source "package/freerdp/Config.in"
>>   	source "package/imagemagick/Config.in"
>> +	source "package/libclc/Config.in"
>>   	source "package/linux-fusion/Config.in"
>>   	source "package/lite/Config.in"
>>   	source "package/mesa3d/Config.in"
>> diff --git a/package/libclc/Config.in b/package/libclc/Config.in
>> new file mode 100644
>> index 0000000000..a0f388c4e1
>> --- /dev/null
>> +++ b/package/libclc/Config.in
>> @@ -0,0 +1,22 @@
>> +config BR2_PACKAGE_LIBCLC
>> +	bool "libclc"
>> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
>> +	depends on BR2_HOST_GCC_AT_LEAST_4_8
>> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
>> +	depends on BR2_TOOLCHAIN_HAS_THREADS
>> +	depends on BR2_INSTALL_LIBSTDCPP
>> +	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future
>> +	depends on !BR2_STATIC_LIBS
>> +	depends on BR2_USE_WCHAR # std::wstring
> You seem to have replicated here all the dependencies of the target
> LLVM package. However, you only depend on host-llvm and host-clang. Are
> you sure all those dependencies are needed by libclc ?

Actually, it wouldn't make sense to have libclc without target LLVM, but it
is true that it is not a build dependency, so I'll remove them.

>> +# There are only two releases: release_35 and release_38, but the last
>> +# commit is from 2 years ago. Master has some recent activity.
>> +LIBCLC_VERSION = 00236279a293b3737dee08c14f25923a889d2795
>> +LIBCLC_SITE = https://git.llvm.org/git/libclc
>> +LIBCLC_SITE_METHOD = git
>> +LIBCLC_LICENSE = NCSA
>> +LIBCLC_LICENSE_FILES = LICENSE.TXT
>> +
>> +LIBCLC_DEPENDENCIES = host-clang host-llvm
>> +LIBCLC_INSTALL_STAGING = YES
>> +
>> +# C++ compiler is used to build a small tool (prepare-builtins) for the host.
>> +# It must be built with the C++ compiler from the host
>> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
>> +	--prefix="/usr" \
>> +	--includedir="/usr/local/include" \
> I'm not a big fan of /usr/local/include. Perhaps we should use
> something really special like /usr/share/libclc/ or something like
> this ?

Perfect, I'll change it to that directory

>> +	--pkgconfigdir="/usr/lib/pkgconfig" \
>> +	--with-cxx-compiler=$(HOSTCXX)
> Weird for a target package to use the host compiler, no ?

Yes, it is used only in the target utils/prepare-builtins.o, all the
other stuff is compiled with host-clang.

>> +define LIBCLC_CONFIGURE_CMDS
>> +	(cd $(@D); $(TARGET_CONFIGURE_OPTS) ./configure.py $(LIBCLC_CONF_OPTS))
> Is the configure.py script compatible with both Python 2.x and Python
> 3.x ?

I believe it is, but I'll check it.

> Best regards,
>
> Thomas

Thanks,

Valentin

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

* [Buildroot] [PATCH v6 2/4] package/libclc: new package
  2018-04-30  7:54     ` Valentin Korenblit
@ 2018-04-30  8:02       ` Thomas Petazzoni
  2018-04-30  8:35         ` Valentin Korenblit
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Petazzoni @ 2018-04-30  8:02 UTC (permalink / raw)
  To: buildroot

Hello,

On Mon, 30 Apr 2018 09:54:10 +0200, Valentin Korenblit wrote:

> >> diff --git a/package/libclc/Config.in b/package/libclc/Config.in
> >> new file mode 100644
> >> index 0000000000..a0f388c4e1
> >> --- /dev/null
> >> +++ b/package/libclc/Config.in
> >> @@ -0,0 +1,22 @@
> >> +config BR2_PACKAGE_LIBCLC
> >> +	bool "libclc"
> >> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> >> +	depends on BR2_HOST_GCC_AT_LEAST_4_8
> >> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
> >> +	depends on BR2_TOOLCHAIN_HAS_THREADS
> >> +	depends on BR2_INSTALL_LIBSTDCPP
> >> +	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future
> >> +	depends on !BR2_STATIC_LIBS
> >> +	depends on BR2_USE_WCHAR # std::wstring  
> > You seem to have replicated here all the dependencies of the target
> > LLVM package. However, you only depend on host-llvm and host-clang. Are
> > you sure all those dependencies are needed by libclc ?  
> 
> Actually, it wouldn't make sense to have libclc without target LLVM, but it
> is true that it is not a build dependency, so I'll remove them.

Is target LLVM a runtime dependency for libclc ? Could you explain a
bit the interaction between libclc and target LLVM, so that we can
decide what is the best way to express this dependency ?

> >> +# C++ compiler is used to build a small tool (prepare-builtins) for the host.
> >> +# It must be built with the C++ compiler from the host
> >> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> >> +	--prefix="/usr" \
> >> +	--includedir="/usr/local/include" \  
> > I'm not a big fan of /usr/local/include. Perhaps we should use
> > something really special like /usr/share/libclc/ or something like
> > this ?  
> 
> Perfect, I'll change it to that directory

Thanks!

> >> +	--pkgconfigdir="/usr/lib/pkgconfig" \
> >> +	--with-cxx-compiler=$(HOSTCXX)  
> > Weird for a target package to use the host compiler, no ?  
> 
> Yes, it is used only in the target utils/prepare-builtins.o, all the
> other stuff is compiled with host-clang.

OK.

Thanks!

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

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

* [Buildroot] [PATCH v6 2/4] package/libclc: new package
  2018-04-30  8:02       ` Thomas Petazzoni
@ 2018-04-30  8:35         ` Valentin Korenblit
  0 siblings, 0 replies; 12+ messages in thread
From: Valentin Korenblit @ 2018-04-30  8:35 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

On 30/04/2018 10:02, Thomas Petazzoni wrote:
> Hello,
>
> On Mon, 30 Apr 2018 09:54:10 +0200, Valentin Korenblit wrote:
>
>>>> diff --git a/package/libclc/Config.in b/package/libclc/Config.in
>>>> new file mode 100644
>>>> index 0000000000..a0f388c4e1
>>>> --- /dev/null
>>>> +++ b/package/libclc/Config.in
>>>> @@ -0,0 +1,22 @@
>>>> +config BR2_PACKAGE_LIBCLC
>>>> +	bool "libclc"
>>>> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
>>>> +	depends on BR2_HOST_GCC_AT_LEAST_4_8
>>>> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
>>>> +	depends on BR2_TOOLCHAIN_HAS_THREADS
>>>> +	depends on BR2_INSTALL_LIBSTDCPP
>>>> +	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future
>>>> +	depends on !BR2_STATIC_LIBS
>>>> +	depends on BR2_USE_WCHAR # std::wstring
>>> You seem to have replicated here all the dependencies of the target
>>> LLVM package. However, you only depend on host-llvm and host-clang. Are
>>> you sure all those dependencies are needed by libclc ?
>> Actually, it wouldn't make sense to have libclc without target LLVM, but it
>> is true that it is not a build dependency, so I'll remove them.
> Is target LLVM a runtime dependency for libclc ? Could you explain a
> bit the interaction between libclc and target LLVM, so that we can
> decide what is the best way to express this dependency ?

Yes, it is a runtime dependency. libclc is a library that provides device
builtin functions defined in the OpenCL specification in LLVM IR bitcode.
At some point, they will need to be processed by the LLVM code generator,
AMDGPU backend in this case, as this library is required by the OpenCL
implementation of Mesa (Clover) which targets GPUs using either R600 or
RadeonSI Gallium drivers.

>
>>>> +# C++ compiler is used to build a small tool (prepare-builtins) for the host.
>>>> +# It must be built with the C++ compiler from the host
>>>> +LIBCLC_CONF_OPTS = --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
>>>> +	--prefix="/usr" \
>>>> +	--includedir="/usr/local/include" \
>>> I'm not a big fan of /usr/local/include. Perhaps we should use
>>> something really special like /usr/share/libclc/ or something like
>>> this ?
>> Perfect, I'll change it to that directory
> Thanks!
>
>>>> +	--pkgconfigdir="/usr/lib/pkgconfig" \
>>>> +	--with-cxx-compiler=$(HOSTCXX)
>>> Weird for a target package to use the host compiler, no ?
>> Yes, it is used only in the target utils/prepare-builtins.o, all the
>> other stuff is compiled with host-clang.
> OK.
>
> Thanks!
>
> Thomas

Best regards,

Valentin

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

end of thread, other threads:[~2018-04-30  8:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11 16:14 [Buildroot] [PATCH v6 0/4] llvm for mesa3d Valentin Korenblit
2018-04-11 16:14 ` [Buildroot] [PATCH v6 1/4] package/clang: new package Valentin Korenblit
2018-04-28 12:51   ` Thomas Petazzoni
2018-04-30  7:20     ` Valentin Korenblit
2018-04-11 16:14 ` [Buildroot] [PATCH v6 2/4] package/libclc: " Valentin Korenblit
2018-04-28 13:06   ` Thomas Petazzoni
2018-04-30  7:54     ` Valentin Korenblit
2018-04-30  8:02       ` Thomas Petazzoni
2018-04-30  8:35         ` Valentin Korenblit
2018-04-11 16:14 ` [Buildroot] [PATCH v6 3/4] package/mesa3d: enable OpenCL support Valentin Korenblit
2018-04-11 16:14 ` [Buildroot] [PATCH v6 4/4] package/clinfo: new package Valentin Korenblit
2018-04-23 16:14 ` [Buildroot] [PATCH v6 0/4] llvm for mesa3d Romain Naour

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