All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 0/6] llvm for mesa3d
@ 2018-03-09 16:49 Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 1/6] package/llvm: new host package Valentin Korenblit
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Valentin Korenblit @ 2018-03-09 16:49 UTC (permalink / raw)
  To: buildroot

Hello all,

This series provides llvm support for Mesa 3D.

With respect to the previous two versions, the biggest change is that
it now provides a full installation of host-llvm. The reason for this
is explained in PATCH 1/6.


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.

Regards,

Valent?n

Valentin Korenblit (6):
  package/llvm: new host package
  package/llvm: enable target variant
  package/llvm: enable AMDGPU
  package/mesa3d: enable llvm support
  package/llvm: enable ARM
  package/llvm: enable AArch64

 package/Config.in           |   1 +
 package/Config.in.host      |   1 +
 package/llvm/Config.in      |  31 +++++
 package/llvm/Config.in.host |   8 ++
 package/llvm/llvm.hash      |   3 +
 package/llvm/llvm.mk        | 302 ++++++++++++++++++++++++++++++++++++++++++++
 package/mesa3d/Config.in    |   8 ++
 package/mesa3d/mesa3d.mk    |  17 ++-
 8 files changed, 368 insertions(+), 3 deletions(-)
 create mode 100644 package/llvm/Config.in
 create mode 100644 package/llvm/Config.in.host
 create mode 100644 package/llvm/llvm.hash
 create mode 100644 package/llvm/llvm.mk

-- 
2.14.3

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

* [Buildroot] [PATCH v3 1/6] package/llvm: new host package
  2018-03-09 16:49 [Buildroot] [PATCH v3 0/6] llvm for mesa3d Valentin Korenblit
