Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/4]  llvm for mesa3d
@ 2018-02-16  8:36 Valentin Korenblit
  2018-02-16  8:36 ` [Buildroot] [PATCH 1/4] package/llvm: new host package Valentin Korenblit
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Valentin Korenblit @ 2018-02-16  8:36 UTC (permalink / raw)
  To: buildroot

Hello all,

This series provides LLVM support for Mesa3d, enabling
llvmpipe software rasterizer.

It must be considered that it does not provide a full LLVM
installation for the host, only the necessary components to
cross-compile LLVM for the target. It will install all target
components as libLLVM.so.

Regards,

Valent?n

Romain Naour (4):
  package/llvm: new host package
  package/llvm: enable target variant
  package/llvm: add AMDGPU support
  package/mesa3d: enable llvm support

 package/Config.in           |   1 +
 package/Config.in.host      |   1 +
 package/llvm/Config.in      |  38 +++++
 package/llvm/Config.in.host |   8 +
 package/llvm/llvm.hash      |   2 +
 package/llvm/llvm.mk        | 356 ++++++++++++++++++++++++++++++++++++++++++++
 package/mesa3d/Config.in    |   8 +
 package/mesa3d/mesa3d.mk    |  18 ++-
 8 files changed, 429 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] 10+ messages in thread

* [Buildroot] [PATCH 1/4] package/llvm: new host package
  2018-02-16  8:36 [Buildroot] [PATCH 0/4] llvm for mesa3d Valentin Korenblit
@ 2018-02-16  8:36 ` Valentin Korenblit
  2018-02-16  8:36 ` [Buildroot] [PATCH 2/4] package/llvm: enable target variant Valentin Korenblit
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Valentin Korenblit @ 2018-02-16  8:36 UTC (permalink / raw)
  To: buildroot

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 |  29 +++++
 package/llvm/llvm.hash      |   2 +
 package/llvm/llvm.mk        | 284 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 316 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..454cf10947
--- /dev/null
+++ b/package/llvm/Config.in.host
@@ -0,0 +1,29 @@
+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_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
+	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_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..ecd7cb9b71
--- /dev/null
+++ b/package/llvm/llvm.mk
@@ -0,0 +1,284 @@
+################################################################################
+#
+# 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
+# host-libtool: Shared library manager
+
+# 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
+
+# default ON
+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.
+#   Keep llvm utility binaries.
+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_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 ON
+#   Disabled, since we don't install them to the target.
+HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=OFF
+
+#   Build llvm runtime livraries for the host, not for the target.
+HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
+-DLLVM_INCLUDE_RUNTIMES=OFF
+
+HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
+
+# * 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
+
+HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
+ifeq ($(BR2_PACKAGE_LLVM_TARGET_ARCH_AMDGPU),y)
+HOST_LLVM_TARGET_TO_BUILD = "$(HOST_LLVM_TARGET_ARCH);AMDGPU"
+endif
+
+HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD=$(HOST_LLVM_TARGET_TO_BUILD)
+
+# 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_GOLD_BUILD=OFF \
+	-DLLVM_TOOL_LLI_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_AR_BUILD=OFF \
+ 	-DLLVM_TOOL_LLC_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_BCANALYZER_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_CXXDUMP_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_CXXFILT_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_COV_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_CONFIG_BUILD=ON  \
+	-DLLVM_TOOL_LLVM_C_TEST_BUILD=OFF  \
+	-DLLVM_TOOL_LTO_BUILD=OFF  \
+	-DLLVM_TOOL_LTO_BUILD=OFF  \
+	-DLLVM_TOOL_OPT_BUILD=OFF  \
+	-DLLVM_TOOL_DSYMUTIL_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_AS_BUILD=OFF  \
+	-DLLVM_TOOL_LLVM_AS_FUZZER_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_CAT_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_CVTRES_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_DIFF_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_DIS_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_DWP_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_DWARFDUMP_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_LTO_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_LTO2_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MCMARKUP_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MC_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_MC_FUZZER_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_MSBUILD_BUILD=OFF \
+	-DLLVM_TOOL_OBJ2YAML_BUILD=OFF \
+	-DLLVM_TOOL_VERIFY_USELISTORDER_BUILD=OFF \
+	-DLLVM_TOOL_SANCOV_BUILD=OFF \
+	-DLLVM_TOOL_SANSTATS_BUILD=OFF \
+	-DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF \
+	-DLLVM_TOOL_LLVM_XRAY_BUILD=OFF \
+	-DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
+
+$(eval $(host-cmake-package))
-- 
2.14.3

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

* [Buildroot] [PATCH 2/4] package/llvm: enable target variant
  2018-02-16  8:36 [Buildroot] [PATCH 0/4] llvm for mesa3d Valentin Korenblit
  2018-02-16  8:36 ` [Buildroot] [PATCH 1/4] package/llvm: new host package Valentin Korenblit
