[v2,1/3] package/llvm: new host package

Message ID 20180219171805.13769-2-valentin.korenblit@smile.fr
State Superseded
Headers show
Series
  • llvm for mesa3d
Related show

Commit Message

Valentin Korenblit Feb. 19, 2018, 5:18 p.m.
From: Romain Naour <romain.naour@gmail.com>

This patch installs only the necessary components of LLVM
for the host that are needed to cross-compile LLVM for
the target. The path to host's llvm-tblgen must be specified
when cross-compiling using option -DLLVM_TABLEGEN.

Most build options are set to OFF in order to reduce the
build time.

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/Config.in.host      |   1 +
 package/llvm/Config.in.host |   8 ++
 package/llvm/llvm.hash      |   2 +
 package/llvm/llvm.mk        | 282 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 293 insertions(+)
 create mode 100644 package/llvm/Config.in.host
 create mode 100644 package/llvm/llvm.hash
 create mode 100644 package/llvm/llvm.mk

Comments

Thomas Petazzoni Feb. 19, 2018, 8:22 p.m. | #1
Hello,

I have by far not reviewed everything, but noticed one problem.

On Mon, 19 Feb 2018 18:18:03 +0100, Valentin Korenblit wrote:

> +# Get target architecture
> +HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))

BR2_PACKAGE_LLVM_TARGET_ARCH does not exist, it is created by PATCH
2/3. This is not good, as it breaks bisectability.

Basically, your series should work even if we apply only PATCH 1/3. Or
if we apply only PATCH 1/3 and 2/3, etc.

So using in PATCH 1/3 something that is introduced in PATCH 2/3 is not
good.

Best regards,

Thomas
Valentin Korenblit Feb. 20, 2018, 10:15 a.m. | #2
Hello,

Thanks Thomas for the review. The problem is fixed for next version but
I will wait for some more tests before sending it.

I would appreciate if anyone interested in this package can test/review
it(applying the 3 patches at once) and give me some feedback following
the guidelines in:

https://buildroot.org/downloads/manual/manual.html#_reviewing_and_testing_patches

Thanks in advance,

Valentín


On 19/02/2018 21:22, Thomas Petazzoni wrote:
> Hello,
>
> I have by far not reviewed everything, but noticed one problem.
>
> On Mon, 19 Feb 2018 18:18:03 +0100, Valentin Korenblit wrote:
>
>> +# Get target architecture
>> +HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
> BR2_PACKAGE_LLVM_TARGET_ARCH does not exist, it is created by PATCH
> 2/3. This is not good, as it breaks bisectability.
>
> Basically, your series should work even if we apply only PATCH 1/3. Or
> if we apply only PATCH 1/3 and 2/3, etc.
>
> So using in PATCH 1/3 something that is introduced in PATCH 2/3 is not
> good.
>
> Best regards,
>
> Thomas
Nimai Mahajan Feb. 20, 2018, 12:13 p.m. | #3
On Tue, Feb 20, 2018, 5:15 AM Valentin Korenblit <
valentin.korenblit@smile.fr> wrote:

> Hello,
>
> Thanks Thomas for the review. The problem is fixed for next version but
> I will wait for some more tests before sending it.
>

I can test this today at work, but I am using the same target architecture
as you, x86. We use this sw rasturizer with a Qt5 app on an old atom
platform (that has no modern kernel support for hw accelerated graphics).

I'd love to see it in 2018.02 if possible as that is BRs next LTS release
but Thomas and the team may not be adding anymore packages there as they
are already cutting RCs. For older platforms though, llvmpipe is pretty big
and should be in there. The difference between that and older sw renderers
like softpipe is tremendous.