@ 2018-03-09 16:49 ` Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 2/6] package/llvm: enable target variant Valentin Korenblit
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Valentin Korenblit @ 2018-03-09 16:49 UTC (permalink / raw)
  To: buildroot

This patch installs LLVM on the host machine: tools and libraries.

In order to cross-compile LLVM for the target, LLVM
must be installed on the host, or at least llvm-tblgen.
This is necessary as the path to host's llvm-tblgen must
be specified when cross-compiling using the option LLVM_TABLEGEN.
Also, a version of llvm-config that can run on the host will
be required by packages that link with LLVM libraries, so we
need to generate it and install it in STAGING_DIR/usr/bin.

It is important to remark why we need llvm-config(host variant)
installed in STAGING dir. This tool is necessary to build
applications that use LLVM, as it prints the compiler flags,
linker flags and object libraries needed to link against LLVM libs.

More info: https://bugs.chromium.org/p/chromium/issues/detail?id=219369

The original idea was to compile only llvm-tblgen and llvm-config
for the host, as they are the only necessary componentes. However,
llvm-config tool does not work as expected if it is not linked with
libLLVM.so, so we must also enable LLVM_LINK_LLVM_DYLIB, what builds
LLVM as a single shared library and links LLVM tools with it.

More info: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224847
in comment #11.

If we don't build full LLVM for the host, it would be necessary to
patch configure.ac from mesa3d if we want dynamic linking, because it
uses llvm-config (host variant installed in STAGING_DIR) to get the
necessary LLVM libraries to link with, what has the following problems:

llvm-config --shared mode outputs static (even if LLVM is built as
one shared library)

llvm-config --libs outputs all LLVM tiny libs: -lLLVMLTO, -lLLVMPasses,etc.

Mesa tries to execute: llvm-config --link-shared --libs, but this outputs
llvm-config: error: libLLVM-5.0.so is missing.

Given that these problems may arise with other packages that use LLVM, it
is preferable to do a full build for the host. Also, having a complete
installation of LLVM on the host will also facilitate the integration
of Clang front-end, what is going to be added in a future patch.

As this package is intended to be used together with Mesa3D to enable llvmpipe,
we target x86 architecture. Mesa strongly recommends support for SSE2. Support
for SSE3 and SSE4.1 will yield the most efficient code.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/Config.in.host      |   1 +
 package/llvm/Config.in.host |  19 ++++
 package/llvm/llvm.hash      |   3 +
 package/llvm/llvm.mk        | 217 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 240 insertions(+)
 create mode 100644 package/llvm/Config.in.host
 create mode 100644 package/llvm/llvm.hash
 create mode 100644 package/llvm/llvm.mk

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..d9fadd5458
--- /dev/null
+++ b/package/llvm/Config.in.host
@@ -0,0 +1,19 @@
+config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	bool
+	# http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
+	# http://llvm.org/docs/GettingStarted.html#local-llvm-configuration
+	depends on BR2_HOST_GCC_AT_LEAST_4_8
+	default y if BR2_i386 || BR2_x86_64
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH
+	string
+	default "X86" if BR2_i386 || BR2_x86_64
+
+config BR2_PACKAGE_HOST_LLVM
+	bool "host llvm"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	help
+	  The LLVM Project is a collection of modular and reusable
+	  compiler and toolchain technologies.
+
+	  http://llvm.org
diff --git a/package/llvm/llvm.hash b/package/llvm/llvm.hash
new file mode 100644
index 0000000000..3e998c4328
--- /dev/null
+++ b/package/llvm/llvm.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 5fa7489fc0225b11821cab0362f5813a05f2bcf2533e8a4ea9c9c860168807b0	llvm-5.0.1.src.tar.xz
+sha256 abd4d8794808bacb1eb6924d49efafd9ab6eef88faaaeb5d3cfa13ee3670d672 LICENSE.TXT
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
new file mode 100644
index 0000000000..71fcaa2b8e
--- /dev/null
+++ b/package/llvm/llvm.mk
@@ -0,0 +1,217 @@
+################################################################################
+#
+# 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. ON for host.
+#   Utils : FileCheck, KillTheDoctor, llvm-PerfectShuffle, count, not, yaml-bench
+HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=ON
+
+# * LLVM_ENABLE_LIBEDIT: Use libedit if available
+#   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=OFF
+
+# * 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
+#   It is only recommended to be used by LLVM developers.To build LLVM as a single
+#   shared library, we should use the LLVM_BUILD_LLVM_DYLIB option.
+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.
+#   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
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
+
+# * LLVM_BUILD_TOOLS: Build the LLVM tools
+#   Enabled for host
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TOOLS=ON
+
+# * LLVM_INCLUDE_UTILS: Generate build targets for the LLVM utils.
+#   Enabled for host, disabled for the target.
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=ON
+
+# Do not build llvm runtime libraries
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
+	-DLLVM_INCLUDE_RUNTIMES=OFF
+
+# * LLVM_BUILD_EXAMPLES: Build the LLVM example programs OFF
+#   Don't build examples
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_EXAMPLES=OFF \
+	-DLLVM_INCLUDE_EXAMPLES=OFF
+
+# * LLVM_BUILD_TESTS: Build LLVM unit tests OFF
+#   Don't build tests
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TESTS=OFF
+
+# * LLVM_INCLUDE_TESTS: Generate build targets for the LLVM unit tests OFF
+#   Don't build llvm unit tests
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
+
+# * LLVM_INCLUDE_GO_TESTS: Include the Go bindings tests in test build targets OFF
+#   Don't build Go tests
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_GO_TESTS=OFF
+
+# * LLVM_BUILD_DOCS: Build the llvm documentation OFF
+#   Disable llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_DOCS=OFF
+
+# * LLVM_INCLUDE_DOCS: Generate build targets for llvm documentation OFF
+#   Don't build llvm documentation
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_DOCS=OFF
+
+# * LLVM_ENABLE_DOXYGEN: Use doxygen to generate llvm API documentation OFF
+#   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, generate code for the target
+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=ON
+
+# * Link tools with libLLVM shared library. If set to ON, it sets
+# LLVM_BUILD_LLVM_DYLIB to ON. We need to enable this option for the
+# host as llvm-config for the host will be used in STAGING_DIR by packages
+# linking against libLLVM and if this option is not selected, then llvm-config
+# does not work properly. For example, it assumes that LLVM is built statically
+# and cannot find libLLVM.so.
+HOST_LLVM_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
+
+# Install libLLVM and tools in HOST_DIR/usr
+HOST_LLVM_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr
+
+$(eval $(host-cmake-package))
-- 
2.14.3

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

* [Buildroot] [PATCH v3 2/6] package/llvm: enable target variant
  2018-03-09 16:49 [Buildroot] [PATCH v3 0/6] llvm for mesa3d Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 1/6] package/llvm: new host package Valentin Korenblit
@ 2018-03-09 16:49 ` Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 3/6] package/llvm: enable AMDGPU Valentin Korenblit
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Valentin Korenblit @ 2018-03-09 16:49 UTC (permalink / raw)
  To: buildroot