@ 2018-02-16  8:36 ` Valentin Korenblit
  2018-02-16  8:36 ` [Buildroot] [PATCH 3/4] package/llvm: add AMDGPU support Valentin Korenblit
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Valentin Korenblit @ 2018-02-16  8:36 UTC (permalink / raw)
  To: buildroot

From: Romain Naour <romain.naour@gmail.com>

This patch installs LLVM libraries for the target (libLLVM*).

Option -DLLVM_BUILD_LLVM_DYLIB=ON allows having all LLVM
components in a single shared library. This is used by
mesa3d to enable llvmpipe software rasterizer.

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

Define target triple with GNU_TARGET_NAME.

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/Config.in           |  1 +
 package/llvm/Config.in      | 29 ++++++++++++++
 package/llvm/Config.in.host | 21 ----------
 package/llvm/llvm.mk        | 94 +++++++++++++++++++++++++++++++++++++++------
 4 files changed, 113 insertions(+), 32 deletions(-)
 create mode 100644 package/llvm/Config.in

diff --git a/package/Config.in b/package/Config.in
index 9cd5d9c087..e570662985 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1520,6 +1520,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..84dde8d5ff
--- /dev/null
+++ b/package/llvm/Config.in
@@ -0,0 +1,29 @@
+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_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
+	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"
+	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/Config.in.host b/package/llvm/Config.in.host
index 454cf10947..fc46535fad 100644
--- a/package/llvm/Config.in.host
+++ b/package/llvm/Config.in.host
@@ -1,24 +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_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
-	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_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 ecd7cb9b71..2222cb096b 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -10,68 +10,108 @@ 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
-# host-libtool: Shared library manager
+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
 HOST_LLVM_CONF_OPTS += -DLLVM_CCACHE_BUILD=OFF
 
-# default ON
+# Disable Build GlobalIsel
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_GLOBAL_ISEL=OFF
 
+# 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) return 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)/bin/llvm-config \
+		$(STAGING_DIR)/usr/bin/llvm-config
+endef
+LLVM_POST_INSTALL_STAGING_HOOKS = LLVM_COPY_LLVM_CONFIG_TO_STAGING_DIR
+
 # 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"
+
+# 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.
+#   Keep llvm utility binaries for the host.
+#   For the target, we should disable it but setting LLVM_BUILD_UTILS=OFF and
+#   LLVM_INSTALL_UTILS=OFF together break the install step due to undefined cmake
+#   behavior: "Target "llvm-tblgen" has EXCLUDE_FROM_ALL set and will not be built by
+#   default but an install rule has been provided for it.  CMake does not define behavior
+#   for this case."
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_UTILS=ON
+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_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_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_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_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 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_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. ON
 #   Disable terminfo database (needs ncurses libtinfo.so)
@@ -81,127 +121,157 @@ 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
+# if Clang is used as cross-compiler, there is a problem with the LLVM argument
+# backend => disable 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
+#   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
 #   Build llvm tools for the target
 HOST_LLVM_CONF_OPTS += -DLLVM_INCLUDE_TOOLS=ON
+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_CONF_OPTS += -DLLVM_BUILD_TOOLS=OFF
 
-# * LLVM_INCLUDE_UTILS: Generate build targets for the LLVM utils 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
+LLVM_CONF_OPTS += -DLLVM_INCLUDE_UTILS=OFF
 