>
> I would appreciate if anyone interested in this package can test/review
> it(applying the 3 patches at once) and give me some feedback following
> the guidelines in:
>
>
> https://buildroot.org/downloads/manual/manual.html#_reviewing_and_testing_patches
>
> Thanks in advance,
>
> Valentín
>
>
> On 19/02/2018 21:22, Thomas Petazzoni wrote:
> > Hello,
> >
> > I have by far not reviewed everything, but noticed one problem.
> >
> > On Mon, 19 Feb 2018 18:18:03 +0100, Valentin Korenblit wrote:
> >
> >> +# Get target architecture
> >> +HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
> > BR2_PACKAGE_LLVM_TARGET_ARCH does not exist, it is created by PATCH
> > 2/3. This is not good, as it breaks bisectability.
> >
> > Basically, your series should work even if we apply only PATCH 1/3. Or
> > if we apply only PATCH 1/3 and 2/3, etc.
> >
> > So using in PATCH 1/3 something that is introduced in PATCH 2/3 is not
> > good.
> >
> > Best regards,
> >
> > Thomas
>
>
<br><br><div class="gmail_quote"><div dir="ltr">On Tue, Feb 20, 2018, 5:15 AM Valentin Korenblit &lt;<a href="mailto:valentin.korenblit@smile.fr">valentin.korenblit@smile.fr</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Thanks Thomas for the review. The problem is fixed for next version but<br>
I will wait for some more tests before sending it.<br></blockquote></div><div><br></div><div>I can test this today at work, but I am using the same target architecture as you, x86. We use this sw rasturizer with a Qt5 app on an old atom platform (that has no modern kernel support for hw accelerated graphics).</div><div><br></div><div>I&#39;d love to see it in 2018.02 if possible as that is BRs next LTS release but Thomas and the team may not be adding anymore packages there as they are already cutting RCs. For older platforms though, llvmpipe is pretty big and should be in there. The difference between that and older sw renderers like softpipe is tremendous.</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I would appreciate if anyone interested in this package can test/review<br>
it(applying the 3 patches at once) and give me some feedback following<br>
the guidelines in:<br>
<br>
<a href="https://buildroot.org/downloads/manual/manual.html#_reviewing_and_testing_patches" rel="noreferrer" target="_blank">https://buildroot.org/downloads/manual/manual.html#_reviewing_and_testing_patches</a><br>
<br>
Thanks in advance,<br>
<br>
Valentín<br>
<br>
<br>
On 19/02/2018 21:22, Thomas Petazzoni wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I have by far not reviewed everything, but noticed one problem.<br>
&gt;<br>
&gt; On Mon, 19 Feb 2018 18:18:03 +0100, Valentin Korenblit wrote:<br>
&gt;<br>
&gt;&gt; +# Get target architecture<br>
&gt;&gt; +HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))<br>
&gt; BR2_PACKAGE_LLVM_TARGET_ARCH does not exist, it is created by PATCH<br>
&gt; 2/3. This is not good, as it breaks bisectability.<br>
&gt;<br>
&gt; Basically, your series should work even if we apply only PATCH 1/3. Or<br>
&gt; if we apply only PATCH 1/3 and 2/3, etc.<br>
&gt;<br>
&gt; So using in PATCH 1/3 something that is introduced in PATCH 2/3 is not<br>
&gt; good.<br>
&gt;<br>
&gt; Best regards,<br>
&gt;<br>
&gt; Thomas<br>
<br>
</blockquote></div>
Thomas Petazzoni Feb. 20, 2018, 12:41 p.m. | #4
Hello,

On Tue, 20 Feb 2018 12:13:54 +0000, Nimai Mahajan wrote:

> I can test this today at work, but I am using the same target architecture
> as you, x86. We use this sw rasturizer with a Qt5 app on an old atom
> platform (that has no modern kernel support for hw accelerated graphics).
> 
> I'd love to see it in 2018.02 if possible as that is BRs next LTS release
> but Thomas and the team may not be adding anymore packages there as they
> are already cutting RCs. For older platforms though, llvmpipe is pretty big
> and should be in there. The difference between that and older sw renderers
> like softpipe is tremendous.

I do realize the value of llvmpipe, and what it brings compared to
softpipe. However, we're already past 2018.02-rc2, and 2018.02 being a
LTS release, we really want to avoid introducing major changes that
close to the release.

Therefore I don't think llvm and llvmpipe support will make it to
2018.02. However, it should hopefully be in 2018.05, and you can always
backport the relevant patches if you want to stick to 2018.02 to
benefit from security updates.

Best regards,

Thomas Petazzoni
Nimai Mahajan Feb. 20, 2018, 5:41 p.m. | #5
On Tue, Feb 20, 2018 at 7:41 AM, Thomas Petazzoni <
thomas.petazzoni@bootlin.com> wrote:

> Hello,
>
> On Tue, 20 Feb 2018 12:13:54 +0000, Nimai Mahajan wrote:
>
> > I can test this today at work, but I am using the same target
> architecture
> > as you, x86. We use this sw rasturizer with a Qt5 app on an old atom
> > platform (that has no modern kernel support for hw accelerated graphics).
>