This patch installs libLLVM.so on the target.

As option LLVM_BUILD_LLVM_DYLIB is enabled, a single shared library
containing all LLVM components is built. This option is not compatible
with BUILD_SHARED_LIBS, which generates on .so per library and is only
recommended for use by LLVM developers.

Tools and utils are not built for the target. The patch aims to provide
LLVM support for other packages.

The main options needed to cross-compile LLVM are the following ones:

LLVM_TABLEGEN
CMAKE_CROSSCOMPILING
LLVM_DEFAULT_TARGET_TRIPLE
LLVM_HOST_TRIPLE
LLVM_TARGET_ARCH
LLVM_TARGETS_TO_BUILD

This patch copies llvm-config from HOST_DIR/usr/bin to STAGING_DIR/usr/in,
so that it can be used by packages that link with LLVM libraries.

Move BR2_PACKAGE_LLVM_ARCH_SUPPORTS and BR2_PACKAGE_LLVM_TARGET_ARCH
to package/llvm/Config.in for consistency with other packages.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/Config.in           |  1 +
 package/llvm/Config.in      | 20 ++++++++++++
 package/llvm/Config.in.host | 11 -------
 package/llvm/llvm.mk        | 79 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 100 insertions(+), 11 deletions(-)
 create mode 100644 package/llvm/Config.in

diff --git a/package/Config.in b/package/Config.in
index f455e74735..5e197cda23 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1528,6 +1528,7 @@ menu "Other"
 	source "package/libuv/Config.in"
 	source "package/lightning/Config.in"
 	source "package/linux-pam/Config.in"
+	source "package/llvm/Config.in"
 if BR2_PACKAGE_LINUX_PAM
 comment "linux-pam plugins"
 	source "package/libpam-radius-auth/Config.in"
diff --git a/package/llvm/Config.in b/package/llvm/Config.in
new file mode 100644
index 0000000000..52bf079acf
--- /dev/null
+++ b/package/llvm/Config.in
@@ -0,0 +1,20 @@
+config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	bool
+	# http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
+	# http://llvm.org/docs/GettingStarted.html#local-llvm-configuration
+	depends on BR2_HOST_GCC_AT_LEAST_4_8
+	default y if BR2_i386 || BR2_x86_64
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH
+	string
+	default "X86" if BR2_i386 || BR2_x86_64
+
+config BR2_PACKAGE_LLVM
+	bool "llvm"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	select BR2_PACKAGE_HOST_LLVM
+	help
+	  The LLVM Project is a collection of modular and reusable
+	  compiler and toolchain technologies.
+
+	  http://llvm.org
diff --git a/package/llvm/Config.in.host b/package/llvm/Config.in.host
index d9fadd5458..fc46535fad 100644
--- a/package/llvm/Config.in.host
+++ b/package/llvm/Config.in.host
@@ -1,14 +1,3 @@
-config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
-	bool
-	# http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
-	# http://llvm.org/docs/GettingStarted.html#local-llvm-configuration
-	depends on BR2_HOST_GCC_AT_LEAST_4_8
-	default y if BR2_i386 || BR2_x86_64
-
-config BR2_PACKAGE_LLVM_TARGET_ARCH
-	string
-	default "X86" if BR2_i386 || BR2_x86_64
-
 config BR2_PACKAGE_HOST_LLVM
 	bool "host llvm"
 	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 71fcaa2b8e..4e58c96e0f 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -10,13 +10,16 @@ LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz
 LLVM_LICENSE = NCSA
 LLVM_LICENSE_FILES = LICENSE.TXT
 LLVM_SUPPORTS_IN_SOURCE_BUILD = NO
+LLVM_INSTALL_STAGING = YES
 
 # http://llvm.org/docs/GettingStarted.html#software
 # host-python: Python interpreter 2.7 or newer is required for builds and testing.
 # host-zlib: Optional, adds compression / uncompression capabilities to selected LLVM tools.
 HOST_LLVM_DEPENDENCIES = host-python host-zlib
+LLVM_DEPENDENCIES = host-llvm zlib
 
 # Don't build clang libcxx libcxxabi lldb compiler-rt lld polly as llvm subprojects
+#This flag assumes that projects are checked out side-by-side and not nested
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_PROJECTS=""
 
 # Disable CCACHE