-#   Build llvm runtime livraries for the host, not for the target.
+#   Do not build llvm runtime libraries
 HOST_LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=OFF \
 -DLLVM_INCLUDE_RUNTIMES=OFF
-
-HOST_LLVM_CONF_OPTS += -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
+LLVM_CONF_OPTS += -DLLVM_BUILD_RUNTIME=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 ON
 #   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 ON
 #   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 ON
 #   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
 
 HOST_LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
+
 ifeq ($(BR2_PACKAGE_LLVM_TARGET_ARCH_AMDGPU),y)
 HOST_LLVM_TARGET_TO_BUILD = "$(HOST_LLVM_TARGET_ARCH);AMDGPU"
 endif
 
 HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD=$(HOST_LLVM_TARGET_TO_BUILD)
-
+LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD=$(HOST_LLVM_TARGET_TO_BUILD)
 # 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, we target the host, but this can be overridden at CMake
 # invocation time.
 HOST_LLVM_CONF_OPTS += -DLLVM_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME)
+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.
@@ -216,6 +286,7 @@ HOST_LLVM_CONF_OPTS += -DLLVM_OPTIMIZED_TABLEGEN=ON
 # 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
+LLVM_CONF_OPTS += -DLLVM_BUILD_LLVM_DYLIB=ON
 
 define HOST_LLVM_INSTALL_CMDS
 	$(INSTALL) -D -m 0755 $(HOST_LLVM_BUILDDIR)/bin/llvm-tblgen $(HOST_DIR)/bin/llvm-tblgen
@@ -281,4 +352,5 @@ HOST_LLVM_CONF_OPTS += -DLLVM_TOOL_BUGPOINT_BUILD=OFF \
 	-DLLVM_TOOL_LLVM_XRAY_BUILD=OFF \
 	-DLLVM_TOOL_YAML2OBJ_BUILD=OFF \
 
+$(eval $(cmake-package))
 $(eval $(host-cmake-package))
-- 
2.14.3

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

* [Buildroot] [PATCH 3/4] package/llvm: add AMDGPU support
  2018-02-16  8:36 [Buildroot] [PATCH 0/4] llvm for mesa3d Valentin Korenblit
  2018-02-16  8:36 ` [Buildroot] [PATCH 1/4] package/llvm: new host package Valentin Korenblit
  2018-02-16  8:36 ` [Buildroot] [PATCH 2/4] package/llvm: enable target variant Valentin Korenblit
