All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valentin Korenblit <valentin.korenblit@smile.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v4 08/11] package/clang: enable target variant
Date: Thu, 29 Mar 2018 13:33:43 +0200	[thread overview]
Message-ID: <20180329113346.10367-9-valentin.korenblit@smile.fr> (raw)
In-Reply-To: <20180329113346.10367-1-valentin.korenblit@smile.fr>

This patch provides Clang for the target, tools and libraries.

In this package we have to deal with the same kind of problem we encountered
when building mesa3d with llvm support: llvm-config (host-version) had to be
copied to STAGING_DIR/usr/bin. In this case, we need llvm-tblgen from host
to be installed in STAGING_DIR/usr/bin for cross-compiling clang.

We need libclang for the target because it is used by all OpenCL implementations.
In this series, Clover is provided.

Signed-off-by: Valentin Korenblit <valentin.korenblit@smile.fr>
---
 package/Config.in       |  1 +
 package/clang/Config.in |  8 ++++++++
 package/clang/clang.mk  | 30 ++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+)
 create mode 100644 package/clang/Config.in

diff --git a/package/Config.in b/package/Config.in
index 47e5b3d1b4..4d32d749fb 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1474,6 +1474,7 @@ menu "Other"
 	source "package/bctoolbox/Config.in"
 	source "package/bdwgc/Config.in"
 	source "package/boost/Config.in"
+	source "package/clang/Config.in"
 	source "package/clapack/Config.in"
 	source "package/classpath/Config.in"
 	source "package/cppcms/Config.in"
diff --git a/package/clang/Config.in b/package/clang/Config.in
new file mode 100644
index 0000000000..e2e53dcbc8
--- /dev/null
+++ b/package/clang/Config.in
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_CLANG
+	bool "clang"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	help
+	  Clang is a C/C++, Objective C/C++ and OpenCL C front-end
+	  for the LLVM compiler.
+
+	  http://clang.llvm.org/
diff --git a/package/clang/clang.mk b/package/clang/clang.mk
index 5ea0bb05f9..c2b83a8e60 100644
--- a/package/clang/clang.mk
+++ b/package/clang/clang.mk
@@ -10,31 +10,61 @@ CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz
 CLANG_LICENSE = NCSA
 CLANG_LICENSE_FILES = LICENSE.TXT
 CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
+CLANG_INSTALL_STAGING = YES
 
 HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
+CLANG_DEPENDENCIES = host-clang llvm
 
 # Use "Unix Makefiles" generator for generating make-compatible parallel makefiles.
 HOST_CLANG_CONF_OPTS += -G "Unix Makefiles"
+CLANG_CONF_OPTS += -G "Unix Makefiles"
+
+# This option is needed. Otherwise multiple shared libs (libclangAST.so,
+# libclangBasic.so, libclangFrontend.so, etc.) will generated. As a final
+# shared lib containing all these components (libclang.so) is also generated, this
+# resulted in the following error when trying to use tools that use libclang:
+# $ CommandLine Error: Option 'track-memory' registered more than once!
+# $ LLVM ERROR: inconsistency in registered CommandLine options
+# By setting BUILD_SHARED_LIBS to OFF, we generate multiple static libraries
+# (the same way as host's clang build) and finally libclang.so to be installed on the
+# target.
+CLANG_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
+
+# Copy llvm-tblgen (host variant) to STAGING_DIR
+define CLANG_COPY_LLVM_TBLGEN_TO_STAGING_DIR
+	$(INSTALL) -D -m 0755 $(HOST_DIR)/bin/llvm-tblgen $(STAGING_DIR)/usr/bin/llvm-tblgen
+endef
+CLANG_PRE_CONFIGURE_HOOKS = CLANG_COPY_LLVM_TBLGEN_TO_STAGING_DIR
 
 # Select Release build
 HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
+
+# Make it explicit that we are cross-compiling
+CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
 
 # Build tools enabled
 HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
+CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
 
 # Don't build examples
 HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
+CLANG_CONF_OPTS += -DCLANG_BUILD_EXAMPLES=OFF
 
 # Don't build doc
 HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
+CLANG_CONF_OPTS += -DCLANG_INCLUDE_DOCS=OFF
 
 # Don't build tests
 HOST_CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF
+CLANG_CONF_OPTS += -DCLANG_INCLUDE_TESTS=OFF
 
 # Specify path to host's llvm-config
 HOST_CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(HOST_DIR)/bin/llvm-config
+CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(STAGING_DIR)/usr/bin/llvm-config
 
 # Install clang in  HOST_DIR/usr
 HOST_CLANG_CONF_OPTS += -DCMAKE_INSTALL_PREFIX=$(HOST_DIR)/usr
 
+$(eval $(cmake-package))
 $(eval $(host-cmake-package))
-- 
2.14.3

  parent reply	other threads:[~2018-03-29 11:33 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29 11:33 [Buildroot] [PATCH v4 00/11] llvm for mesa3d Valentin Korenblit
2018-03-29 11:33 ` [Buildroot] [PATCH v4 01/11] package/llvm: new host package Valentin Korenblit
2018-04-01 20:36   ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 02/11] package/llvm: enable target variant Valentin Korenblit
2018-04-01 20:46   ` Thomas Petazzoni
2018-04-01 22:50     ` Arnout Vandecappelle
2018-03-29 11:33 ` [Buildroot] [PATCH v4 03/11] package/llvm: enable AMDGPU Valentin Korenblit
2018-03-30  9:02   ` Thomas Petazzoni
2018-03-30 11:33     ` Valentin Korenblit
2018-03-30 18:08     ` Arnout Vandecappelle
2018-03-30 19:06       ` Thomas Petazzoni
2018-03-30 20:33         ` Valentin Korenblit
2018-04-01 20:47           ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 04/11] package/mesa3d: enable llvm support Valentin Korenblit
2018-04-01 20:53   ` Thomas Petazzoni
2018-04-02 10:05     ` Valentin Korenblit
2018-04-02 12:01       ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 05/11] package/llvm: enable ARM Valentin Korenblit
2018-04-01 20:53   ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 06/11] package/llvm: enable AArch64 Valentin Korenblit
2018-03-29 11:33 ` [Buildroot] [PATCH v4 07/11] package/clang: new host package Valentin Korenblit
2018-03-30 16:56   ` Matthew Weber
2018-03-30 20:24     ` Valentin Korenblit
2018-04-01 20:56   ` Thomas Petazzoni
2018-03-29 11:33 ` Valentin Korenblit [this message]
2018-03-30  9:07   ` [Buildroot] [PATCH v4 08/11] package/clang: enable target variant Thomas Petazzoni
2018-03-30 12:16     ` Valentin Korenblit
2018-03-30 12:37       ` Thomas Petazzoni
2018-03-30 17:58   ` Matthew Weber
2018-04-01 21:25   ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 09/11] package/libclc: new package Valentin Korenblit
2018-04-01 21:29   ` Thomas Petazzoni
2018-04-03 12:27     ` Valentin Korenblit
2018-04-03 15:17       ` Thomas Petazzoni
2018-04-03 16:26         ` Valentin Korenblit
2018-03-29 11:33 ` [Buildroot] [PATCH v4 10/11] package/mesa3d: enable OpenCL support Valentin Korenblit
2018-04-01 21:32   ` Thomas Petazzoni
2018-04-02  5:23     ` Erik Larsson
2018-04-02  6:51       ` Thomas Petazzoni
2018-04-02 10:36     ` Valentin Korenblit
2018-04-02 12:03       ` Thomas Petazzoni
2018-03-29 11:33 ` [Buildroot] [PATCH v4 11/11] package/clinfo: new package Valentin Korenblit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180329113346.10367-9-valentin.korenblit@smile.fr \
    --to=valentin.korenblit@smile.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.