@@ -28,166 +31,238 @@ HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
 # * Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
 #   Ninja is not supported yet by Buildroot
 HOST_LLVM_CONF_OPTS += -G "Unix Makefiles"
+LLVM_CONF_OPTS += -G "Unix Makefiles"
+
+# Use native llvm-tblgen from host-llvm (needed for cross-compilation)
+LLVM_CONF_OPTS += -DLLVM_TABLEGEN=$(HOST_DIR)/usr/bin/llvm-tblgen
+
+# Copy llvm-config (host variant) to STAGING_DIR since llvm-config
+# provided by llvm target variant can't run on the host.
+# Also, llvm-config (host variant) returns include and lib directories
+# for the host if it's installed in host/usr/bin:
+# output/host/usr/bin/llvm-config --includedir
+# output/host/usr/include
+# When istalled in STAGING_DIR, llvm-config return include and lib
+# directories from STAGING_DIR.
+# output/staging/usr/bin/llvm-config --includedir
+# output/staging/usr/include
+define LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
+	$(INSTALL) -D -m 0755 $(HOST_DIR)/usr/bin/llvm-config \
+		$(STAGING_DIR)/usr/bin/llvm-config
+endef
+LLVM_POST_INSTALL_STAGING_HOOKS = LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
+
+# Make it explicit that we are cross-compiling
+LLVM_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
 
 # * LLVM_BUILD_UTILS: Build LLVM utility binaries. If OFF, just generate build targets.
+#   Keep llvm utility binaries for the host. llvm-tblgen is built anyway as CMakeLists.txt
+#   has add_subdirectory(utils/TableGen) unconditionally.
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=ON
+LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=OFF
 
 # * LLVM_INSTALL_UTILS: Include utility binaries in the 'install' target. ON for host.
 #   Utils : FileCheck, KillTheDoctor, llvm-PerfectShuffle, count, not, yaml-bench
 HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=ON
+LLVM_CONF_OPTS += -DLLVM_INSTALL_UTILS=OFF
 
 # * LLVM_ENABLE_LIBEDIT: Use libedit if available
 #   Disabled since no host-libedit
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_LIBEDIT=OFF
+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=OFF
+LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
 
 # * LLVM_APPEND_VC_REV "Append the version control system revision id to LLVM version OFF
 #   We build from a release archive without vcs
 HOST_LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
+LLVM_CONF_OPTS += -DLLVM_APPEND_VC_REV=OFF
 
 # * BUILD_SHARED_LIBS Build all libraries as shared libraries instead of static
 #   It is only recommended to be used by LLVM developers.To build LLVM as a single
 #   shared library, we should use the LLVM_BUILD_LLVM_DYLIB option.
 HOST_LLVM_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+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
+LLVM_CONF_OPTS += -DLLVM_ENABLE_BACKTRACES=OFF
 
 # * 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_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_CONF_OPTS += -DLLVM_ENABLE_FFI=OFF
 
 # * LLVM_ENABLE_TERMINFO: Use terminfo database if available.
 #   Disable terminfo database (needs ncurses libtinfo.so)
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_TERMINFO=OFF
+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_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_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_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_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_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
+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_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
+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_CONF_OPTS += -DLLVM_POLLY_LINK_INTO_TOOLS=ON
 
 # * LLVM_INCLUDE_TOOLS: Generate build targets for the LLVM tools ON
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
 
 # * LLVM_BUILD_TOOLS: Build the LLVM tools
 #   Enabled for host
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_TOOLS=ON
+LLVM_CONF_OPTS += -DLLVM_BUILD_TOOLS=OFF
 
 # * LLVM_INCLUDE_UTILS: Generate build targets for the LLVM utils.
 #   Enabled for host, disabled for the target.
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=ON
+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_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_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_CONF_OPTS += -DLLVM_BUILD_TESTS=OFF
 
 # * LLVM_INCLUDE_TESTS: Generate build targets for the LLVM unit tests OFF
 #   Don't build llvm unit tests
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_TESTS=OFF
 
 # * LLVM_INCLUDE_GO_TESTS: Include the Go bindings tests in test build targets OFF
 #   Don't build Go tests
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_GO_TESTS=OFF
+LLVM_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_CONF_OPTS += -DLLVM_BUILD_DOCS=OFF
 
 # * LLVM_INCLUDE_DOCS: Generate build targets for llvm documentation OFF
 #   Don't build llvm documentation
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_DOCS=OFF
+LLVM_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_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_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_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
+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_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
 
 # LLVM target to use for native code generation.
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
+LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
 
 # * LLVM_ENABLE_CXX1Y: Compile with C++1y enabled OFF
 #   Enable C++ and C++11 support if BR2_INSTALL_LIBSTDCPP=y
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
+LLVM_CONF_OPTS += -DLLVM_ENABLE_CXX1Y=$(if $(BR2_INSTALL_LIBSTDCPP),ON,OFF)
 
 # * 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_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_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_CONF_OPTS += -DLLVM_ENABLE_LLD=OFF
 
 # * LLVM_DEFAULT_TARGET_TRIPLE: by default, generate code for the target
 HOST_LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+