@ 2018-02-16  8:36 ` Valentin Korenblit
  2018-02-16  8:36 ` [Buildroot] [PATCH 4/4] package/mesa3d: enable llvm support Valentin Korenblit
  2018-02-16  9:42 ` [Buildroot] [PATCH 0/4] llvm for mesa3d Will Wagner
  4 siblings, 0 replies; 10+ messages in thread
From: Valentin Korenblit @ 2018-02-16  8:36 UTC (permalink / raw)
  To: buildroot

From: Romain Naour <romain.naour@gmail.com>

Limit the number of supported target for mesa3d when openCL support is enabled.
With -DLLVM_TARGETS_TO_BUILD="all" mesa3d fail to build on x86_64 target with AMDGPU target:

 CXXLD    libOpenCL.la
../../../../src/gallium/state_trackers/clover/.libs/libclover.a(libclllvm_la-invocation.o): In function `(anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
invocation.cpp:(.text+0x1a8): undefined reference to `LLVMInitializeAArch64Target'
invocation.cpp:(.text+0x1b2): undefined reference to `LLVMInitializeARMTarget'
invocation.cpp:(.text+0x1b7): undefined reference to `LLVMInitializeBPFTarget'
invocation.cpp:(.text+0x1bc): undefined reference to `LLVMInitializeHexagonTarget'
invocation.cpp:(.text+0x1c1): undefined reference to `LLVMInitializeLanaiTarget'
invocation.cpp:(.text+0x1c6): undefined reference to `LLVMInitializeMipsTarget'
invocation.cpp:(.text+0x1cb): undefined reference to `LLVMInitializeMSP430Target'
invocation.cpp:(.text+0x1d0): undefined reference to `LLVMInitializeNVPTXTarget'
invocation.cpp:(.text+0x1d5): undefined reference to `LLVMInitializePowerPCTarget'
invocation.cpp:(.text+0x1da): undefined reference to `LLVMInitializeRISCVTarget'
invocation.cpp:(.text+0x1df): undefined reference to `LLVMInitializeSparcTarget'
invocation.cpp:(.text+0x1e4): undefined reference to `LLVMInitializeSystemZTarget'
invocation.cpp:(.text+0x1ee): undefined reference to `LLVMInitializeXCoreTarget'
invocation.cpp:(.text+0x1f3): undefined reference to `LLVMInitializeAArch64TargetInfo'
invocation.cpp:(.text+0x1fd): undefined reference to `LLVMInitializeARMTargetInfo'
invocation.cpp:(.text+0x202): undefined reference to `LLVMInitializeBPFTargetInfo'
invocation.cpp:(.text+0x207): undefined reference to `LLVMInitializeHexagonTargetInfo'
invocation.cpp:(.text+0x20c): undefined reference to `LLVMInitializeLanaiTargetInfo'
invocation.cpp:(.text+0x211): undefined reference to `LLVMInitializeMipsTargetInfo'
invocation.cpp:(.text+0x216): undefined reference to `LLVMInitializeMSP430TargetInfo'
invocation.cpp:(.text+0x21b): undefined reference to `LLVMInitializeNVPTXTargetInfo'
invocation.cpp:(.text+0x220): undefined reference to `LLVMInitializePowerPCTargetInfo'
invocation.cpp:(.text+0x225): undefined reference to `LLVMInitializeRISCVTargetInfo'
invocation.cpp:(.text+0x22a): undefined reference to `LLVMInitializeSparcTargetInfo'
invocation.cpp:(.text+0x22f): undefined reference to `LLVMInitializeSystemZTargetInfo'
invocation.cpp:(.text+0x239): undefined reference to `LLVMInitializeXCoreTargetInfo'
invocation.cpp:(.text+0x23e): undefined reference to `LLVMInitializeAArch64TargetMC'
invocation.cpp:(.text+0x248): undefined reference to `LLVMInitializeARMTargetMC'
invocation.cpp:(.text+0x24d): undefined reference to `LLVMInitializeBPFTargetMC'
invocation.cpp:(.text+0x252): undefined reference to `LLVMInitializeHexagonTargetMC'
invocation.cpp:(.text+0x257): undefined reference to `LLVMInitializeLanaiTargetMC'
invocation.cpp:(.text+0x25c): undefined reference to `LLVMInitializeMipsTargetMC'
invocation.cpp:(.text+0x261): undefined reference to `LLVMInitializeMSP430TargetMC'
invocation.cpp:(.text+0x266): undefined reference to `LLVMInitializeNVPTXTargetMC'
invocation.cpp:(.text+0x26b): undefined reference to `LLVMInitializePowerPCTargetMC'
invocation.cpp:(.text+0x270): undefined reference to `LLVMInitializeRISCVTargetMC'
invocation.cpp:(.text+0x275): undefined reference to `LLVMInitializeSparcTargetMC'
invocation.cpp:(.text+0x27a): undefined reference to `LLVMInitializeSystemZTargetMC'
invocation.cpp:(.text+0x284): undefined reference to `LLVMInitializeXCoreTargetMC'
invocation.cpp:(.text+0x289): undefined reference to `LLVMInitializeAArch64AsmPrinter'
invocation.cpp:(.text+0x293): undefined reference to `LLVMInitializeARMAsmPrinter'
invocation.cpp:(.text+0x298): undefined reference to `LLVMInitializeBPFAsmPrinter'
invocation.cpp:(.text+0x29d): undefined reference to `LLVMInitializeHexagonAsmPrinter'
invocation.cpp:(.text+0x2a2): undefined reference to `LLVMInitializeLanaiAsmPrinter'
invocation.cpp:(.text+0x2a7): undefined reference to `LLVMInitializeMipsAsmPrinter'
invocation.cpp:(.text+0x2ac): undefined reference to `LLVMInitializeMSP430AsmPrinter'
invocation.cpp:(.text+0x2b1): undefined reference to `LLVMInitializeNVPTXAsmPrinter'
invocation.cpp:(.text+0x2b6): undefined reference to `LLVMInitializePowerPCAsmPrinter'
invocation.cpp:(.text+0x2bb): undefined reference to `LLVMInitializeSparcAsmPrinter'
invocation.cpp:(.text+0x2c0): undefined reference to `LLVMInitializeSystemZAsmPrinter'
invocation.cpp:(.text+0x2ca): undefined reference to `LLVMInitializeXCoreAsmPrinter'
collect2: error: ld returned 1 exit status

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/llvm/Config.in | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index 84dde8d5ff..417af6ebe2 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -27,3 +27,12 @@ config BR2_PACKAGE_LLVM
 	  compiler and toolchain technologies.
 
 	  http://llvm.org
+
+if BR2_PACKAGE_LLVM
+
+config BR2_PACKAGE_LLVM_TARGET_ARCH_AMDGPU
+	bool "AMDGPU"
+	help
+	  TODO
+
+endif # BR2_PACKAGE_LLVM
-- 
2.14.3

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

* [Buildroot] [PATCH 4/4] package/mesa3d: enable llvm support
  2018-02-16  8:36 [Buildroot] [PATCH 0/4] llvm for mesa3d Valentin Korenblit
                   ` (2 preceding siblings ...)
  2018-02-16  8:36 ` [Buildroot] [PATCH 3/4] package/llvm: add AMDGPU support Valentin Korenblit
@ 2018-02-16  8:36 ` Valentin Korenblit
  2018-02-16  9:42 ` [Buildroot] [PATCH 0/4] llvm for mesa3d Will Wagner
  4 siblings, 0 replies; 10+ messages in thread
From: Valentin Korenblit @ 2018-02-16  8:36 UTC (permalink / raw)
  To: buildroot

From: Romain Naour <romain.naour@gmail.com>

mesa: disable shared libs

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/mesa3d/Config.in |  8 ++++++++
 package/mesa3d/mesa3d.mk | 18 +++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/package/mesa3d/Config.in b/package/mesa3d/Config.in
index f141587c4d..cc8960b1b1 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 a llvm compiler"
+	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 c275579fb8..2822f82bc6 100644
--- a/package/mesa3d/mesa3d.mk
+++ b/package/mesa3d/mesa3d.mk
@@ -32,6 +32,21 @@ ifeq ($(BR2_SHARED_STATIC_LIBS),y)
 MESA3D_CONF_OPTS += --disable-static
 endif
 
+ifeq ($(BR2_PACKAGE_MESA3D_LLVM),y)
+# Mesa want to build libgallium.a unconditionally, so it can't be linked dynamically with llvm shared libraries.
+MESA3D_DEPENDENCIES += host-llvm llvm
+MESA3D_CONF_OPTS += \
+	--with-llvm-prefix=$(STAGING_DIR)/usr \
+	--disable-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 +234,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] 10+ messages in thread

* [Buildroot] [PATCH 0/4] llvm for mesa3d
  2018-02-16  8:36 [Buildroot] [PATCH 0/4] llvm for mesa3d Valentin Korenblit
                   ` (3 preceding siblings ...)
  2018-02-16  8:36 ` [Buildroot] [PATCH 4/4] package/mesa3d: enable llvm support Valentin Korenblit
@ 2018-02-16  9:42 ` Will Wagner
  2018-02-16 14:31   ` Valentin KORENBLIT
  4 siblings, 1 reply; 10+ messages in thread
From: Will Wagner @ 2018-02-16  9:42 UTC (permalink / raw)
  To: buildroot

On 16/02/2018 08:36, Valentin Korenblit wrote:
> Hello all,
> 
> This series provides LLVM support for Mesa3d, enabling
> llvmpipe software rasterizer.
> 
> It must be considered that it does not provide a full LLVM
> installation for the host, only the necessary components to
> cross-compile LLVM for the target. It will install all target
> components as libLLVM.so.

Hi Valentin,

As it happens I've just been updating my patches for llvm as I added it 
to get radeonsi gallium working in mesa3d. My patches are much messier 
than your and hence I've never tried to upstream anything.

A couple of overall questions:

Have you only added host-llvm because of llvm-tblgen and llvm-config? 
llvm will try to build native versions of those for you but I had 
problems with llvm-tblgen and so had to go to a host package like you. 
However I only built those two tools with:

HOST_LLVM_MAKE_OPTS = llvm-tblgen llvm-config

It makes the build smaller and faster and it means you don't need to 
care about almost all of the host conf options.


My other question is about AMDGPU support, you seem to have mixed this 
up into a number of your patches not just number 3. What are you trying 
to do here, add an option to build amdgpu as well as the target arch? In 
my case I wanted to be able to build for only amdgpu and not the target 
arch as this is what radeonsi needs.

Regards
Will

-- 
------------------------------------------------------------------------
Will Wagner                                     will_wagner at carallon.com
Engineering Manager                      Office Tel: +44 (0)20 7471 9424
Carallon Ltd, International House, 7 High Street, Ealing, London  W5 5DB
------------------------------------------------------------------------

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

* [Buildroot] [PATCH 0/4] llvm for mesa3d
  2018-02-16  9:42 ` [Buildroot] [PATCH 0/4] llvm for mesa3d Will Wagner
@ 2018-02-16 14:31   ` Valentin KORENBLIT
  2018-02-17 23:00     ` nimaim
  0 siblings, 1 reply; 10+ messages in thread
From: Valentin KORENBLIT @ 2018-02-16 14:31 UTC (permalink / raw)
  To: buildroot

Hi WIll,

On 16/02/2018 10:42, Will Wagner wrote:
> On 16/02/2018 08:36, Valentin Korenblit wrote:
>> Hello all,
>>
>> This series provides LLVM support for Mesa3d, enabling
>> llvmpipe software rasterizer.
>>
>> It must be considered that it does not provide a full LLVM
>> installation for the host, only the necessary components to
>> cross-compile LLVM for the target. It will install all target
>> components as libLLVM.so.
>
> Hi Valentin,
>
> As it happens I've just been updating my patches for llvm as I added 
> it to get radeonsi gallium working in mesa3d. My patches are much 
> messier than your and hence I've never tried to upstream anything.
>
> A couple of overall questions:
>
> Have you only added host-llvm because of llvm-tblgen and llvm-config? 
> llvm will try to build native versions of those for you but I had 
> problems with llvm-tblgen and so had to go to a host package like you. 
> However I only built those two tools with:
>
> HOST_LLVM_MAKE_OPTS = llvm-tblgen llvm-config
>
> It makes the build smaller and faster and it means you don't need to 
> care about almost all of the host conf options.

Correct, host-llvm installs only llvm-tblgen and llvm-config and I agree 
with you that we could use that option for this case.
>
> My other question is about AMDGPU support, you seem to have mixed this 
> up into a number of your patches not just number 3. What are you 
> trying to do here, add an option to build amdgpu as well as the target 
> arch? In my case I wanted to be able to build for only amdgpu and not 
> the target arch as this is what radeonsi needs.
You're right, I should move:

ifeq ($(BR2_PACKAGE_LLVM_TARGET_ARCH_AMDGPU),y)
HOST_LLVM_TARGET_TO_BUILD = "$(HOST_LLVM_TARGET_ARCH);AMDGPU"
endif

to patch 3. Yes, by using this option I limit the targets to build to 
'target_arch + amdgpu' because by default it is set to 'all'.
>
> Regards
> Will
>
Thanks and regards,

Valent?n

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

* [Buildroot] [PATCH 0/4] llvm for mesa3d
  2018-02-16 14:31   ` Valentin KORENBLIT
@ 2018-02-17 23:00     ` nimaim
  2018-02-19 12:38       ` Valentin KORENBLIT
  0 siblings, 1 reply; 10+ messages in thread
From: nimaim @ 2018-02-17 23:00 UTC (permalink / raw)
  To: buildroot

Hi, thank you for your contribution. I've been manually building and using
llvmpipe w/ mesa3d based on Romain's RFC series in patchwork (ignoring the
clang, clc stuff), but it would be nice if we can get it officially added. 

Out of curiosity, have you tested this with mesa3d 17.3.x? Those versions
broke llvm for me w/ Romain's older patches ... mesa fails to find and link
against the libs. I had to downgrade to the latest 17.2.x (17.2.8 at the
time of this posting).



--
Sent from: http://buildroot-busybox.2317881.n4.nabble.com/

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

* [Buildroot] [PATCH 0/4] llvm for mesa3d
  2018-02-17 23:00     ` nimaim
@ 2018-02-19 12:38       ` Valentin KORENBLIT
  2018-02-19 14:28         ` Nimai Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Valentin KORENBLIT @ 2018-02-19 12:38 UTC (permalink / raw)
  To: buildroot



On 18/02/2018 00:00, nimaim wrote:
> Hi, thank you for your contribution. I've been manually building and using
> llvmpipe w/ mesa3d based on Romain's RFC series in patchwork (ignoring the
> clang, clc stuff), but it would be nice if we can get it officially added.
>
> Out of curiosity, have you tested this with mesa3d 17.3.x? Those versions
> broke llvm for me w/ Romain's older patches ... mesa fails to find and link
> against the libs. I had to downgrade to the latest 17.2.x (17.2.8 at the
> time of this posting).
>
>
>
> --
> Sent from: http://buildroot-busybox.2317881.n4.nabble.com/
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Hi,

