Adding LLVM + support for it in Mesa3D
cover Adding LLVM + support for it in Mesa3D
Hello everybody,
This set of patches adds an LLVM package. For now my main motivation is to enable support for llvmpipe in Mesa3D'd swrast Gallium driver, which we I am using in am embedded ARM device which does not provide a GPU, and software rendering is enough for a small 320x240 LCD framebuffer -- so that is tested and working.
So far the built LLVM enables only the code generation backend for the CPU of the target device, which fits the Mesa3D use-case. Having a llvm package in Buildroot is interesting for many reasons, and I see this as a first step, on top of which to build on later: target packages for new programming languages using Clang+LLVM as cross-toolchain, or enabling building programs written in Rust are just a few examples.
I'll be happy to iterate on these patches with your feedback (keep me CC'd, please), and have them upstream.
Best regards,
--
Adri?n ?
Adrian Perez de Castro (2):
llvm: new package
mesa3d: Allow optionally using LLVM in drivers
package/Config.in | 1 + ...-Clean-up-exported-values-update-for-shar.patch | 57 ++++++++ package/llvm/Config.in | 48 +++++++ package/llvm/llvm.hash | 2 + package/llvm/llvm.mk | 145 +++++++++++++++++++++ package/mesa3d/Config.in | 11 ++ package/mesa3d/mesa3d.mk | 9 +- 7 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch create mode 100644 package/llvm/Config.in create mode 100644 package/llvm/llvm.hash create mode 100644 package/llvm/llvm.mk
Signature · 1 line
2.13.1
PATCH 1/2 llvm: new package
--- package/Config.in | 1 + ...-Clean-up-exported-values-update-for-shar.patch | 57 ++++++++ package/llvm/Config.in | 48 +++++++ package/llvm/llvm.hash | 2 + package/llvm/llvm.mk | 145 +++++++++++++++++++++ 5 files changed, 253 insertions(+) create mode 100644 package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch create mode 100644 package/llvm/Config.in create mode 100644 package/llvm/llvm.hash create mode 100644 package/llvm/llvm.mk
package/Config.in +1 -0
@@ -146,6 +146,7 @@ menu "Development tools" source "package/jo/Config.in" source "package/jq/Config.in" source "package/libtool/Config.in" + source "package/llvm/Config.in" source "package/make/Config.in" source "package/patch/Config.in" source "package/pkgconf/Config.in"
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +57 -0
57 lines not on this page · raw message
package/llvm/Config.in new file +48 -0
48 lines not on this page · raw message
package/llvm/llvm.hash new file +2 -0
@@ -0,0 +1,2 @@ +# Computed locally after checking the GPG signature: +sha256 8d10511df96e73b8ff9e7abbfb4d4d432edbdbe965f1f4f07afaf370b8a533be llvm-4.0.0.src.tar.xz
package/llvm/llvm.mk new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.13.1
PATCH 1/2 llvm: new package
Hello,
Quoted 1 line · Adrian Perez de Castro
Signed-off-by Adrian Perez de Castro <[email protected]>
Thanks a lot for this patch. It's definitely good to see someone working on LLVM support.
Quoted 6 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +0
-0
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch line 9
Quoted 9 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +9
-0@@ -0,0 +1,57 @@ +From 628b899be14a6bab4b32dbd53aabd447dcc16cb7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Sat, 20 Aug 2016 23:47:41 +0200 +Subject: [PATCH] llvm-config: Clean up exported values, update for shared + linking + +Gentoo-specific fixup for llvm-config, including: +- wiping build-specific CFLAGS, CXXFLAGS, +- making --src-root return invalid path (/dev/null).
It would be nice to explain why this patch is needed.
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch line 18
Quoted 9 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +9
-0+ +Thanks to Steven Newbury for the initial patch. + +Bug: https://bugs.gentoo.org/565358 +Bug: https://bugs.gentoo.org/501684 + +Fetch from: https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-devel/llvm/files/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch + +
Please add your Signed-off-by here.
package/llvm/Config.in line 1
Quoted 7 lines
package/llvm/Config.in new file +1
-0@@ -0,0 +1,48 @@ +config BR2_PACKAGE_HOST_LLVM_ARCH_SUPPORT
Why are you calling this BR2_PACKAGE_HOST_LLVM ? Isn't this instead related to which target architectures LLVM support?
Also, it should be "SUPPORTS" with a final "S".
package/llvm/Config.in line 9
Quoted 8 lines
package/llvm/Config.in new file +8
-0+ bool + default y + depends on BR2_arm || BR2_armeb || BR2_aarch64 || \ + BR2_i386 || BR2_x86_64 || \ + BR2_mips || BR2_mipsel || \ + BR2_mips64 || BR2_mips64el || \ + BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le || \ + BR2_sparc
It would IMO be a bit more readable as follows:
config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
bool
default y if BR2_arm || BR2_armeb
default y if BR2_aarch64
default y if ...
package/llvm/Config.in line 11
Quoted 1 line
package/llvm/Config.in new file +1
-0+menuconfig BR2_PACKAGE_LLVM
A "menuconfig" is probably not needed, keep this just a plain "config".
package/llvm/Config.in line 14
Quoted 3 lines
package/llvm/Config.in new file +3
-0+ bool "llvm" + depends on BR2_PACKAGE_HOST_LLVM_ARCH_SUPPORT && \ + BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_BUILDROOT_WCHAR
Please split each depends on on its own line.
package/llvm/Config.in line 21
Quoted 7 lines
package/llvm/Config.in new file +7
-0+ select BR2_PACKAGE_LIBXML2 + select BR2_PACKAGE_ZLIB + help + The LLVM Project is a collection of modular and reusable compiler + and toolchain technologies. + + http://llvm.org
Indentation of the help text is one tab + two spaces. Please run your package through ./support/scripts/check-package to detect such coding style related issues.
package/llvm/Config.in line 23
Quoted 1 line
package/llvm/Config.in new file +1
-0+comment "llvm requires C++ and wide-character support"
Should be:
comment "llvm needs a toolchain w/ C++, wchar"
depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
Indeed, the wording of such comments is standardized in Buildroot, and the depends on allows to not show the comment if llvm is anyway not available for the selected architecture.
package/llvm/Config.in line 30
Quoted 7 lines
package/llvm/Config.in new file +7
-0+ depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_BUILDROOT_WCHAR + +if BR2_PACKAGE_LLVM + +config BR2_PACKAGE_LLVM_ENABLE_FFI + bool "Support libffi" + default n
"default n" is never needed, as it's the default, please remove everywhere.
package/llvm/Config.in line 34
Quoted 4 lines
package/llvm/Config.in new file +4
-0+ select BR2_PACKAGE_LIBFFI + help + Use libffi in the LLVM Interpreter in order to enable calling + external functions.
One tab + two spaces for the indentation (please fix globally).
package/llvm/Config.in line 46
Quoted 11 lines
package/llvm/Config.in new file +11
-0+config BR2_PACKAGE_LLVM_ENABLE_RTTI + bool "C++: Support RTTI" + default n + help + Enable support for C++ Run-Time Type Information (RTTI) + +config BR2_PACKAGE_LLVM_ENABLE_EH + bool "C++: Support exception handling" + default n + help + Enable support for C++ exception handling (try/catch)
Is it really important to make those features configurable, as opposed to having them unconditionally enabled? What is the size impact?
Quoted 6 lines
package/llvm/llvm.mk new file +0
-0
package/llvm/llvm.mk line 10
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0@@ -0,0 +1,145 @@ +################################################################################ +# +# llvm +# +################################################################################ + +LLVM_VERSION = 4.0.0 +LLVM_SITE = http://llvm.org/releases/$(LLVM_VERSION) +LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz +LLVM_LICENSE = University of Illinois/NCSA Open Source License
We want SPDX license codes for the <pkg>_LICENSE variable. According to
https://spdx.org/licenses/, the corresponding code is just "NCSA".
package/llvm/llvm.mk line 13
Quoted 3 lines
package/llvm/llvm.mk new file +3
-0+LLVM_LICENSE_FILES = LICENSE.TXT +LLVM_INSTALL_STAGING = YES +LLVM_INSTALL_TARGET = YES
This last line is not needed, it's the default.
package/llvm/llvm.mk line 14
Quoted 1 line
package/llvm/llvm.mk new file +1
-0+LLVM_DEPENDENCIES = libxml2 zlib host-python host-cmake
Remove host-cmake, it's automatically added to the dependencies since you're using cmake-package.
Quoted 22 lines
package/llvm/llvm.mk new file +22
-0+# Determine the name of the LLVM target to enable depending on +# the Buildroot target settings. +# +ifeq ($(BR2_i386),y) + LLVM_TARGET_ARCH := X86 +else ifeq ($(BR2_x86_64),y) + LLVM_TARGET_ARCH := X86 +else ifeq ($(BR2_arm),y) + LLVM_TARGET_ARCH := ARM +else ifeq ($(BR2_armeb),y) + LLVM_TARGET_ARCH := ARM +else ifeq ($(BR2_aarch64),y) + LLVM_TARGET_ARCH := AArch64 +else ifeq ($(BR2_mips),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_mipsel),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_mips64),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_mips64el),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_powerpc),y)
package/llvm/llvm.mk line 47
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+ LLVM_TARGET_ARCH := PowerPC +else ifeq ($(BR2_powerpc64),y) + LLVM_TARGET_ARCH := PowerPC +else ifeq ($(BR2_powerpc64le),y) + LLVM_TARGET_ARCH := PowerPC +else ifeq ($(BR2_sparc),y) + LLVM_TARGET_ARCH := Sparc +else + $(error Target architecture not supported by LLVM) +endif
Don't use := for assignments, but =. Also, this could probably be more nicely handled in the Config.in file. Something like:
config BR2_PACKAGE_LLVM_ARCH
string default "X86" if BR2_i386 || BR2_x86_64 default "ARM" if BR2_arm || BR2_armeb ...
and in llvm.mk:
LLVM_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_ARCH))
package/llvm/llvm.mk line 53
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+# List of build options at: +# http://llvm.org/docs/CMake.html +# +LLVM_CONF_OPTS := \
Use = for assignments, not :=.
package/llvm/llvm.mk line 59
Quoted 6 lines
package/llvm/llvm.mk new file +6
-0+ -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME) \ + -DLLVM_HOST_TRIPLE=$(GNU_TARGET_NAME) \ + -DLLVM_TARGETS_TO_BUILD=$(LLVM_TARGET_ARCH) \ + -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH) \ + -DLLVM_OPTIMIZED_TABLEGEN=YES \ + -DLLVM_ENABLE_ZLIB=YES \
zlib support is optional ?
package/llvm/llvm.mk line 68
Quoted 9 lines
package/llvm/llvm.mk new file +9
-0+ -DLLVM_INCLUDE_TOOLS=YES \ + -DLLVM_INCLUDE_UTILS=NO \ + -DLLVM_INCLUDE_EXAMPLES=NO \ + -DLLVM_INCLUDE_TESTS=NO \ + -DLLVM_BUILD_TESTS=NO \ + -DLLVM_BUILD_RUNTIME=NO \ + -DLLVM_ENABLE_PROJECTS='' + +
Please use only one blank line.
package/llvm/llvm.mk line 76
Quoted 8 lines
package/llvm/llvm.mk new file +8
-0+# The Go bindings have no CMake rules at the moment, but better remove the +# check preventively. Building the Go and OCaml bindings is yet unsupported. +# +LLVM_CONF_OPTS += \ + -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \ + -DOCAMLFIND=OCAMLFIND-NOTFOUND + +
Only one blank line.
package/llvm/llvm.mk line 83
Quoted 7 lines
package/llvm/llvm.mk new file +7
-0+# Building per-component shared libraries is NOT recommended by upstream. +# The all-in-one libLLVM-<version>.so is enabled with a different setting. +LLVM_CONF_OPTS += \ + -DBUILD_SHARED_LIBS=NO \ + -DLLVM_BUILD_LLVM_DYLIB=$(if $(BR2_STATIC_LIBS),NO,YES) + +
Only one blank line.
package/llvm/llvm.mk line 88
Quoted 5 lines
package/llvm/llvm.mk new file +5
-0+ifeq ($(BR2_PACKAGE_LLVM_ENABLE_FFI),y) + LLVM_DEPENDENCIES += libffi + LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=YES +else + LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=NO
No indentation inside the ifeq...endif blocks (please fix globally).
package/llvm/llvm.mk line 111
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+# XXX: LLVM does include some support for building native tools. This is used +# to build e.g. llvm-config, and a host-native llvm-tblgen if needed. +# Unfortunately, Buildroot is overzealous about passing the parameters +# needed for cross-building, and the CMake configuration for the native
Can you explain in what respect Buildroot is "overzealous"? Is there anything we can/should fix?
Quoted 7 lines
package/llvm/llvm.mk new file +7
-0+# tools ends up using the cross-toolchain. Once "cmake-package" has +# defined LLVM_*_CMDS, this adds: +# +# - A call to CMake which resets CMAKE_{C,CXX,ASM}_COMPILER with the +# paths to the host-native ones. Note that using the *_NOCCACHE +# variables is needed, otherwise CMake will choke. +#
package/llvm/llvm.mk line 128
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+# - The file "BuildVariables.inc" is copied over from the cross-build +# directory to the native one. This way a new "llvm-config" which +# can run on the build host returns information about the target +# build which gets installed in the sysroot. This is done as an +# appended build command. Note that Make has to be re-invoked to +# rebuild after copying the file over. +# +# - Last but not least, "llvm-config" is copied into the sysroot with +# the target triple prefix, because packages using sane build systems +# will first try that.
Buildroot doesn't rename <foo>-config scripts/programs to be prefixed with the target triple prefix, so it would be better to keep it named llvm-config, like all other <foo>-config in $(STAGING_DIR)/usr/bin.
package/llvm/llvm.mk line 130
Quoted 1 line
package/llvm/llvm.mk new file +1
-0+LLVM_CONFIGURE_CMDS += \
Using those += is really not clean. Instead, you should use POST_CONFIGURE_HOOKS, POST_BUILD_HOOKS and POST_INSTALL_STAGING_HOOKS.
However, I'd really like to understand how Buildroot is "overzealous" and see if things can work out of the box without doing those hacks.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/2 llvm: new package
Hello,
Thanks for taking some time to review the patches :-) I'll comment inline below.
Quoted 15 lines · Thomas Petazzoni
Quoted 1 line · Adrian Perez de Castro
Signed-off-by Adrian Perez de Castro <[email protected]>Thanks a lot for this patch. It's definitely good to see someone working on LLVM support.
Quoted 9 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +3
-0@@ -0,0 +1,57 @@ +From 628b899be14a6bab4b32dbd53aabd447dcc16cb7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Sat, 20 Aug 2016 23:47:41 +0200
Quoted 8 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch line 9
Quoted 6 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +6
-0+Subject: [PATCH] llvm-config: Clean up exported values, update for shared + linking + +Gentoo-specific fixup for llvm-config, including: +- wiping build-specific CFLAGS, CXXFLAGS, +- making --src-root return invalid path (/dev/null).It would be nice to explain why this patch is needed.
This patch does a couple of things which I are interesting for myself (to build Mesa3D with llvmpipe in swrast), and which I image may be desired for Buildroot as well:
* Removes CFLAGS/CXXFLAGS from the output of ?llvm-config?. This way packages which use LLVM will use the Buildroot compiler flags (either global ones or defined locally-defined in a package). For example, this avoids cases like the following:
- A build being done with ?-Os? chosen in .config
- A package known to break with ?-Os? replaces it with ?-O2?.
- LLVM built with ?-Os? has the output from ?llvm-config? including ?-Os? and adding that to the package build flags end up being ?-O2 ? -Os?, resulting in a broken package.
* It makes ?llvm-config --src-root? return ?/dev/null?. This is to prevent other packages to build tools which should be built as part of the LLVM build process (and that therefore need the path to the LLVM sources).
Depending on which approach Buildroot follows regarding additional tools (lldb, clang, lld, etc), it may be possible to drop the second part of the patch. What would we prefer, using separate per-component packages, or sub-options for the LLVM package? Personally I would favor the latter, as it seems to be less error prone, but I have no strong preference here.
Quoted 10 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch line 18
Quoted 8 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +8
-0+Thanks to Steven Newbury for the initial patch. + +Bug: https://bugs.gentoo.org/565358 +Bug: https://bugs.gentoo.org/501684 + +Fetch from: https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-devel/llvm/files/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch + +Please add your Signed-off-by here.
Oh, I forgot this, thanks.
Quoted 11 lines
package/llvm/Config.in line 1
Quoted 7 lines
package/llvm/Config.in new file +1
-0@@ -0,0 +1,48 @@ +config BR2_PACKAGE_HOST_LLVM_ARCH_SUPPORTWhy are you calling this
BR2_PACKAGE_HOST_LLVM? Isn't this instead related to which target architectures LLVM support?
Quoted 1 line
Also, it should be "SUPPORTS" with a final "S".
Indeed, this a mistake. I'll rename it to ?BR2_PACKAGE_LLVM_ARCH_SUPPORTS?.
Quoted 11 lines
package/llvm/Config.in line 9
Quoted 8 lines
package/llvm/Config.in new file +8
-0+ bool + default y + depends on BR2_arm || BR2_armeb || BR2_aarch64 || \ + BR2_i386 || BR2_x86_64 || \ + BR2_mips || BR2_mipsel || \ + BR2_mips64 || BR2_mips64el || \ + BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le || \ + BR2_sparcIt would IMO be a bit more readable as follows:
Quoted 5 lines
config
BR2_PACKAGE_LLVM_ARCH_SUPPORTS
bool
default y ifBR2_arm||BR2_armeb
default y ifBR2_aarch64
default y if ...
Cool, I didn't know that multiple ?default y? lines are supported :-)
Quoted 3 lines
package/llvm/Config.in line 11
Quoted 1 line
package/llvm/Config.in new file +1
-0+menuconfig BR2_PACKAGE_LLVMA "menuconfig" is probably not needed, keep this just a plain "config".
Okay.
Quoted 5 lines
package/llvm/Config.in line 14
Quoted 3 lines
package/llvm/Config.in new file +3
-0+ bool "llvm" + depends on BR2_PACKAGE_HOST_LLVM_ARCH_SUPPORT && \ + BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_BUILDROOT_WCHARPlease split each depends on on its own line.
Will do.
Quoted 11 lines
package/llvm/Config.in line 21
Quoted 7 lines
package/llvm/Config.in new file +7
-0+ select BR2_PACKAGE_LIBXML2 + select BR2_PACKAGE_ZLIB + help + The LLVM Project is a collection of modular and reusable compiler + and toolchain technologies. + + http://llvm.orgIndentation of the help text is one tab + two spaces. Please run your package through ./support/scripts/check-package to detect such coding style related issues.
Handy tool, and works nicely with Vim, I'm now using this to get the list of reported issues in the quickfix window:
:set makeprg=./support/scripts/check-package\ % :make
:-)
Quoted 10 lines
package/llvm/Config.in line 23
Quoted 1 line
package/llvm/Config.in new file +1
-0+comment "llvm requires C++ and wide-character support"Should be:
comment "llvm needs a toolchain w/ C++, wchar"
depends onBR2_PACKAGE_LLVM_ARCH_SUPPORTSIndeed, the wording of such comments is standardized in Buildroot, and the depends on allows to not show the comment if llvm is anyway not available for the selected architecture.
Wouldn't the existing dependencies be needed as well? I.e:
comment "llvm needs a toolchain w/ C++, wchar"
depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_BUILDROOT_WCHAR
Quoted 6 lines
Quoted 6 lines
package/llvm/Config.in new file +6
-0+config BR2_PACKAGE_LLVM_ENABLE_RTTI + bool "C++: Support RTTI" + default n + help + Enable support for C++ Run-Time Type Information (RTTI) +
Quoted 8 lines
package/llvm/Config.in line 46
Quoted 5 lines
package/llvm/Config.in new file +5
-0+config BR2_PACKAGE_LLVM_ENABLE_EH + bool "C++: Support exception handling" + default n + help + Enable support for C++ exception handling (try/catch)Is it really important to make those features configurable, as opposed to having them unconditionally enabled? What is the size impact?
Both add a measurable amount of data to the generated object code. The size binary size reduction when disabling RTTI for building LLVM are in the ballpark of 5 to 10% according to Chris Lattner, one of the developers:
https://stackoverflow.com/a/5138926
The same goes for exception handling. I did one build with both of them disabled, and another with both options enabled, with the following results for the combined shared library (?strip -x --strip-unneeded libLLVM-4.0.so?):
text data bss dec hex 15664977 385820 113648 16164445 f6a65d libLLVM-4.0.so [with EH+RTTI] 14164237 361440 113648 14639325 df60dd libLLVM-4.0.so [without EH/RTTI]
That's a total saving of 1.45 MiB, which looks pretty good to me.
Quoted 68 lines
Quoted 6 lines
package/llvm/llvm.mk new file +0
-0package/llvm/llvm.mk line 10
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0@@ -0,0 +1,145 @@ +################################################################################ +# +# llvm +# +################################################################################ + +LLVM_VERSION = 4.0.0 +LLVM_SITE = http://llvm.org/releases/$(LLVM_VERSION) +LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz +LLVM_LICENSE = University of Illinois/NCSA Open Source LicenseWe want SPDX license codes for the <pkg>_LICENSE variable. According to
https://spdx.org/licenses/, the corresponding code is just "NCSA".package/llvm/llvm.mk line 13
Quoted 3 lines
package/llvm/llvm.mk new file +3
-0+LLVM_LICENSE_FILES = LICENSE.TXT +LLVM_INSTALL_STAGING = YES +LLVM_INSTALL_TARGET = YESThis last line is not needed, it's the default.
package/llvm/llvm.mk line 14
Quoted 1 line
package/llvm/llvm.mk new file +1
-0+LLVM_DEPENDENCIES = libxml2 zlib host-python host-cmakeRemove host-cmake, it's automatically added to the dependencies since you're using cmake-package.
Quoted 22 lines
package/llvm/llvm.mk new file +22
-0+# Determine the name of the LLVM target to enable depending on +# the Buildroot target settings. +# +ifeq ($(BR2_i386),y) + LLVM_TARGET_ARCH := X86 +else ifeq ($(BR2_x86_64),y) + LLVM_TARGET_ARCH := X86 +else ifeq ($(BR2_arm),y) + LLVM_TARGET_ARCH := ARM +else ifeq ($(BR2_armeb),y) + LLVM_TARGET_ARCH := ARM +else ifeq ($(BR2_aarch64),y) + LLVM_TARGET_ARCH := AArch64 +else ifeq ($(BR2_mips),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_mipsel),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_mips64),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_mips64el),y) + LLVM_TARGET_ARCH := Mips +else ifeq ($(BR2_powerpc),y)package/llvm/llvm.mk line 47
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+ LLVM_TARGET_ARCH := PowerPC +else ifeq ($(BR2_powerpc64),y) + LLVM_TARGET_ARCH := PowerPC +else ifeq ($(BR2_powerpc64le),y) + LLVM_TARGET_ARCH := PowerPC +else ifeq ($(BR2_sparc),y) + LLVM_TARGET_ARCH := Sparc +else + $(error Target architecture not supported by LLVM) +endifDon't use := for assignments, but =. Also, this could probably be more nicely handled in the Config.in file. Something like:
config
BR2_PACKAGE_LLVM_ARCH
Quoted 8 lines
string default "X86" if BR2_i386 || BR2_x86_64 default "ARM" if BR2_arm || BR2_armeb ...and in llvm.mk:
LLVM_ARCH= $(call qstrip,$(BR2_PACKAGE_LLVM_ARCH))
Now that's a neat trick using kconfig, thanks!
Quoted 6 lines
package/llvm/llvm.mk line 53
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+# List of build options at: +# http://llvm.org/docs/CMake.html +# +LLVM_CONF_OPTS := \Use = for assignments, not :=.
Out of curiosity, and as a side question: What is the reason for not using ?:=? for assignments?
It looks to me as if it would be better to use the immediate-expansion assignment (?:=?) at least when the right side of the assignment contains potentially expensive expansions. For example:
LLVM_ARCH := $(call qstrip,$(BR2_PACKAGE_LLVM_ARCH))
LLVM_CONF_OPTS += \ -DLLVM_TARGETS_TO_BUILD=$(LLVM_ARCH) \
-DLLVM_TARGET_ARCH=$(LLVM_ARCH) ...
...will call ?qstrip? only once, while using a lazy-expansion assignment (?=?) causes the ?qstrip? macro to be called twice every time that $(LLVM_CONF_OPTS) gets expanded. Using ?:=? expands the macro just once.
(I am sure there is a good reason for sticking with ?=?, and I am curious about it, that's all)
Quoted 8 lines
package/llvm/llvm.mk line 59
Quoted 6 lines
package/llvm/llvm.mk new file +6
-0+ -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME) \ + -DLLVM_HOST_TRIPLE=$(GNU_TARGET_NAME) \ + -DLLVM_TARGETS_TO_BUILD=$(LLVM_TARGET_ARCH) \ + -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH) \ + -DLLVM_OPTIMIZED_TABLEGEN=YES \ + -DLLVM_ENABLE_ZLIB=YES \zlib support is optional ?
Yes. Support for zlib is enabled by default, and it's possible to disable it. Do you think it would be worth to enable it conditionally when zlib is being built? Probably any target for which LLVM will be built surely has a few KiB more for zlib.
Quoted 7 lines
package/llvm/llvm.mk line 111
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+# XXX: LLVM does include some support for building native tools. This is used +# to build e.g. llvm-config, and a host-native llvm-tblgen if needed. +# Unfortunately, Buildroot is overzealous about passing the parameters +# needed for cross-building, and the CMake configuration for the nativeCan you explain in what respect Buildroot is "overzealous"? Is there anything we can/should fix?
To be honest, I am not 100% sure that Buildroot is to blame here. There is some code in the build files for LLVM which supposedly handle building a version of ?llvm-config? which can be executed in the host:
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-config/CMakeLists.txt#L65
but even when ?CMAKE_CROSSCOMPILING? is indeed correctly set in the toolchain file generated by Buildroot, when the tools under ?NATIVE/? are built normally the results and up being ARM (=target) binaries. The same happens with the ?llvm-tblgen? binary, which needs to be run in the host during compilation.
After much struggling and trying different things, I settled on re-configuring the ?NATIVE/? subdirectory to use ?HOST{CC,CXX}_NOCACHE? which has been working reliably for weeks now (somehow, trying to use ccache here breaks the builds, though :-S)
Because LLVM includes some provisions for cross-compiling which are not working well, I assumed that maybe Buildroot is doing something funny here. But take into account that my knowledge of CMake is limited (for now!) and it could as well be that the LLVM build system is broken instead.
Quoted 13 lines
Quoted 13 lines
package/llvm/llvm.mk new file +13
-0+# tools ends up using the cross-toolchain. Once "cmake-package" has +# defined LLVM_*_CMDS, this adds: +# +# - A call to CMake which resets CMAKE_{C,CXX,ASM}_COMPILER with the +# paths to the host-native ones. Note that using the *_NOCCACHE +# variables is needed, otherwise CMake will choke. +# +# - The file "BuildVariables.inc" is copied over from the cross-build +# directory to the native one. This way a new "llvm-config" which +# can run on the build host returns information about the target +# build which gets installed in the sysroot. This is done as an +# appended build command. Note that Make has to be re-invoked to +# rebuild after copying the file over.
Quoted 8 lines
package/llvm/llvm.mk line 128
Quoted 4 lines
package/llvm/llvm.mk new file +4
-0+# +# - Last but not least, "llvm-config" is copied into the sysroot with +# the target triple prefix, because packages using sane build systems +# will first try that.Buildroot doesn't rename <foo>-config
scripts/programsto be prefixed with the target triple prefix, so it would be better to keep it named llvm-config, like all other <foo>-config in $(STAGING_DIR)/usr/bin.
It's fine to just call the binary ?llvm-config?, the idea behind this was to avoid this warning when configuring Mesa3D:
Checking for llvm-config... /home/aperez/devel/wpe/buildroot-upstream/output/host/usr/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/bin/llvm-config
configure: WARNING: using cross tools not prefixed with host triplet
Let's change it back to just ?llvm-config?, then.
Quoted 4 lines
package/llvm/llvm.mk line 130
Quoted 1 line
package/llvm/llvm.mk new file +1
-0+LLVM_CONFIGURE_CMDS += \Using those += is really not clean. Instead, you should use
POST_CONFIGURE_HOOKS,POST_BUILD_HOOKSandPOST_INSTALL_STAGING_HOOKS.
Certainly.
Quoted 2 lines
However, I'd really like to understand how Buildroot is "overzealous" and see if things can work out of the box without doing those hacks.
As mentioned above, I do not have a good reason to be 100% sure that this is Buildroot's fault. Any ideas on what may be going on here will be very welcome and I am willing to try and improve this as much as my spare time allows. In the next days I won't have the chance to spend time figuring this out, but at any rate, I will be submitting an updated patch today or tomorrow with the rest of suggested changes.
Cheers,
--
Adri?n ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170619/811d091c/attachment.asc>
PATCH v2 1/2 llvm: new package
In reply to Adrian Perez de Castro---
Changes v1 -> v2:
- Added missing Signed-off-by in patch.
- Renamed BR2_PACKAGE_HOST_LLVM_ARCH_SUPPORT to BR2_PACKAGE_LLVM_ARCH_SUPPORTS and made its dependencies more readable.
- Fixed indentation of help texts in Config.in.
- Changed comment in Config.in to use the standard Buildroot wording.
- Handle converting Buildroot's target architecture to LLVM's in Config.in instead of in llvm.mk.
- Change LLVM_LICENSE to use the SPDX license string.
- Use hooks in llvm.mk instead of appending commands to LLVM_*_CMDS.
- Fixed all the code style issues pointed out by support/scripts/check-package.
--- package/Config.in | 1 + ...-Clean-up-exported-values-update-for-shar.patch | 58 +++++++++++ package/llvm/Config.in | 54 ++++++++++ package/llvm/llvm.hash | 2 + package/llvm/llvm.mk | 116 +++++++++++++++++++++ 5 files changed, 231 insertions(+) create mode 100644 package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch create mode 100644 package/llvm/Config.in create mode 100644 package/llvm/llvm.hash create mode 100644 package/llvm/llvm.mk
package/Config.in +1 -0
@@ -146,6 +146,7 @@ menu "Development tools" source "package/jo/Config.in" source "package/jq/Config.in" source "package/libtool/Config.in" + source "package/llvm/Config.in" source "package/make/Config.in" source "package/patch/Config.in" source "package/pkgconf/Config.in"
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +58 -0
58 lines not on this page · raw message
package/llvm/Config.in new file +54 -0
54 lines not on this page · raw message
package/llvm/llvm.hash new file +2 -0
@@ -0,0 +1,2 @@ +# Computed locally after checking the GPG signature: +sha256 8d10511df96e73b8ff9e7abbfb4d4d432edbdbe965f1f4f07afaf370b8a533be llvm-4.0.0.src.tar.xz
package/llvm/llvm.mk new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.13.1
PATCH v2 2/2 mesa3d: Allow optionally using LLVM in drivers
--- package/mesa3d/Config.in | 11 +++++++++++ package/mesa3d/mesa3d.mk | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
package/mesa3d/Config.in +11 -0
@@ -44,6 +44,17 @@ config BR2_PACKAGE_MESA3D_DRIVER config BR2_PACKAGE_MESA3D_NEEDS_XA bool +config BR2_PACKAGE_MESA3D_USE_LLVM + bool "Enable LLVM usage" + default y + depends on BR2_PACKAGE_LLVM + select BR2_PACKAGE_LLVM_ENABLE_RTTI + help + Build optimized driver code which makes use of LLVM (e.g. llvmpipe). + +comment "optional llvm support depends on llvm" + depends on !BR2_PACKAGE_LLVM + comment "Gallium drivers" config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_ETNAVIV
package/mesa3d/mesa3d.mk +8 -1
@@ -57,6 +57,13 @@ MESA3D_CONF_OPTS += \ --disable-xa endif +ifeq ($(BR2_PACKAGE_MESA3D_USE_LLVM),y) +MESA3D_DEPENDENCIES += llvm +MESA3D_CONF_OPTS += --enable-llvm +else +MESA3D_CONF_OPTS += --disable-llvm +endif + # Drivers #Gallium Drivers
@@ -214,6 +221,6 @@ MESA3D_CONF_OPTS += --disable-lmsensors endif # Avoid automatic search of llvm-config -MESA3D_CONF_OPTS += --with-llvm-prefix=$(STAGING_DIR)/usr/bin +MESA3D_CONF_OPTS += --with-llvm-prefix=$(STAGING_DIR)/usr $(eval $(autotools-package))
Signature · 1 line
2.13.1
PATCH v2 1/2 llvm: new package
In reply to Adrian Perez de CastroHi Adrian,
Le 19/06/2017 ? 21:03, Adrian Perez de Castro a ?crit :
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch
Quoted 44 lines
Signed-off-by Adrian Perez de Castro <[email protected]>---
Changes v1 -> v2:
- Added missing Signed-off-by in patch.
- RenamedBR2_PACKAGE_HOST_LLVM_ARCH_SUPPORTtoBR2_PACKAGE_LLVM_ARCH_SUPPORTSand made its dependencies more readable.
- Fixed indentation of help texts in Config.in.
- Changed comment in Config.in to use the standard Buildroot wording.
- Handle converting Buildroot's target architecture to LLVM's in Config.in instead of in llvm.mk.
- ChangeLLVM_LICENSEto use the SPDX license string.
- Use hooks in llvm.mk instead of appending commands to LLVM_*_CMDS.
- Fixed all the code style issues pointed out by support/scripts/check-package.--- package/Config.in | 1 + ...-Clean-up-exported-values-update-for-shar.patch | 58 +++++++++++ package/llvm/Config.in | 54 ++++++++++ package/llvm/llvm.hash | 2 + package/llvm/llvm.mk | 116 +++++++++++++++++++++ 5 files changed, 231 insertions(+) create mode 100644 package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch create mode 100644 package/llvm/Config.in create mode 100644 package/llvm/llvm.hash create mode 100644 package/llvm/llvm.mkpackage/Config.in +1
-0@@ -146,6 +146,7 @@ menu "Development tools" source "package/jo/Config.in" source "package/jq/Config.in" source "package/libtool/Config.in" + source "package/llvm/Config.in" source "package/make/Config.in" source "package/patch/Config.in" source "package/pkgconf/Config.in"package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +0
-0
The patch should be named 0001-llvm-config-Clean-up-exported-values-update-for-shar.patch
Quoted 29 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +27
-0@@ -0,0 +1,58 @@ +From 628b899be14a6bab4b32dbd53aabd447dcc16cb7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Sat, 20 Aug 2016 23:47:41 +0200 +Subject: [PATCH] llvm-config: Clean up exported values, update for shared + linking + +Gentoo-specific fixup for llvm-config, including: +- wiping build-specific CFLAGS, CXXFLAGS, +- making --src-root return invalid path (/dev/null). + +Thanks to Steven Newbury for the initial patch. + +Bug: https://bugs.gentoo.org/565358 +Bug: https://bugs.gentoo.org/501684 + +Fetch from: https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-devel/llvm/files/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch + +Signed-off-by: Adrian Perez de Castro <[email protected]> + +diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt +index 744fa4e44d1..593788aaef3 100644 +--- a/tools/llvm-config/CMakeLists.txt ++++ b/tools/llvm-config/CMakeLists.txt +@@ -32,8 +32,12 @@ get_property(COMPILE_FLAGS TARGET llvm-config PROPERTY COMPILE_FLAGS) + set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR}) + set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR}) + set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch line 35
Quoted 10 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +8
-0+-set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") +-set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}") ++# Just use CMAKE_CPP_FLAGS for CFLAGS and CXXFLAGS, otherwise compiler ++# specific flags will be set when we don't know what compiler will be used ++# with external project utilising llvm-config. C++ Standard is required. ++# TODO: figure out if we can remove -std=c++11 and move it to revdeps. ++set(LLVM_CFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") ++set(LLVM_CXXFLAGS "${CMAKE_CPP_FLAGS} -std=c++11 ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
The Gentoo bug is quite old now (2015) can you check if this part is still needed ?
With llvm-config build without this patch, -std=c++1y is present in cxxflags.
./test/llvm/host/usr/bin/llvm-config --cxxflags -I/home/naourr/buildroot-test/test/llvm/host/usr/include -O2 -I/home/naourr/buildroot-test/test/llvm/host/usr/include -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++1y -ffunction-sections -fdata-sections -O2 -DNDEBUG -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
Quoted 7 lines
+
set(LLVM_BUILD_SYSTEM cmake)
+set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI})
+set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX}")package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +4
-0+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index d780094861c..c61c72ff48c 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch line 52
Quoted 10 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +10
-0+@@ -549,7 +550,11 @@ int main(int argc, char **argv) { + } else if (Arg == "--obj-root") { + OS << ActivePrefix << '\n'; + } else if (Arg == "--src-root") { +- OS << LLVM_SRC_ROOT << '\n'; ++ if (IsInDevelopmentTree) { ++ OS << LLVM_SRC_ROOT << '\n'; ++ } else { ++ OS << "/dev/null\n"; ++ }
Indeed:
./test/llvm/host/usr/bin/llvm-config --src-root /home/naourr/buildroot-test/test/llvm/build/host-llvm-4.0.1
Do you know which package using llvm use --src-root option ?
Quoted 22 lines
package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch new file +6
-0+ } else if (Arg == "--ignore-libllvm") { + LinkDyLib = false; + LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto; +-- +2.11.0 +package/llvm/Config.in new file +10
-0@@ -0,0 +1,54 @@ +config BR2_PACKAGE_LLVM_ARCH_SUPPORTS + bool + default y if BR2_arm || BR2_armeb + default y if BR2_aarch64 + default y if BR2_i386 || BR2_x86_64 + default y if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el + default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le + default y if BR2_sparc + +config BR2_PACKAGE_LLVM_TARGET_ARCH
package/llvm/Config.in line 20
Quoted 10 lines
package/llvm/Config.in new file +10
-0+ string + default "ARM" if BR2_arm || BR2_armeb + default "AArch64" if BR2_aarch64 + default "X86" if BR2_i386 || BR2_x86_64 + default "Mips" if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el + default "PowerPC" if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le + default "Sparc" if BR2_sparc + +config BR2_PACKAGE_LLVM + bool "llvm"
llvm needs at least gcc 4.8:
http://releases.llvm.org/4.0.1/docs/ReleaseNotes.html
package/llvm/Config.in line 24
Quoted 4 lines
package/llvm/Config.in new file +4
-0+ depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS + depends on BR2_INSTALL_LIBSTDCPP + depends on BR2_TOOLCHAIN_BUILDROOT_WCHAR + select BR2_PACKAGE_LIBXML2
I don't see why libxml2 is selected here. llvm doesn't check for this library.
Quoted 57 lines
package/llvm/Config.in new file +30
-0+ select BR2_PACKAGE_ZLIB + help + The LLVM Project is a collection of modular and reusable + compiler and toolchain technologies. + + http://llvm.org + +comment "llvm needs a toolchain w/ C++, wchar" + depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS + +if BR2_PACKAGE_LLVM + +config BR2_PACKAGE_LLVM_ENABLE_FFI + bool "Support libffi" + select BR2_PACKAGE_LIBFFI + help + Use libffi in the LLVM Interpreter in order to enable calling + external functions. + +config BR2_PACKAGE_LLVM_ENABLE_RTTI + bool "C++: Support RTTI" + help + Enable support for C++ Run-Time Type Information (RTTI) + +config BR2_PACKAGE_LLVM_ENABLE_EH + bool "C++: Support exception handling" + help + Enable support for C++ exception handling (try/catch) + +endifpackage/llvm/llvm.hash new file +2
-0@@ -0,0 +1,2 @@ +# Computed locally after checking the GPG signature: +sha256 8d10511df96e73b8ff9e7abbfb4d4d432edbdbe965f1f4f07afaf370b8a533be llvm-4.0.0.src.tar.xzpackage/llvm/llvm.mk new file +13
-0@@ -0,0 +1,116 @@ +################################################################################ +# +# llvm +# +################################################################################ + +LLVM_VERSION = 4.0.0 +LLVM_SITE = http://llvm.org/releases/$(LLVM_VERSION) +LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz +LLVM_LICENSE = NCSA +LLVM_LICENSE_FILES = LICENSE.TXT +LLVM_INSTALL_STAGING = YES +LLVM_DEPENDENCIES = libxml2 zlib host-python
package/llvm/llvm.mk line 23
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+ +LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH)) + +# List of build options at: +# http://llvm.org/docs/CMake.html +# +LLVM_CONF_OPTS = \ + -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME) \ + -DLLVM_HOST_TRIPLE=$(GNU_TARGET_NAME) \ + -DLLVM_TARGETS_TO_BUILD=$(LLVM_TARGET_ARCH) \
I believe we should take into account other target like AMDGPU. I've tested mesa3d with llvm shaders enabled for an HD6310 graphic card on a x86_64 target.
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+ -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH) \ + -DLLVM_OPTIMIZED_TABLEGEN=YES \ + -DLLVM_ENABLE_ZLIB=YES \ + -DLLVM_INCLUDE_TOOLS=YES \ + -DLLVM_INCLUDE_UTILS=NO \ + -DLLVM_INCLUDE_EXAMPLES=NO \ + -DLLVM_INCLUDE_TESTS=NO \ + -DLLVM_BUILD_TESTS=NO \ + -DLLVM_BUILD_RUNTIME=NO \ + -DLLVM_ENABLE_PROJECTS=''
package/llvm/llvm.mk line 43
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+ +# The Go bindings have no CMake rules at the moment, but better remove the +# check preventively. Building the Go and OCaml bindings is yet unsupported. +# +LLVM_CONF_OPTS += \ + -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \ + -DOCAMLFIND=OCAMLFIND-NOTFOUND + +# Building per-component shared libraries is NOT recommended by upstream. +# The all-in-one libLLVM-<version>.so is enabled with a different setting.
Indeed, there is a NOTE about this in docs/CMake.rst.
.. note:: BUILD_SHARED_LIBS is only recommended for use by LLVM developers.
If you want to build LLVM as a shared library, you should use the ``LLVM_BUILD_LLVM_DYLIB`` option.
package/llvm/llvm.mk line 46
Quoted 3 lines
package/llvm/llvm.mk new file +3
-0+LLVM_CONF_OPTS += \ + -DBUILD_SHARED_LIBS=NO \ + -DLLVM_BUILD_LLVM_DYLIB=$(if $(BR2_STATIC_LIBS),NO,YES)
I'm not sure we really want to support llvm for static build only.
Quoted 43 lines
package/llvm/llvm.mk new file +43
-0+ +ifeq ($(BR2_PACKAGE_LLVM_ENABLE_FFI),y) +LLVM_DEPENDENCIES += libffi +LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=YES +else +LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=NO +endif + +ifeq ($(BR2_PACKAGE_LLVM_ENABLE_RTTI),y) +LLVM_CONF_OPTS += -DLLVM_ENABLE_RTTI=YES +else +LLVM_CONF_OPTS += -DLLVM_ENABLE_RTTI=NO +endif + +ifeq ($(BR2_PACKAGE_LLVM_ENABLE_EH),y) +LLVM_CONF_OPTS += -DLLVM_ENABLE_EH=YES +else +LLVM_CONF_OPTS += -DLLVM_ENABLE_EH=NO +endif + +# LLVM expects to always be built in a separate directory. +LLVM_SUPPORTS_IN_SOURCE_BUILD = NO + +# XXX: LLVM does include some support for building native tools. This is used +# to build e.g. llvm-config, and a host-native llvm-tblgen if needed. +# Unfortunately, Buildroot is overzealous about passing the parameters +# needed for cross-building, and the CMake configuration for the native +# tools ends up using the cross-toolchain. Once "cmake-package" has +# defined LLVM_*_CMDS, this adds: +# +# - A call to CMake which resets CMAKE_{C,CXX,ASM}_COMPILER with the +# paths to the host-native ones. Note that using the *_NOCCACHE +# variables is needed, otherwise CMake will choke. +# +# - The file "BuildVariables.inc" is copied over from the cross-build +# directory to the native one. This way a new "llvm-config" which +# can run on the build host returns information about the target +# build which gets installed in the sysroot. This is done as an +# appended build command. Note that Make has to be re-invoked to +# rebuild after copying the file over. +# +# - Last but not least, "llvm-config" is copied into the sysroot with +# the target triple prefix, because packages using sane build systems
package/llvm/llvm.mk line 99
Quoted 10 lines
package/llvm/llvm.mk new file +10
-0+# will first try that. +# + +define LLVM_CONFIGURE_NATIVE_TOOLS_CMDS + cd $(LLVM_BUILDDIR)/NATIVE && \ + PATH=$(BR_PATH) $(LLVM_CONF_ENV) $(BR2_CMAKE) $(LLVM_SRCDIR) \ + -DCMAKE_C_COMPILER='$(HOSTCC_NOCCACHE)' \ + -DCMAKE_ASM_COMPILER='$(HOSTCC_NOCCACHE)' \ + -DCMAKE_CXX_COMPILER='$(HOSTCXX_NOCCACHE)' +endef
I believe we should add a host-llvm package to provide llvm-tblgen and llvm-config binaries, so we can use -DLLVM_TABLEGEN instead of theses hooks.
# Use native llvm-tblgen from host-llvm.LLVM_CONF_OPTS += -DLLVM_TABLEGEN=$(HOST_DIR)/usr/bin/llvm-tblgen
package/llvm/llvm.mk line 111
Quoted 12 lines
package/llvm/llvm.mk new file +12
-0+ +LLVM_POST_CONFIGURE_HOOKS += LLVM_CONFIGURE_NATIVE_TOOLS_CMDS + +define LLVM_REBUILD_NATIVE_LLVM_CONFIG_CMDS + cp $(LLVM_BUILDDIR)/tools/llvm-config/BuildVariables.inc $(LLVM_BUILDDIR)/NATIVE/tools/llvm-config/BuildVariables.inc + $(HOST_MAKE_ENV) $(LLVM_MAKE_ENV) $(LLVM_MAKE) $(LLVM_MAKE_OPTS) -C $(LLVM_BUILDDIR)/NATIVE llvm-config +endef + +LLVM_POST_BUILD_HOOKS += LLVM_REBUILD_NATIVE_LLVM_CONFIG_CMDS + +define LLVM_INSTALL_STAGING_NATIVE_LLVM_CONFIG_CMDS + install -Dm755 $(LLVM_BUILDDIR)/NATIVE/bin/llvm-config $(STAGING_DIR)/usr/bin/llvm-config
You should use "$(INSTALL) -D -m 0755" here.
package/llvm/llvm.mk line 116
Quoted 6 lines
package/llvm/llvm.mk new file +5
-0+endef + +LLVM_POST_INSTALL_STAGING_HOOKS += LLVM_INSTALL_STAGING_NATIVE_LLVM_CONFIG_CMDS + +$(eval $(cmake-package))
I'm working on a new patch series using llvm 4.0.1 including your changes, also I'll speak with Thomas about it during the Summer Camp.
Best regards,
Romain
PATCH 2/2 mesa3d: Allow optionally using LLVM in drivers
In reply to Adrian Perez de Castro--- package/mesa3d/Config.in | 11 +++++++++++ package/mesa3d/mesa3d.mk | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
package/mesa3d/Config.in +11 -0
@@ -44,6 +44,17 @@ config BR2_PACKAGE_MESA3D_DRIVER config BR2_PACKAGE_MESA3D_NEEDS_XA bool +config BR2_PACKAGE_MESA3D_USE_LLVM + bool "Enable LLVM usage" + default y + depends on BR2_PACKAGE_LLVM + select BR2_PACKAGE_LLVM_ENABLE_RTTI + help + Build optimized driver code which makes use of LLVM (e.g. llvmpipe). + +comment "optional llvm support depends on llvm" + depends on !BR2_PACKAGE_LLVM + comment "Gallium drivers" config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_ETNAVIV
package/mesa3d/mesa3d.mk +8 -1
@@ -57,6 +57,13 @@ MESA3D_CONF_OPTS += \ --disable-xa endif +ifeq ($(BR2_PACKAGE_MESA3D_USE_LLVM),y) +MESA3D_DEPENDENCIES += llvm +MESA3D_CONF_OPTS += --enable-llvm +else +MESA3D_CONF_OPTS += --disable-llvm +endif + # Drivers #Gallium Drivers
@@ -211,6 +218,6 @@ MESA3D_CONF_OPTS += --disable-lmsensors endif # Avoid automatic search of llvm-config -MESA3D_CONF_OPTS += --with-llvm-prefix=$(STAGING_DIR)/usr/bin +MESA3D_CONF_OPTS += --with-llvm-prefix=$(STAGING_DIR)/usr $(eval $(autotools-package))
Signature · 1 line
2.13.1
cover Adding LLVM + support for it in Mesa3D
In reply to Adrian Perez de CastroHi Adrian,
Le 16/06/2017 ? 22:41, Adrian Perez de Castro a ?crit :
Quoted 15 lines
Hello everybody,
This set of patches adds an LLVM package. For now my main motivation is to enable support for llvmpipe in Mesa3D'd swrast Gallium driver, which we I am using in am embedded ARM device which does not provide a GPU, and software rendering is enough for a small 320x240 LCD framebuffer -- so that is tested and working.
So far the built LLVM enables only the code generation backend for the CPU of the target device, which fits the Mesa3D use-case. Having a llvm package in Buildroot is interesting for many reasons, and I see this as a first step, on top of which to build on later: target packages for new programming languages using Clang+LLVM as cross-toolchain, or enabling building programs written in Rust are just a few examples.
Quoted 2 lines
I'll be happy to iterate on these patches with your feedback (keep me CC'd, please), and have them upstream.
Thanks for this work!
I also tried to add llvm and clang in Buildroot but it's not finished yet. See [1].
I successfully tested llvmpipe with a HD6310 graphic card and I also try to enable libclc support (openCL).
I'll take a look at your patches and try to improve the llvm packaging. First, I'll rebase the work on the latest llvm release 4.0.1.
Best regards,
Romain
[1] https://github.com/RomainNaour/buildroot/tree/clang-llvm-v4.0.0
Quoted 23 lines
Best regards,
--
Adri?n ?Adrian Perez de Castro (2):
llvm: new package
mesa3d: Allow optionally using LLVM in driverspackage/Config.in | 1 + ...-Clean-up-exported-values-update-for-shar.patch | 57 ++++++++ package/llvm/Config.in | 48 +++++++ package/llvm/llvm.hash | 2 + package/llvm/llvm.mk | 145 +++++++++++++++++++++ package/mesa3d/Config.in | 11 ++ package/mesa3d/mesa3d.mk | 9 +- 7 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 package/llvm/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch create mode 100644 package/llvm/Config.in create mode 100644 package/llvm/llvm.hash create mode 100644 package/llvm/llvm.mk