+# Need to specify triple for native code generation
+# This solves "No available targets are compatible for this triple" with llvmpipe
+LLVM_CONF_OPTS += -DLLVM_HOST_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.
@@ -197,11 +272,13 @@ HOST_LLVM_CONF_OPTS += \
 
 # Builds a release tablegen that gets used during the LLVM build.
 HOST_LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
+LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
 
 # * 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=ON
+LLVM_CONF_OPTS += -DLLVM_BUILD_LLVM_DYLIB=ON
 
 # * Link tools with libLLVM shared library. If set to ON, it sets
 # LLVM_BUILD_LLVM_DYLIB to ON. We need to enable this option for the
@@ -210,8 +287,10 @@ HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_LLVM_DYLIB=ON
 # does not work properly. For example, it assumes that LLVM is built statically
 # and cannot find libLLVM.so.
 HOST_LLVM_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
+LLVM_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
 
 # Install libLLVM and tools in HOST_DIR/usr
 HOST_LLVM_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr
 
+$(eval $(cmake-package))
 $(eval $(host-cmake-package))
-- 
2.14.3

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

* [Buildroot] [PATCH v3 3/6] package/llvm: enable AMDGPU
  2018-03-09 16:49 [Buildroot] [PATCH v3 0/6] llvm for mesa3d Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 1/6] package/llvm: new host package Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 2/6] package/llvm: enable target variant Valentin Korenblit
@ 2018-03-09 16:49 ` Valentin Korenblit
  2018-03-14 16:04   ` Jérôme Oufella
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 4/6] package/mesa3d: enable llvm support Valentin Korenblit
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Valentin Korenblit @ 2018-03-09 16:49 UTC (permalink / raw)
  To: buildroot

The AMDGPU backend provides ISA code generation for AMD GPU's,
starting with the R600 family up until the current GCN families.

It should not be confused with the AMDGPU Linux kernel DRM driver.

For more info: https://llvm.org/docs/AMDGPUUsage.html

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---

Tested on HD6480 using Gallium Radeon R600 driver.
 
 package/llvm/Config.in | 7 +++++++
 package/llvm/llvm.mk   | 8 +++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index 52bf079acf..d9a36223f7 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -18,3 +18,10 @@ config BR2_PACKAGE_LLVM
 	  compiler and toolchain technologies.
 
 	  http://llvm.org
+
+config BR2_PACKAGE_LLVM_AMDGPU
+	bool "AMDGPU backend"
+	depends on BR2_PACKAGE_LLVM
+	help
+	  Build AMDGPU target. Select this option if you are going
+	  to install mesa3d with llvm and use Gallium Radeon driver.
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 4e58c96e0f..b787d2da15 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -226,14 +226,20 @@ LLVM_CONF_OPTS += -DLLVM_BUILD_EXTERNAL_COMPILER_RT=OFF
 # Get target architecture
 HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
 
+# Build AMDGPU backend
+ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
+LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH);AMDGPU"
+else
 # Build backend for target architecture
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
 LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(HOST_LLVM_TARGET_ARCH)"
+endif
 
 # LLVM target to use for native code generation.
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(HOST_LLVM_TARGET_ARCH)
 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)
-- 
2.14.3

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

* [Buildroot] [PATCH v3 4/6] package/mesa3d: enable llvm support
  2018-03-09 16:49 [Buildroot] [PATCH v3 0/6] llvm for mesa3d Valentin Korenblit
                   ` (2 preceding siblings ...)
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 3/6] package/llvm: enable AMDGPU Valentin Korenblit
@ 2018-03-09 16:49 ` Valentin Korenblit
  2018-03-14 16:05   ` Jérôme Oufella
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 5/6] package/llvm: enable ARM Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 6/6] package/llvm: enable AArch64 Valentin Korenblit
  5 siblings, 1 reply; 9+ messages in thread
From: Valentin Korenblit @ 2018-03-09 16:49 UTC (permalink / raw)
  To: buildroot

This patch provides LLVM support for Mesa3D, enabling llvmpipe
software rasterizer.

It uses llvm-config (host variant) installed in STAGING_DIR/usr/bin
to get LLVM libraries. Assuming that LLVM version 5.0.1 is installed,
llvm-config --libs will output -lLLVM-5.0.

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

diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
index f141587c4d..e99e737d31 100644
--- a/package/mesa3d/Config.in
+++ b/package/mesa3d/Config.in
@@ -25,6 +25,14 @@ menuconfig BR2_PACKAGE_MESA3D
 
 if BR2_PACKAGE_MESA3D
 
+config BR2_PACKAGE_MESA3D_LLVM
+	bool "mesa3d w/ llvm"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	select BR2_PACKAGE_LLVM
+
+comment "mesa3d w/ llvm needs llvm"
+	depends on !BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+
 # inform the .mk file of gallium, dri or vulkan driver selection
 config BR2_PACKAGE_MESA3D_GALLIUM_DRIVER
 	bool
diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk
index 5f4832c0f0..03104c3c00 100644
--- a/package/mesa3d/mesa3d.mk
+++ b/package/mesa3d/mesa3d.mk
@@ -32,6 +32,20 @@ ifeq ($(BR2_SHARED_STATIC_LIBS),y)
 MESA3D_CONF_OPTS += --disable-static
 endif
 
+ifeq ($(BR2_PACKAGE_MESA3D_LLVM),y)
+MESA3D_DEPENDENCIES += host-llvm llvm
+MESA3D_CONF_OPTS += \
+	--with-llvm-prefix=$(STAGING_DIR)/usr \
+	--enable-llvm-shared-libs \
+	--enable-llvm
+else
+# Avoid automatic search of llvm-config
+MESA3D_CONF_OPTS += \
+	--with-llvm-prefix=$(STAGING_DIR)/usr \
+	--disable-llvm-shared-libs \
+	--disable-llvm
+endif
+
 # The Sourcery MIPS toolchain has a special (non-upstream) feature to
 # have "compact exception handling", which unfortunately breaks with
 # mesa3d, so we disable it here by passing -mno-compact-eh.
@@ -219,7 +233,4 @@ else
 MESA3D_CONF_OPTS += --disable-lmsensors
 endif
 
-# Avoid automatic search of llvm-config
-MESA3D_CONF_OPTS += --with-llvm-prefix=$(STAGING_DIR)/usr/bin
-
 $(eval $(autotools-package))
-- 
2.14.3

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

* [Buildroot] [PATCH v3 5/6] package/llvm: enable ARM
  2018-03-09 16:49 [Buildroot] [PATCH v3 0/6] llvm for mesa3d Valentin Korenblit
                   ` (3 preceding siblings ...)
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 4/6] package/mesa3d: enable llvm support Valentin Korenblit
@ 2018-03-09 16:49 ` Valentin Korenblit
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 6/6] package/llvm: enable AArch64 Valentin Korenblit
  5 siblings, 0 replies; 9+ messages in thread
From: Valentin Korenblit @ 2018-03-09 16:49 UTC (permalink / raw)
  To: buildroot

This patch adds LLVM support for ARM

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---

Tested llvmpipe running glmark2-es2 on Raspberry Pi 2 and 3(32-bit)

 package/llvm/Config.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index d9a36223f7..1b7d23f854 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -3,10 +3,12 @@ config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 	# http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
 	# http://llvm.org/docs/GettingStarted.html#local-llvm-configuration
 	depends on BR2_HOST_GCC_AT_LEAST_4_8
+	default y if BR2_arm || BR2_armeb
 	default y if BR2_i386 || BR2_x86_64
 
 config BR2_PACKAGE_LLVM_TARGET_ARCH
 	string
+	default "ARM" if BR2_arm || BR2_armeb
 	default "X86" if BR2_i386 || BR2_x86_64
 
 config BR2_PACKAGE_LLVM
-- 
2.14.3

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

* [Buildroot] [PATCH v3 6/6] package/llvm: enable AArch64
  2018-03-09 16:49 [Buildroot] [PATCH v3 0/6] llvm for mesa3d Valentin Korenblit
                   ` (4 preceding siblings ...)
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 5/6] package/llvm: enable ARM Valentin Korenblit
@ 2018-03-09 16:49 ` Valentin Korenblit
  5 siblings, 0 replies; 9+ messages in thread
From: Valentin Korenblit @ 2018-03-09 16:49 UTC (permalink / raw)
  To: buildroot

This patch adds LLVM support for AArch64

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---

Tested llvmpipe running glmark2-es2 on Raspberry Pi 3(64-bit)

 package/llvm/Config.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index 1b7d23f854..1865abc20d 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -3,11 +3,13 @@ config BR2_PACKAGE_LLVM_ARCH_SUPPORTS
 	# http://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
 	# http://llvm.org/docs/GettingStarted.html#local-llvm-configuration
 	depends on BR2_HOST_GCC_AT_LEAST_4_8
+	default y if BR2_aarch64
 	default y if BR2_arm || BR2_armeb
 	default y if BR2_i386 || BR2_x86_64
 
 config BR2_PACKAGE_LLVM_TARGET_ARCH
 	string
+	default "AArch64" if BR2_aarch64
 	default "ARM" if BR2_arm || BR2_armeb
 	default "X86" if BR2_i386 || BR2_x86_64
 
-- 
2.14.3

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

* [Buildroot] [PATCH v3 3/6] package/llvm: enable AMDGPU
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 3/6] package/llvm: enable AMDGPU Valentin Korenblit
@ 2018-03-14 16:04   ` Jérôme Oufella
  0 siblings, 0 replies; 9+ messages in thread
From: Jérôme Oufella @ 2018-03-14 16:04 UTC (permalink / raw)
  To: buildroot

----- On Mar 9, 2018, at 11:49 AM, Valentin Korenblit valentin.korenblit at smile.fr wrote:

> The AMDGPU backend provides ISA code generation for AMD GPU's,
> starting with the R600 family up until the current GCN families.
> 
> It should not be confused with the AMDGPU Linux kernel DRM driver.
> 
> For more info: https://llvm.org/docs/AMDGPUUsage.html
> 
> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>

Tested with an AMD Carrizo GPU, works like a charm.

Tested-by: J?r?me Oufella <jerome.oufella@savoirfairelinux.com>

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

* [Buildroot] [PATCH v3 4/6] package/mesa3d: enable llvm support
  2018-03-09 16:49 ` [Buildroot] [PATCH v3 4/6] package/mesa3d: enable llvm support Valentin Korenblit
@ 2018-03-14 16:05   ` Jérôme Oufella
  0 siblings, 0 replies; 9+ messages in thread
From: Jérôme Oufella @ 2018-03-14 16:05 UTC (permalink / raw)
  To: buildroot

> This patch provides LLVM support for Mesa3D, enabling llvmpipe
> software rasterizer.
> 
> It uses llvm-config (host variant) installed in STAGING_DIR/usr/bin
> to get LLVM libraries. Assuming that LLVM version 5.0.1 is installed,
> llvm-config --libs will output -lLLVM-5.0.
> 
> Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>

Tested-by: J?r?me Oufella <jerome.oufella@savoirfairelinux.com>

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

end of thread, other threads:[~2018-03-14 16:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 16:49 [Buildroot] [PATCH v3 0/6] llvm for mesa3d Valentin Korenblit
2018-03-09 16:49 ` [Buildroot] [PATCH v3 1/6] package/llvm: new host package Valentin Korenblit
2018-03-09 16:49 ` [Buildroot] [PATCH v3 2/6] package/llvm: enable target variant Valentin Korenblit
2018-03-09 16:49 ` [Buildroot] [PATCH v3 3/6] package/llvm: enable AMDGPU Valentin Korenblit
2018-03-14 16:04   ` Jérôme Oufella
2018-03-09 16:49 ` [Buildroot] [PATCH v3 4/6] package/mesa3d: enable llvm support Valentin Korenblit
2018-03-14 16:05   ` Jérôme Oufella
2018-03-09 16:49 ` [Buildroot] [PATCH v3 5/6] package/llvm: enable ARM Valentin Korenblit
2018-03-09 16:49 ` [Buildroot] [PATCH v3 6/6] package/llvm: enable AArch64 Valentin Korenblit

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