I'm using mesa3d 17.3.4 and it works correctly. You should also consider 
that the RFC series uses llvm 4.0.1.

Regards,

Valent?n

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

* [Buildroot] [PATCH 0/4] llvm for mesa3d
  2018-02-19 12:38       ` Valentin KORENBLIT
@ 2018-02-19 14:28         ` Nimai Mahajan
  0 siblings, 0 replies; 10+ messages in thread
From: Nimai Mahajan @ 2018-02-19 14:28 UTC (permalink / raw)
  To: buildroot

On Mon, Feb 19, 2018 at 7:38 AM, Valentin KORENBLIT <
valentin.korenblit@smile.fr> wrote:

>
>
> On 18/02/2018 00:00, nimaim wrote:
>
>> Hi, thank you for your contribution. I've been manually building and using
>> llvmpipe w/ mesa3d based on Romain's RFC series in patchwork (ignoring the
>> clang, clc stuff), but it would be nice if we can get it officially added.
>>
>> Out of curiosity, have you tested this with mesa3d 17.3.x? Those versions
>> broke llvm for me w/ Romain's older patches ... mesa fails to find and
>> link
>> against the libs. I had to downgrade to the latest 17.2.x (17.2.8 at the
>> time of this posting).
>>
>>
>>
>> --
>> Sent from: http://buildroot-busybox.2317881.n4.nabble.com/
>> _______________________________________________
>> buildroot mailing list
>> buildroot at busybox.net
>> http://lists.busybox.net/mailman/listinfo/buildroot
>>
> Hi,
>
> I'm using mesa3d 17.3.4 and it works correctly. You should also consider
> that the RFC series uses llvm 4.0.1.


