llvm for mesa3d
v6 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
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
Signature · 1 line
2.14.3
PATCH v6 1/4 package/clang: new package
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
--- 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
DEVELOPERS +1 -0
@@ -1906,6 +1906,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 +1 -0
@@ -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"
package/clang/Config.in new file +22 -0
@@ -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
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 +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH v6 1/4 package/clang: new package
Hello Valentin,
Quoted 14 lines · Valentin Korenblit
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_DIRas it is not installed by default but is needed for cross-compilation: http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.htmlSigned-off-by Valentin Korenblit <[email protected]>
Quoted 10 lines
--- 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.pyAlso, 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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v6 1/4 package/clang: new package
Hi Thomas,
Quoted 33 lines · Thomas Petazzoni
Hello Valentin,
Quoted 21 lines · Valentin Korenblit
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_DIRas it is not installed by default but is needed for cross-compilation: http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.htmlSigned-off-by Valentin Korenblit <[email protected]>--- 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(+)Quoted 3 lines
create mode 100644 package/clang/Config.in
create mode 100644 package/clang/clang.hash
create mode 100644package/clang/clang.mkI've applied to master, after doing the following changes:
[Thomas:
- Add Config.in comment aboutBR2_TOOLCHAIN_HAS_GCC_BUG_64735
- Minor reformatting/rewrapping of comments in .mk file]
Quoted 5 lines
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/clangdon'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.
Quoted 170 lines
`-- 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.pyAlso, 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.0Dynamic section at offset
0x15ebbd0contains 31 entries:
Tag Type Name/Value0x0000000000000001 (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: []
Quoted 7 lines
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.
Quoted 22 lines
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_DEBUGis not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
#BR2_PACKAGE_BUSYBOXis not set
BR2_PACKAGE_CLANG=y
#BR2_TARGET_ROOTFS_TARis not set
Quoted 3 lines
Thanks!
Thomas
Best regards,
Valentin
PATCH v6 2/4 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 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.
--- 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
DEVELOPERS +1 -0
@@ -1907,6 +1907,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
@@ -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"
package/libclc/Config.in new file +22 -0
@@ -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
package/libclc/libclc.hash new file +3 -0
@@ -0,0 +1,3 @@ +# locally calculated +sha256 e2f1f294f93695f2d1f87ccb9760231b435702dd0c27abeb38baa97186674d9e libclc-00236279a293b3737dee08c14f25923a889d2795.tar.gz +sha256 c66aa55d8478b45f1018500af9f433dd271444ad304d683dd49ff2a42f30dad1 LICENSE.TXT
package/libclc/libclc.mk new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH v6 2/4 package/libclc: new package
Hello,
Quoted 18 lines · Valentin Korenblit
package/Config.in +1
-0@@ -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"package/libclc/Config.in new file +0
-0
package/libclc/Config.in line 10
Quoted 10 lines
package/libclc/Config.in new file +10
-0@@ -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 ?
Quoted 6 lines
package/libclc/Config.in new file +6
-0+# 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
package/libclc/Config.in
Quoted 10 lines
package/libclc/Config.in new file +10
-0+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 ?
package/libclc/Config.in
Quoted 2 lines
package/libclc/Config.in new file +2
-0+ --pkgconfigdir="/usr/lib/pkgconfig" \ + --with-cxx-compiler=$(HOSTCXX)
Weird for a target package to use the host compiler, no ?
package/libclc/Config.in
Quoted 2 lines
package/libclc/Config.in new file +2
-0+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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v6 2/4 package/libclc: new package
Hello Thomas,
Quoted 27 lines · Thomas Petazzoni
Hello,
Quoted 23 lines · Valentin Korenblit
package/Config.in +1
-0@@ -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"package/libclc/Config.in new file +5
-0@@ -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
Quoted 8 lines
package/libclc/Config.in line 10
Quoted 5 lines
package/libclc/Config.in new file +5
-0+ 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::wstringYou 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.
Quoted 11 lines
Quoted 11 lines
package/libclc/Config.in new file +11
-0+# 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 +
Quoted 8 lines
package/libclc/Config.in
Quoted 5 lines
package/libclc/Config.in new file +5
-0+# 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
Quoted 3 lines
package/libclc/Config.in
Quoted 2 lines
package/libclc/Config.in new file +2
-0+ --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.
Quoted 4 lines
package/libclc/Config.in
Quoted 2 lines
package/libclc/Config.in new file +2
-0+define LIBCLC_CONFIGURE_CMDS + (cd $(@D); $(TARGET_CONFIGURE_OPTS) ./configure.py $(LIBCLC_CONF_OPTS))Is the
configure.pyscript compatible with both Python 2.x and Python 3.x ?
I believe it is, but I'll check it.
Quoted 3 lines
Best regards,
Thomas
Thanks,
Valentin
PATCH v6 2/4 package/libclc: new package
Hello,
Quoted 20 lines · Valentin Korenblit
Quoted 11 lines
Quoted 11 lines
package/libclc/Config.in new file +5
-0@@ -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_8Quoted 8 lines
package/libclc/Config.in line 10
Quoted 5 lines
package/libclc/Config.in new file +5
-0+ 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::wstringYou 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 ?
Quoted 2 lines
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 ?
Quoted 10 lines
Quoted 8 lines
package/libclc/Config.in line 15
Quoted 5 lines
package/libclc/Config.in new file +5
-0+# 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!
Quoted 6 lines
Quoted 3 lines
package/libclc/Config.in line 17
Quoted 2 lines
package/libclc/Config.in new file +2
-0+ --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
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v6 2/4 package/libclc: new package
Hi Thomas,
Quoted 23 lines · Thomas Petazzoni
Hello,
Quoted 19 lines · Valentin Korenblit
Quoted 19 lines
Quoted 6 lines
package/libclc/Config.in new file +0
-0package/libclc/Config.in line 10
Quoted 10 lines
package/libclc/Config.in new file +10
-0@@ -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::wstringYou 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 ?
Quoted 5 lines
Quoted 2 lines
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.
Quoted 15 lines
Quoted 10 lines
Quoted 9 lines
package/libclc/Config.in line 15
Quoted 6 lines
package/libclc/Config.in new file +5
-0+# 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!
Quoted 3 lines
Quoted 3 lines
package/libclc/Config.in line 17
Quoted 2 lines
package/libclc/Config.in new file +2
-0+ --pkgconfigdir="/usr/lib/pkgconfig" \ + --with-cxx-compiler=$(HOSTCXX)Weird for a target package to use the host compiler, no ?
Quoted 7 lines
Quoted 2 lines
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
PATCH v6 3/4 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.
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.
--- package/mesa3d/Config.in | 8 ++++++++ package/mesa3d/mesa3d.mk | 9 +++++++++ 2 files changed, 17 insertions(+)
package/mesa3d/Config.in +8 -0
@@ -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
package/mesa3d/mesa3d.mk +9 -0
@@ -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))
Signature · 1 line
2.14.3
PATCH v6 4/4 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 | 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
DEVELOPERS +1 -0
@@ -1907,6 +1907,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
@@ -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"
package/clinfo/Config.in new file +9 -0
@@ -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
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
v6 cover llvm for mesa3d
In reply to Valentin KorenblitHi All,
Le 11/04/2018 ? 18:14, Valentin Korenblit a ?crit?:
Quoted 2 lines
Hello all,
[...]
Quoted 7 lines
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