Tested! Works just fine on x86. Pulled in BR master, applied the 3 patches
successfully, LLVM builds, mesa3d builds and links against it properly.


> >
> > I'd love to see it in 2018.02 if possible as that is BRs next LTS release
> > but Thomas and the team may not be adding anymore packages there as they
> > are already cutting RCs. For older platforms though, llvmpipe is pretty
> big
> > and should be in there. The difference between that and older sw
> renderers
> > like softpipe is tremendous.
>
> I do realize the value of llvmpipe, and what it brings compared to
> softpipe. However, we're already past 2018.02-rc2, and 2018.02 being a
> LTS release, we really want to avoid introducing major changes that
> close to the release.
>

Understood, no problem. Thanks for the consideration.

>
> Therefore I don't think llvm and llvmpipe support will make it to
> 2018.02. However, it should hopefully be in 2018.05, and you can always
> backport the relevant patches if you want to stick to 2018.02 to
> benefit from security updates.
>

Yes, will do that. It's just a pain in the build process to pre-patch a
tagged release rather than just having it committed upstream. But I
definitely understand.

>
> Best regards,
>
> Thomas Petazzoni
> --
> Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
> Embedded Linux and Kernel engineering
> http://bootlin.com
>
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 20, 2018 at 7:41 AM, Thomas Petazzoni <span dir="ltr">&lt;<a href="mailto:thomas.petazzoni@bootlin.com" target="_blank">thomas.petazzoni@bootlin.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<span><br>
On Tue, 20 Feb 2018 12:13:54 +0000, Nimai Mahajan wrote:<br>
<br>
&gt; I can test this today at work, but I am using the same target architecture<br>
&gt; as you, x86. We use this sw rasturizer with a Qt5 app on an old atom<br>
&gt; platform (that has no modern kernel support for hw accelerated graphics).<br></span></blockquote><div><br></div><div>Tested! Works just fine on x86. Pulled in BR master, applied the 3 patches successfully, LLVM builds, mesa3d builds and links against it properly.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
&gt;<br>
&gt; I&#39;d love to see it in 2018.02 if possible as that is BRs next LTS release<br>
&gt; but Thomas and the team may not be adding anymore packages there as they<br>
&gt; are already cutting RCs. For older platforms though, llvmpipe is pretty big<br>
&gt; and should be in there. The difference between that and older sw renderers<br>
&gt; like softpipe is tremendous.<br>
<br>
</span>I do realize the value of llvmpipe, and what it brings compared to<br>
softpipe. However, we&#39;re already past 2018.02-rc2, and 2018.02 being a<br>
LTS release, we really want to avoid introducing major changes that<br>
close to the release.<br></blockquote><div><br></div><div>Understood, no problem. Thanks for the consideration. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Therefore I don&#39;t think llvm and llvmpipe support will make it to<br>
2018.02. However, it should hopefully be in 2018.05, and you can always<br>
backport the relevant patches if you want to stick to 2018.02 to<br>
benefit from security updates.<br></blockquote><div><br></div><div>Yes, will do that. It&#39;s just a pain in the build process to pre-patch a tagged release rather than just having it committed upstream. But I definitely understand.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Best regards,<br>
<br>
Thomas Petazzoni<br>
<div class="m_-8842626065995368292HOEnZb"><div class="m_-8842626065995368292h5">--<br>
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)<br>
Embedded Linux and Kernel engineering<br>
<a href="http://bootlin.com" rel="noreferrer" target="_blank">http://bootlin.com</a><br>
</div></div></blockquote></div><br></div></div>
Adrian Perez de Castro Feb. 20, 2018, 5:51 p.m. | #6
On Tue, 20 Feb 2018 12:41:04 -0500, Nimai Mahajan <nimaim@gmail.com> wrote:
> On Tue, Feb 20, 2018 at 7:41 AM, Thomas Petazzoni <
> thomas.petazzoni@bootlin.com> wrote:
> 
> > Hello,
> >
> > On Tue, 20 Feb 2018 12:13:54 +0000, Nimai Mahajan wrote:
> >
> > > I can test this today at work, but I am using the same target
> > architecture
> > > as you, x86. We use this sw rasturizer with a Qt5 app on an old atom
> > > platform (that has no modern kernel support for hw accelerated graphics).
> >
> 
> Tested! Works just fine on x86. Pulled in BR master, applied the 3 patches
> successfully, LLVM builds, mesa3d builds and links against it properly.

FWIW, in cases like this could you please add a “Tested-by” tag to your reply,
so the tags get picked by the review system (thanks!).

For more info on this, there's a section in the manual about tags used by
the Buildroot project:

  https://buildroot.org/downloads/manual/manual.html#_reviewing_and_testing_patches
 
Cheers,

--
 Adrián 🎩

Patch

diff --git a/package/Config.in.host b/package/Config.in.host
index 199a8e9856..9a6227174b 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -27,6 +27,7 @@  menu "Host utilities"
 	source "package/imx-usb-loader/Config.in.host"
 	source "package/jq/Config.in.host"
 	source "package/jsmin/Config.in.host"
+	source "package/llvm/Config.in.host"
 	source "package/lpc3250loader/Config.in.host"
 	source "package/lttng-babeltrace/Config.in.host"
 	source "package/mfgtools/Config.in.host"
diff --git a/package/llvm/Config.in.host b/package/llvm/Config.in.host
new file mode 100644
index 0000000000..fc46535fad
--- /dev/null
+++ b/package/llvm/Config.in.host
@@ -0,0 +1,8 @@ 
+config BR2_PACKAGE_HOST_LLVM
+	bool "host llvm"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	help
+	  The LLVM Project is a collection of modular and reusable
+	  compiler and toolchain technologies.
+
+	  http://llvm.org
diff --git a/package/llvm/llvm.hash b/package/llvm/llvm.hash
new file mode 100644
index 0000000000..2d38445673
--- /dev/null
+++ b/package/llvm/llvm.hash
@@ -0,0 +1,2 @@ 
+# locally calculated
+sha256	5fa7489fc0225b11821cab0362f5813a05f2bcf2533e8a4ea9c9c860168807b0	llvm-5.0.1.src.tar.xz
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
new file mode 100644
index 0000000000..334a934722
--- /dev/null
+++ b/package/llvm/llvm.mk
@@ -0,0 +1,282 @@ 
+################################################################################
+#
+# llvm
+#
+################################################################################
+
+LLVM_VERSION = 5.0.1
+LLVM_SITE = http://llvm.org/releases/$(LLVM_VERSION)
+LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz
+LLVM_LICENSE = NCSA
+LLVM_LICENSE_FILES = LICENSE.TXT
+LLVM_SUPPORTS_IN_SOURCE_BUILD = NO
+
+# http://llvm.org/docs/GettingStarted.html#software
+# host-python: Python interpreter 2.7 or newer is required for builds and testing.
+# host-zlib: Optional, adds compression / uncompression capabilities to selected LLVM tools.
+HOST_LLVM_DEPENDENCIES = host-python host-zlib
+
+# Don't build clang libcxx libcxxabi lldb compiler-rt lld polly as llvm subprojects
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PROJECTS=""
+
+# Disable CCACHE
+HOST_LLVM_CONF_OPTS += -DLLVM_CCACHE_BUILD=OFF
+
+# Disable Build GlobalIsel
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
+
+# Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
+# Ninja is not supported yet by Buildroot
+HOST_LLVM_CONF_OPTS += -G "Unix Makefiles"
+
+# * LLVM_BUILD_UTILS: Build LLVM utility binaries. If OFF, just generate build targets.
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=ON
+
+# * LLVM_INSTALL_UTILS: Include utility binaries in the 'install' target. OFF
+#   Utils : FileCheck, KillTheDoctor, llvm-PerfectShuffle, count, not, yaml-bench
+HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=OFF
+
+# * LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING:
+#   Disable abi-breaking checks mismatch detection at link-tim
+#   Keep it enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=OFF
+
+# * LLVM_ENABLE_LIBEDIT: Use libedit if available
+#   Disabled since no host-libedit
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
+
+# * LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target. OFF
+#   We also want llvm libraries and modules.
+HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
+
+# * LLVM_APPEND_VC_REV "Append the version control system revision id to LLVM version OFF
+#   We build from a release archive without vcs
+HOST_LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
+
+# * BUILD_SHARED_LIBS Build all libraries as shared libraries instead of static ON
+#   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.
+HOST_LLVM_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+
+# * LLVM_ENABLE_BACKTRACES: Enable embedding backtraces on crash ON
+#   Use backtraces on crash to report toolchain issue.
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_BACKTRACES=ON
+
+# * ENABLE_CRASH_OVERRIDES: Enable crash overrides ON
+#   Keep the possibility to install or overrides signal handlers
+HOST_LLVM_CONF_OPTS += -DENABLE_CRASH_OVERRIDES=ON
+
+# * LLVM_ENABLE_FFI: Use libffi to call external functions from the interpreter OFF
+#   Keep ffi disabled for now
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_FFI=OFF
+
+# * LLVM_ENABLE_TERMINFO: Use terminfo database if available. ON
+#   Disable terminfo database (needs ncurses libtinfo.so)
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_TERMINFO=OFF
+
+# * LLVM_ENABLE_THREADS: Use threads if available ON
+#   Keep threads enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_THREADS=ON
+
+# * LLVM_ENABLE_ZLIB: Use zlib for compression/decompression if available ON
+#   Keep zlib support enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_ZLIB=ON
+
+# * LLVM_ENABLE_PIC: Build Position-Independent Code ON
+#   We don't use llvm for static only build, so enable PIC
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PIC=ON
+
+# * LLVM_ENABLE_WARNINGS: Enable compiler warnings ON
+#   Keep compiler warning enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WARNINGS=ON
+
+# * LLVM_ENABLE_PEDANTIC: Compile with pedantic enabled ON
+#   Keep pedantic enabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PEDANTIC=ON
+
+# * LLVM_ENABLE_WERROR: Fail and stop if a warning is triggered OFF
+#   Keep Werror disabled
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_WERROR=OFF
+
+# * CMAKE_BUILD_TYPE: Set build type Debug, Release, RelWithDebInfo, and MinSizeRel.
+#   Default is Debug. Use the Release build which requires considerably less space.
+HOST_LLVM_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+# * LLVM_POLLY_BUILD: Build LLVM with Polly ON
+#   Keep it enabled, if POLLY is not in-tree it will not be built
+HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_BUILD=ON
+
+# * LINK_POLLY_INTO_TOOLS: Static link Polly into tools ON
+HOST_LLVM_CONF_OPTS += -DLLVM_POLLY_LINK_INTO_TOOLS=ON
+
+# * LLVM_INCLUDE_TOOLS: Generate build targets for the LLVM tools ON
+#   Build llvm tools for the target
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
+
+# * LLVM_BUILD_TOOLS: Build the LLVM tools for the host ON
+#   Build llvm tools for the host
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TOOLS=ON
+
+# * LLVM_INCLUDE_UTILS: Generate build targets for the LLVM utils default ON
+#   Disabled, since we don't install them to the target.
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=OFF
+
+# Do not build llvm runtime libraries
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
+	-DLLVM_INCLUDE_RUNTIMES=OFF
+
+# * LLVM_BUILD_EXAMPLES: Build the LLVM example programs OFF
+#   Don't build examples
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXAMPLES=OFF \
+	-DLLVM_INCLUDE_EXAMPLES=OFF
+
+# * LLVM_BUILD_TESTS: Build LLVM unit tests OFF
+#   Don't build tests
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TESTS=OFF
+
+# * LLVM_INCLUDE_TESTS: Generate build targets for the LLVM unit tests ON
+#   Don't build llvm unit tests
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
+
+# * LLVM_INCLUDE_GO_TESTS: Include the Go bindings tests in test build targets ON
+#   Don't build Go tests
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_GO_TESTS=OFF
+
+# * LLVM_BUILD_DOCS: Build the llvm documentation OFF
+#   Disable llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_DOCS=OFF
+
+# * LLVM_INCLUDE_DOCS: Generate build targets for llvm documentation ON
+#   Don't build llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_DOCS=OFF
+
+# * LLVM_ENABLE_DOXYGEN: Use doxygen to generate llvm API documentation OFF
+#   Don't build llvm API documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_DOXYGEN=OFF
+
+# * LLVM_ENABLE_SPHINX: Use Sphinx to generate llvm documentation OFF
+#   Don't build llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_SPHINX=OFF
+
+# * LLVM_ENABLE_OCAMLDOC: Use OCaml bindings documentation OFF
+#   Don't build llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_OCAMLDOC=OFF
+
+# * LLVM_BUILD_EXTERNAL_COMPILER_RT: Build compiler-rt as an external project OFF
+#   Keep rt compiler disabled
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
+
+# Get target architecture
+HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
+
+# Build backend for target architecture
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
+
+# LLVM target to use for native code generation.
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
+
+# * LLVM_ENABLE_CXX1Y: Compile with C++1y enabled OFF
+#   Enable C++ and C++11 support if BR2_INSTALL_LIBSTDCPP=y
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
+
+# * LLVM_ENABLE_MODULES: Compile with C++ modules enabled OFF
+#   Disabled, requires sys/ndir.h header
+#   Disable debug in module
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_MODULES=OFF \
+	-DLLVM_ENABLE_MODULE_DEBUGGING=OFF
+
+# * LLVM_ENABLE_LIBCXX: Use libc++ if available OFF
+#   Use -stdlib=libc++ compiler flag, use libc++ as C++ standard library
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBCXX=OFF
+
+# * LLVM_ENABLE_LLD: Use lld as C and C++ linker. OFF
+HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LLD=OFF
+
+# * LLVM_DEFAULT_TARGET_TRIPLE: By default, we target the host, but this can be overridden at CMake
+# invocation time.
+HOST_LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+
+# The Go bindings have no CMake rules at the moment, but better remove the
+# check preventively. Building the Go and OCaml bindings is yet unsupported.
+HOST_LLVM_CONF_OPTS += \
+	-DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \
+	-DOCAMLFIND=OCAMLFIND-NOTFOUND
+
+# Builds a release tablegen that gets used during the LLVM build.
+HOST_LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
+
+# * Generate libLLVM.so. This library contains a default set of LLVM components
+# that can be overridden with "LLVM_DYLIB_COMPONENTS". The default contains
+# most of LLVM and is defined in "tools/llvm-shlib/CMakelists.txt".
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_LLVM_DYLIB=OFF
+
+define HOST_LLVM_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 $(HOST_LLVM_BUILDDIR)/bin/llvm-tblgen $(HOST_DIR)/bin/llvm-tblgen
+	$(INSTALL) -D -m 0755 $(HOST_LLVM_BUILDDIR)/bin/llvm-config $(HOST_DIR)/bin/llvm-config
+endef
+
+# Avoid building host tools, except llvm-config
+HOST_LLVM_CONF_OPTS += \
+	-DLLVM_TOOL_BUGPOINT_BUILD=OFF \
+	-DLLVM_TOOL_BUGPOINT_PASSES_BUILD=OFF \
+	-DLLVM_TOOL_DSYMUTIL_BUILD=OFF \
+	-DLLVM_TOOL_GOLD_BUILD=OFF \
+	-DLLVM_TOOL_LLC_BUILD=OFF \
+	-DLLVM_TOOL_LLI_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_AR_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_AS_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_AS_FUZZER_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_BCANALYZER_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_CAT_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_CONFIG_BUILD=ON  \
+	-DLLVM_TOOL_LLVM_COV_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_C_TEST_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_CVTRES_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_CXXDUMP_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_CXXFILT_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_DIFF_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_DIS_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_DWARFDUMP_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_DWP_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_EXTRACT_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_GO_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_JITLISTENER_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_LINK_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_LTO2_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_LTO_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MC_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MC_FUZZER_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MCMARKUP_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MODEXTRACT_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MT_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_NM_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_OBJDUMP_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_OPT_REPORT_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_PDBDUMP_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_PDBUTIL_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_PROFDATA_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_READOBJ_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_RTDYLD_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_SHLIB_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_SIZE_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_SPLIT_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_STRESS_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_STRINGS_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_SYMBOLIZER_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_XRAY_BUILD=OFF \
+	-DLLVM_TOOL_LTO_BUILD=OFF  \
+	-DLLVM_TOOL_LTO_BUILD=OFF  \
+	-DLLVM_TOOL_MSBUILD_BUILD=OFF \
+	-DLLVM_TOOL_OBJ2YAML_BUILD=OFF \
+	-DLLVM_TOOL_OPT_BUILD=OFF  \
+	-DLLVM_TOOL_SANCOV_BUILD=OFF \
+	-DLLVM_TOOL_SANSTATS_BUILD=OFF \
+	-DLLVM_TOOL_VERIFY_USELISTORDER_BUILD=OFF \
+	-DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF \
+	-DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
+
+# Make only llvm-config and llvm-tblgen for host to reduce build time
+HOST_LLVM_MAKE_OPTS = llvm-tblgen llvm-config
+
+$(eval $(host-cmake-package))