> Regards,
>
> Valent?n
>

Thanks for the confirmation. I actually bumped that series up to 5.0.1
before I tested it but it still broke mesa3d 17.3.x (17.2.x worked fine).
I'm guessing your other fixes to this patch did the trick. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180219/55806ac2/attachment.html>

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

end of thread, other threads:[~2018-02-19 14:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-16  8:36 [Buildroot] [PATCH 0/4] llvm for mesa3d Valentin Korenblit
2018-02-16  8:36 ` [Buildroot] [PATCH 1/4] package/llvm: new host package Valentin Korenblit
2018-02-16  8:36 ` [Buildroot] [PATCH 2/4] package/llvm: enable target variant Valentin Korenblit
2018-02-16  8:36 ` [Buildroot] [PATCH 3/4] package/llvm: add AMDGPU support Valentin Korenblit
2018-02-16  8:36 ` [Buildroot] [PATCH 4/4] package/mesa3d: enable llvm support Valentin Korenblit
2018-02-16  9:42 ` [Buildroot] [PATCH 0/4] llvm for mesa3d Will Wagner
2018-02-16 14:31   ` Valentin KORENBLIT
2018-02-17 23:00     ` nimaim
2018-02-19 12:38       ` Valentin KORENBLIT
2018-02-19 14:28         ` Nimai Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox