All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0
@ 2021-03-11 14:29 Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 2/9] package/clang: " Matt Weber
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
---
 package/llvm/llvm.hash | 2 +-
 package/llvm/llvm.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/llvm/llvm.hash b/package/llvm/llvm.hash
index 6bf2755777..e93a922492 100644
--- a/package/llvm/llvm.hash
+++ b/package/llvm/llvm.hash
@@ -1,3 +1,3 @@
 # locally calculated
-sha256 00a1ee1f389f81e9979f3a640a01c431b3021de0d42278f6508391a2f0b81c9a llvm-9.0.1.src.tar.xz
+sha256 ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5 llvm-11.1.0.src.tar.xz
 sha256 8d85c1057d742e597985c7d4e6320b015a9139385cff4cbae06ffc0ebe89afee LICENSE.TXT
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 7d60fe7f8c..6c7ae3f838 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -5,7 +5,7 @@
 ################################################################################
 
 # LLVM, Clang and lld should be version bumped together
-LLVM_VERSION = 9.0.1
+LLVM_VERSION = 11.1.0
 LLVM_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LLVM_VERSION)
 LLVM_SOURCE = llvm-$(LLVM_VERSION).src.tar.xz
 LLVM_LICENSE = Apache-2.0 with exceptions
-- 
2.17.1

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

* [Buildroot] [PATCH v11 2/9] package/clang: bump to version 11.1.0
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 3/9] package/lld: " Matt Weber
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
---
 package/clang/clang.hash | 2 +-
 package/clang/clang.mk   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/package/clang/clang.hash b/package/clang/clang.hash
index 067a2c0470..32a19c1659 100644
--- a/package/clang/clang.hash
+++ b/package/clang/clang.hash
@@ -1,3 +1,3 @@
 # locally calculated
-sha256 5778512b2e065c204010f88777d44b95250671103e434f9dc7363ab2e3804253 clang-9.0.1.src.tar.xz
+sha256 0a8288f065d1f57cb6d96da4d2965cbea32edc572aa972e466e954d17148558b clang-11.1.0.src.tar.xz
 sha256 ebcd9bbf783a73d05c53ba4d586b8d5813dcdf3bbec50265860ccc885e606f47 LICENSE.TXT
diff --git a/package/clang/clang.mk b/package/clang/clang.mk
index 939f000cbd..d1667d79b6 100644
--- a/package/clang/clang.mk
+++ b/package/clang/clang.mk
@@ -5,7 +5,8 @@
 ################################################################################
 
 # LLVM, Clang and lld should be version bumped together
-CLANG_VERSION = 9.0.1
+CLANG_VERSION_MAJOR = 11
+CLANG_VERSION = $(CLANG_VERSION_MAJOR).1.0
 CLANG_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(CLANG_VERSION)
 CLANG_SOURCE = clang-$(CLANG_VERSION).src.tar.xz
 CLANG_LICENSE = Apache-2.0 with exceptions
-- 
2.17.1

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

* [Buildroot] [PATCH v11 3/9] package/lld: bump to version 11.1.0
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 2/9] package/clang: " Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0 Matt Weber
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

---
 package/lld/lld.hash | 2 +-
 package/lld/lld.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/lld/lld.hash b/package/lld/lld.hash
index 2144cc5666..17b8d18997 100644
--- a/package/lld/lld.hash
+++ b/package/lld/lld.hash
@@ -1,3 +1,3 @@
 # locally calculated
-sha256 86262bad3e2fd784ba8c5e2158d7aa36f12b85f2515e95bc81d65d75bb9b0c82  lld-9.0.1.src.tar.xz
+sha256 017a788cbe1ecc4a949abf10755870519086d058a2e99f438829aef24f0c66ce  lld-11.1.0.src.tar.xz
 sha256 f7891568956e34643eb6a0db1462db30820d40d7266e2a78063f2fe233ece5a0  LICENSE.TXT
diff --git a/package/lld/lld.mk b/package/lld/lld.mk
index cd1a03c1d3..4bf903cda0 100644
--- a/package/lld/lld.mk
+++ b/package/lld/lld.mk
@@ -5,7 +5,7 @@
 ################################################################################
 
 # LLVM, Clang and lld should be version bumped together
-LLD_VERSION = 9.0.1
+LLD_VERSION = 11.1.0
 LLD_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LLD_VERSION)
 LLD_SOURCE = lld-$(LLD_VERSION).src.tar.xz
 LLD_LICENSE = Apache-2.0 with exceptions
-- 
2.17.1

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

* [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 2/9] package/clang: " Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 3/9] package/lld: " Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  2021-03-11 14:35   ` Matthew Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 5/9] package/compiler-rt: new package Matt Weber
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

 * Converts to the cmake pkg type
 * Updates download site
 * Adds a crosscompile fixups patch
   * Allow prepare_builtins utility to be directly called
     (it isn't installed into the path when cross compiling)
   * Fix file_find() for root search limitation

Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
---
 .../0001-support-out-of-tree-build.patch      | 71 +++++++++++++++++++
 package/libclc/libclc.hash                    |  2 +-
 package/libclc/libclc.mk                      | 42 +++--------
 3 files changed, 83 insertions(+), 32 deletions(-)
 create mode 100644 package/libclc/0001-support-out-of-tree-build.patch

diff --git a/package/libclc/0001-support-out-of-tree-build.patch b/package/libclc/0001-support-out-of-tree-build.patch
new file mode 100644
index 0000000000..918474c433
--- /dev/null
+++ b/package/libclc/0001-support-out-of-tree-build.patch
@@ -0,0 +1,71 @@
+From 495491e9d53bfb184c15753b5187e4bb55b19511 Mon Sep 17 00:00:00 2001
+From: Matt Weber <matthew.weber@rockwellcollins.com>
+Date: Tue, 9 Mar 2021 15:55:17 -0600
+Subject: [PATCH] support out of tree build
+
+(1) The package has a prepare_builtins tool which is built
+but not placed in the path for later use in the build. This
+fix allows the later build steps to use the binary in-place.
+
+(2) With cmake, find_file() when used for non-host builds is
+limited by CMAKE_FIND_ROOT_PATH* scope.
+
+In $(HOST_DIR)/share/buildroot/toolchainfile.cmake we set the
+following target settings for CMAKE_FIND_ROOT_PATH* which
+limit the scope.
+set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/aarch64-buildroot-linux-gnu/sysroot")
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+
+Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
+---
+ CMakeLists.txt                          | 2 +-
+ cmake/CMakeDetermineCLCCompiler.cmake   | 4 ++++
+ cmake/CMakeDetermineLLAsmCompiler.cmake | 4 ++++
+ 3 files changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9472f19..a784519 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -279,7 +279,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
+ 
+ 		# Add prepare target
+ 		add_custom_command( OUTPUT "${obj_suffix}"
+-			            COMMAND prepare_builtins -o
++			            COMMAND ./prepare_builtins -o
+ 				    "${obj_suffix}"
+ 				    "builtins.opt.${obj_suffix}"
+ 				    DEPENDS "opt.${obj_suffix}"
+diff --git a/cmake/CMakeDetermineCLCCompiler.cmake b/cmake/CMakeDetermineCLCCompiler.cmake
+index 94d85d9..5de6a48 100644
+--- a/cmake/CMakeDetermineCLCCompiler.cmake
++++ b/cmake/CMakeDetermineCLCCompiler.cmake
+@@ -12,7 +12,7 @@ mark_as_advanced(CMAKE_CLC_ARCHIVE)
+ 
+ set(CMAKE_CLC_COMPILER_ENV_VAR "CLC_COMPILER")
+ set(CMAKE_CLC_ARCHIVE_ENV_VAR "CLC_LINKER")
+-find_file(clc_comp_in CMakeCLCCompiler.cmake.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
++set(clc_comp_in "${CMAKE_MODULE_PATH}/CMakeCLCCompiler.cmake.in" )
+ # configure all variables set in this file
+ configure_file(${clc_comp_in} ${CMAKE_PLATFORM_INFO_DIR}/CMakeCLCCompiler.cmake @ONLY)
+ mark_as_advanced(clc_comp_in)
+diff --git a/cmake/CMakeDetermineLLAsmCompiler.cmake b/cmake/CMakeDetermineLLAsmCompiler.cmake
+index 1c424c7..dd3bfb6 100644
+--- a/cmake/CMakeDetermineLLAsmCompiler.cmake
++++ b/cmake/CMakeDetermineLLAsmCompiler.cmake
+@@ -18,7 +18,7 @@ mark_as_advanced(CMAKE_LLAsm_ARCHIVE)
+ set(CMAKE_LLAsm_PREPROCESSOR_ENV_VAR "LL_PREPROCESSOR")
+ set(CMAKE_LLAsm_COMPILER_ENV_VAR "LL_ASSEMBLER")
+ set(CMAKE_LLAsm_ARCHIVE_ENV_VAR "LL_LINKER")
+-find_file(ll_comp_in CMakeLLAsmCompiler.cmake.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
++set(ll_comp_in "${CMAKE_MODULE_PATH}/CMakeLLAsmCompiler.cmake.in" )
+ # configure all variables set in this file
+ configure_file(${ll_comp_in} ${CMAKE_PLATFORM_INFO_DIR}/CMakeLLAsmCompiler.cmake @ONLY)
+ mark_as_advanced(ll_comp_in)
+-- 
+2.17.1
+
diff --git a/package/libclc/libclc.hash b/package/libclc/libclc.hash
index 2af64bc8e8..c670d92ed3 100644
--- a/package/libclc/libclc.hash
+++ b/package/libclc/libclc.hash
@@ -1,3 +1,3 @@
 # locally calculated
-sha256  54d7ae523aabf68d533011739d6c01546cae0c294442d0f44fd657c046cb707d  libclc-d1cbc92e2ceee59963f5c3a576382e5bba31f060-br1.tar.gz
+sha256  198dc45cdcc426c7968b9628a55062162ea338931157a18ddefb47188d119e1d  libclc-11.1.0.src.tar.xz
 sha256  3c536c052db9afd997809e38785c9f2a9e54e2892330fa7c5b438e18a7413479  LICENSE.TXT
diff --git a/package/libclc/libclc.mk b/package/libclc/libclc.mk
index 6fe8e10a77..d460adcf41 100644
--- a/package/libclc/libclc.mk
+++ b/package/libclc/libclc.mk
@@ -4,43 +4,23 @@
 #
 ################################################################################
 
-# Use the latest commit from release_90 branch.
-LIBCLC_VERSION = d1cbc92e2ceee59963f5c3a576382e5bba31f060
-LIBCLC_SITE = https://github.com/llvm-mirror/libclc
-LIBCLC_SITE_METHOD = git
+LIBCLC_VERSION = 11.1.0
+LIBCLC_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCLC_VERSION)
+LIBCLC_SOURCE = libclc-$(LIBCLC_VERSION).src.tar.xz
 LIBCLC_LICENSE = Apache-2.0 with exceptions or MIT
 LIBCLC_LICENSE_FILES = LICENSE.TXT
 
 LIBCLC_DEPENDENCIES = host-clang host-llvm
 LIBCLC_INSTALL_STAGING = YES
 
-# C++ compiler is used to build a small tool (prepare-builtins) for the host.
-# It must be built with the C++ compiler from the host.
+# CMAKE_*_COMPILER_FORCED=ON skips testing the tools and assumes
+# llvm-config provided values
 #
-# The headers are installed in /usr/share and not /usr/include,
-# because they are needed at runtime on the target to build the OpenCL
-# kernels.
+# CMAKE_CXX_COMPILER has to be set to the host compiler to build a host
+# 'prepare_builtins' tool used during the build process
 LIBCLC_CONF_OPTS = \
-	--with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
-	--prefix=/usr \
-	--includedir=/usr/share \
-	--pkgconfigdir=/usr/lib/pkgconfig \
-	--with-cxx-compiler=$(HOSTCXX_NOCCACHE)
+	-DCMAKE_CLC_COMPILER_FORCED=ON \
+	-DCMAKE_LLAsm_COMPILER_FORCED=ON \
+	-DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)"
 
-define LIBCLC_CONFIGURE_CMDS
-	(cd $(@D); $(TARGET_CONFIGURE_OPTS) ./configure.py $(LIBCLC_CONF_OPTS))
-endef
-
-define LIBCLC_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
-endef
-
-define LIBCLC_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
-endef
-
-define LIBCLC_INSTALL_STAGING_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
-endef
-
-$(eval $(generic-package))
+$(eval $(cmake-package))
-- 
2.17.1

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

* [Buildroot] [PATCH v11 5/9] package/compiler-rt: new package
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
                   ` (2 preceding siblings ...)
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0 Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 6/9] testing/tests: CLANG compiler-rt runtime test Matt Weber
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

This patch adds support for the compiler-rt (CLANG runtime) library.
It builds a set of static libraries and installs them into the
CLANG/LLVM toolchain resource folder. These libraries can then be
used by developers in the SDK for building target applications for
analysis.

What is fuzzing and why libfuzzer?
https://www.moritz.systems/blog/an-introduction-to-llvm-libfuzzer/

The compiler-rt fuzzer and address sanitizer tools require additional
LLVM binary tools installed to allow stack trace decoding actively during
executable analysis.  This patch conditionally enables these tools.
https://github.com/google/sanitizers/wiki/AddressSanitizerCallStack

Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Cc: Romain Naour <romain.naour@smile.fr>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Cc: Michael Drake <michael.drake@codethink.co.uk>

---
Changes
v1 -> v2
[Romain
 - Removed unnecessary host-cmake dependency

v2 -> v3
[Romain
 - Update to use COMPILER_RT_INSTALL_PATH for library install
[Ricardo
 - Fixed check-package extra line
 - Spelling in commit message

v3 -> v4
[Valentin
 - Pointed out that non-glibc libraries won't build. Further
   investigation shows that the lib asan support in compiler-rt
   doesn't have the libc checks yet to support multiple libraries.
   (https://patchwork.ozlabs.org/patch/339938/ was the best example
    I could find and it doesn't look like anything has changed in the
    recent codebase)

v4 -> v5
[Thomas P
 - Revisited staging install step and found a cleaner way to use the
   default and then a hook to setup the runtime library path

v6
 - Bumped to 7.0.1 to match current LLVM/Clang version

v7
 - Rebased on master for 8.0 LLVM/Clang version
 - Added comment about bumping verions of LLVM/Clang and Compiler-rt
   together
[Romain
 - Disabled test cases (-DCOMPILER_RT_INCLUDE_TESTS=OFF)

v8
 - Rebased and updated version to 9.x to match llvm/clang

[Romain
 - Squashed "[v7,1/5]package/llvm: install target binary/debug tools" to
   be included in this patch

[Michael D
 - compiler-rt symlink creation to include shared folder such
   that control flow lists work

v9
 - Rebased post 2020.05

v10
 - Switched compiler-rt site to point towards new github project
 - Updated compiler-rt version to 11.0.0
 - Tested against master[8640e8ffde3f61c5838] using
   support/testing/run-tests -o runtest -k \
      tests.package.test_clang.TestClangCompilerRT

v11
 - Updated compiler-rt version to 11.1.0
---
 DEVELOPERS                           |  1 +
 package/Config.in                    |  1 +
 package/compiler-rt/Config.in        | 14 +++++++++++
 package/compiler-rt/compiler-rt.hash |  3 +++
 package/compiler-rt/compiler-rt.mk   | 37 ++++++++++++++++++++++++++++
 package/llvm/llvm.mk                 | 11 ++++++++-
 6 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 package/compiler-rt/Config.in
 create mode 100644 package/compiler-rt/compiler-rt.hash
 create mode 100644 package/compiler-rt/compiler-rt.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index c750105623..cc365c42ed 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1709,6 +1709,7 @@ F:	package/bridge-utils/
 F:	package/checkpolicy/
 F:	package/checksec/
 F:	package/cgroupfs-mount/
+F:	package/compiler-rt/
 F:	package/crda/
 F:	package/cunit/
 F:	package/dacapo/
diff --git a/package/Config.in b/package/Config.in
index 06dfc32cc6..61ec54fd38 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1856,6 +1856,7 @@ menu "Other"
 	source "package/clang/Config.in"
 	source "package/clapack/Config.in"
 	source "package/cmocka/Config.in"
+	source "package/compiler-rt/Config.in"
 	source "package/cppcms/Config.in"
 	source "package/cracklib/Config.in"
 	source "package/dawgdic/Config.in"
diff --git a/package/compiler-rt/Config.in b/package/compiler-rt/Config.in
new file mode 100644
index 0000000000..9afc0d9d60
--- /dev/null
+++ b/package/compiler-rt/Config.in
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_COMPILER_RT
+	bool "compiler-rt"
+	depends on BR2_PACKAGE_LLVM
+	depends on BR2_TOOLCHAIN_USES_GLIBC # asan lib requires
+	help
+	  A collection of runtime libraries primarily used by clang and
+	  llvm to provide builtins, sanitizer runtimes, and profiling
+	  at runtime.
+
+	  https://compiler-rt.llvm.org/
+
+comment "compiler-rt requires llvm to be enabled and a glibc toolchain"
+	depends on !BR2_PACKAGE_LLVM
+	depends on !BR2_TOOLCHAIN_USES_GLIBC
diff --git a/package/compiler-rt/compiler-rt.hash b/package/compiler-rt/compiler-rt.hash
new file mode 100644
index 0000000000..0689ec3d2a
--- /dev/null
+++ b/package/compiler-rt/compiler-rt.hash
@@ -0,0 +1,3 @@
+# Locally computed:
+sha256 def1fc00c764cd3abbba925c712ac38860a756a43b696b291f46fee09e453274  compiler-rt-11.1.0.src.tar.xz
+sha256 1a8f1058753f1ba890de984e48f0242a3a5c29a6a8f2ed9fd813f36985387e8d  LICENSE.TXT
diff --git a/package/compiler-rt/compiler-rt.mk b/package/compiler-rt/compiler-rt.mk
new file mode 100644
index 0000000000..57f9c26854
--- /dev/null
+++ b/package/compiler-rt/compiler-rt.mk
@@ -0,0 +1,37 @@
+################################################################################
+#
+# compiler-rt
+#
+################################################################################
+
+# Compiler-RT should be bumped together with LLVM and Clang as the run-time is
+# tied to the version of those tools
+COMPILER_RT_VERSION = 11.1.0
+COMPILER_RT_SOURCE = compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz
+COMPILER_RT_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(COMPILER_RT_VERSION)
+COMPILER_RT_LICENSE = NCSA MIT
+COMPILER_RT_LICENSE_FILES = LICENSE.TXT
+COMPILER_RT_DEPENDENCIES = host-clang llvm
+
+COMPILER_RT_INSTALL_STAGING = YES
+COMPILER_RT_INSTALL_TARGET = NO
+
+COMPILER_RT_CONF_OPTS=-DCOMPILER_RT_STANDALONE_BUILD=OFF \
+	-DCOMPILER_RT_STANDALONE_BUILD=ON \
+	-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=$(GNU_TARGET_NAME) \
+	-DLLVM_CONFIG_PATH=$(HOST_DIR)/usr/bin/llvm-config
+
+# The installation of the target runtime libraries defaults to DESTDIR, however
+# host-clang resources directory needs a link so Clang can find the runtime
+# libraries in the same location they would be if built as part of the Clang
+# build. The "resources" directory is loosely documented and seems to be
+# assumed, as compiler-rt is usually build at the same time as Clang and not
+# standalone.
+define COMPILER_RT_SETUP_RUNTIME_LIBS
+	mkdir -p $(HOST_DIR)/lib/clang/$(HOST_CLANG_VERSION)/lib
+	ln -sf ../../../../$(GNU_TARGET_NAME)/sysroot/usr/lib/linux $(HOST_DIR)/lib/clang/$(HOST_CLANG_VERSION)/lib/linux
+	ln -sf ../../../../$(GNU_TARGET_NAME)/sysroot/usr/share $(HOST_DIR)/lib/clang/$(HOST_CLANG_VERSION)/share
+endef
+COMPILER_RT_POST_INSTALL_STAGING_HOOKS += COMPILER_RT_SETUP_RUNTIME_LIBS
+
+$(eval $(cmake-package))
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 6c7ae3f838..9b0f3c30d2 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -215,8 +215,17 @@ HOST_LLVM_CONF_OPTS += \
 # We need to activate LLVM_INCLUDE_TOOLS, otherwise it does not generate
 # libLLVM.so
 LLVM_CONF_OPTS += \
-	-DLLVM_INCLUDE_TOOLS=ON \
+	-DLLVM_INCLUDE_TOOLS=ON
+
+# The llvm-symbolizer binary is used by the Compiler-RT Fuzzer
+# and AddressSanitizer tools for stack traces.
+ifeq ($(BR2_PACKAGE_COMPILER_RT),y)
+LLVM_CONF_OPTS += \
+	-DLLVM_BUILD_TOOLS=ON
+else
+LLVM_CONF_OPTS += \
 	-DLLVM_BUILD_TOOLS=OFF
+endif
 
 ifeq ($(BR2_PACKAGE_LLVM_RTTI),y)
 HOST_LLVM_CONF_OPTS += -DLLVM_ENABLE_RTTI=ON
-- 
2.17.1

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

* [Buildroot] [PATCH v11 6/9] testing/tests: CLANG compiler-rt runtime test
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
                   ` (3 preceding siblings ...)
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 5/9] package/compiler-rt: new package Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 7/9] package/clang: help host-clang to find our external toolchain Matt Weber
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

This patch adds a test case that
 1) Builds the complete LLVM and CLANG set of host tools
 2) Cross-compiles the compiler-rt runtime using CLANG
 3) Builds a cross-compiled application using CLANG and the libfuzzer
    compiler-rt library.
 4) Executes the fuzz application (part of the libfuzzer package) on
    target and checks expected output for a heap-buffer-overflow.

Note: The libfuzzer package is just a tutorial example of how to use
      the toolkit provided by llvm (Thus not adding it as a full
      Buildroot package).

Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Cc: Romain Naour <romain.naour@smile.fr>

---
Changes
v1 -> v2
[Ricardo
 - updated yml with test case
 - moved emulator launch cmd to test case from infra
 - defconfig in the order provided by savedefconfig
 - indent defconfig
 - add full package for test code to the test br2-external
 - consolidated to one class only

v2 -> v3
 - Added Review/tested by Ricardo's
   [with the entire series applied on next branch:
    https://gitlab.com/RicardoMartincoski/buildroot/-/jobs/121908178
    NOTE: this test case takes longer than test_rust, ~2 hours in my host
    machine with all tarballs previously downloaded]

v4
 - None

v5
 - Rebased post 2018.11 on master

v6
 - Testing of LLVM/Clang bump

v7
 - Rebase on master and testing of LLVM/Clang bump to 8.0
 - Updated hashes for archive and legal info (legal info changed
   because of spelling cleanup)

v8
 - Cleaned up wording the 4th item of the message above.

[Romain
 - Removes a hardcoded toolchain/sysroot path "b option" for libfuzzer
   pkg build, however requires this series applied.
   http://patchwork.ozlabs.org/project/buildroot/list/?series=129565
 - updated test case to check for heap overflow string to keep arch
   generic
 - Removed the fixed mcpu arg from clang++ build and dropped --sysroot
   as cross compiler wrapper now provides this for libfuzzer build

v9
 - Rebased post 2020.05

v10
 - Updated site for libfuzzer test case and bumped version
 - Switched back to have no dependency on clang as cross compiler series
   - Fixed a libfuzzer link time gcc ld error by adding sysroot and -B
     to the BUILD_CMDS since we don't depend on the cross wrapper.
 - Tested against master[8640e8ffde3f61c583] using
   support/testing/run-tests -o runtest -k \
        tests.package.test_clang.TestClangCompilerRT

v11
 - Updated compiler-rt version to 11.1.0
---
 .../br2-external/clang-compiler-rt/Config.in  |  1 +
 .../clang-compiler-rt/external.desc           |  1 +
 .../clang-compiler-rt/external.mk             |  1 +
 .../package/libfuzzer/Config.in               |  8 ++++
 .../package/libfuzzer/libfuzzer.hash          |  2 +
 .../package/libfuzzer/libfuzzer.mk            | 24 ++++++++++
 support/testing/tests/package/test_clang.py   | 46 +++++++++++++++++++
 7 files changed, 83 insertions(+)
 create mode 100644 support/testing/tests/package/br2-external/clang-compiler-rt/Config.in
 create mode 100644 support/testing/tests/package/br2-external/clang-compiler-rt/external.desc
 create mode 100644 support/testing/tests/package/br2-external/clang-compiler-rt/external.mk
 create mode 100644 support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/Config.in
 create mode 100644 support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.hash
 create mode 100644 support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk
 create mode 100644 support/testing/tests/package/test_clang.py

diff --git a/support/testing/tests/package/br2-external/clang-compiler-rt/Config.in b/support/testing/tests/package/br2-external/clang-compiler-rt/Config.in
new file mode 100644
index 0000000000..e1f9f8c598
--- /dev/null
+++ b/support/testing/tests/package/br2-external/clang-compiler-rt/Config.in
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_CLANG_COMPILER_RT_PATH/package/libfuzzer/Config.in"
diff --git a/support/testing/tests/package/br2-external/clang-compiler-rt/external.desc b/support/testing/tests/package/br2-external/clang-compiler-rt/external.desc
new file mode 100644
index 0000000000..92df85911d
--- /dev/null
+++ b/support/testing/tests/package/br2-external/clang-compiler-rt/external.desc
@@ -0,0 +1 @@
+name: CLANG_COMPILER_RT
diff --git a/support/testing/tests/package/br2-external/clang-compiler-rt/external.mk b/support/testing/tests/package/br2-external/clang-compiler-rt/external.mk
new file mode 100644
index 0000000000..6fa55c1211
--- /dev/null
+++ b/support/testing/tests/package/br2-external/clang-compiler-rt/external.mk
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_CLANG_COMPILER_RT_PATH)/package/*/*.mk))
diff --git a/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/Config.in b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/Config.in
new file mode 100644
index 0000000000..2d335fd3c7
--- /dev/null
+++ b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/Config.in
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_LIBFUZZER
+	bool "libfuzzer"
+	help
+	  This project aims at hosting tutorials,
+	  examples, discussions, research proposals,
+	  and other resources related to fuzzing.
+
+	  https://github.com/google/fuzzing
diff --git a/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.hash b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.hash
new file mode 100644
index 0000000000..9287005ed9
--- /dev/null
+++ b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.hash
@@ -0,0 +1,2 @@
+sha256 c71360c3b1ba1d88b28b0b3cb3a1744d251b87a12f2881224cc53ec26eb7a2db  libfuzzer-cec02db916d21baa4db5b8d262d78848b3a35f4b.tar.gz
+sha256 cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
diff --git a/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk
new file mode 100644
index 0000000000..6c6371bea7
--- /dev/null
+++ b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk
@@ -0,0 +1,24 @@
+################################################################################
+#
+# libfuzzer
+#
+################################################################################
+
+LIBFUZZER_VERSION = cec02db916d21baa4db5b8d262d78848b3a35f4b
+LIBFUZZER_SITE = $(call github,google,fuzzing,$(LIBFUZZER_VERSION))
+LIBFUZZER_LICENSE = Apache-2.0
+LIBFUZZER_LICENSE_FILES = LICENSE
+LIBFUZZER_DEPENDENCIES = compiler-rt
+
+define LIBFUZZER_BUILD_CMDS
+	$(HOST_DIR)/bin/clang++ --sysroot=$(STAGING_DIR) \
+		-B $(HOST_DIR)/opt/ext-toolchain -fsanitize=address,fuzzer \
+		$(@D)/tutorial/libFuzzer/fuzz_me.cc \
+		-o $(@D)/fuzz_me
+endef
+
+define LIBFUZZER_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 755 $(@D)/fuzz_me $(TARGET_DIR)/usr/bin/fuzz_me
+endef
+
+$(eval $(generic-package))
diff --git a/support/testing/tests/package/test_clang.py b/support/testing/tests/package/test_clang.py
new file mode 100644
index 0000000000..df3990c6be
--- /dev/null
+++ b/support/testing/tests/package/test_clang.py
@@ -0,0 +1,46 @@
+import os
+
+import infra.basetest
+
+FUZZ_TIMEOUT = 120
+
+
+class TestClangCompilerRT(infra.basetest.BRTest):
+    br2_external = [infra.filepath("tests/package/br2-external/clang-compiler-rt")]
+    config = \
+        """
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.16.7"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_PACKAGE_COMPILER_RT=y
+        BR2_PACKAGE_LLVM=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        BR2_TARGET_ROOTFS_CPIO_GZIP=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        BR2_PACKAGE_LIBFUZZER=y
+        """
+
+    def login(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
+        kern = os.path.join(self.builddir, "images", "Image")
+        # Sanitizers overallocate memory and the minimum that seemed to work was 512MB
+        self.emulator.boot(arch="aarch64",
+                           kernel=kern,
+                           kernel_cmdline=["console=ttyAMA0"],
+                           options=["-M", "virt", "-cpu", "cortex-a53", "-m", "512", "-initrd", img])
+        self.emulator.login()
+
+    def test_run(self):
+        self.login()
+
+        # The test case verifies the application executes and that
+        # the symbolizer is working to decode the stack trace.
+        cmd = "fuzz_me 2>&1 | grep heap-buffer-overflow"
+        _, exit_code = self.emulator.run(cmd, FUZZ_TIMEOUT)
+        self.assertEqual(exit_code, 0)
-- 
2.17.1

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

* [Buildroot] [PATCH v11 7/9] package/clang: help host-clang to find our external toolchain
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
                   ` (4 preceding siblings ...)
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 6/9] testing/tests: CLANG compiler-rt runtime test Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 8/9] package/clang: install a toolchain-wrapper for the host clang cross-compiler Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 9/9] package/compiler-rt: runtime test use toolchain-wrapper Matt Weber
  7 siblings, 0 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

From: Romain Naour <romain.naour@smile.fr>

To build libfuzzer package Matthew Weber noticed that (host) clang
doesn't run on the host without "-B $(HOST_DIR)/opt/ext-toolchain"
option. This option add a new search path for binaries and object
files used implicitly.

Without -B clang fail to link due to missing crtbeging.o file and libgcc:
output/host/bin/aarch64-linux-gnu-ld: cannot find crtbegin.o: No such file or directory
output/host/bin/aarch64-linux-gnu-ld: cannot find -lgcc

Indeed, clang search path doesn't include the dafault cross-gcc's search paths:

$ output/host/bin/clang -print-search-dirs
programs: = output/host/bin:output/host/bin:/..//bin
libraries: = output/host/lib/clang/8.0.0:
             output/host/bin/../lib64:
             /lib/../lib64:
             /usr/lib/../lib64:
             output/host/bin/../lib:
             /lib:/usr/lib

Here is the same command for cross-gcc:

$ output/host/bin/aarch64-linux-gnu-gcc -print-search-dirs
install: output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/
programs: = output/host/opt/ext-toolchain/bin/../libexec/gcc/aarch64-linux-gnu/8.3.0/:
            output/host/opt/ext-toolchain/bin/../libexec/gcc/:
            output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/aarch64-linux-gnu/8.3.0/:
            output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/
libraries: = output/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/:
             output/host/opt/ext-toolchain/bin/../lib/gcc/:
             output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/aarch64-linux-gnu/8.3.0/:
             output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/:
             output/host/aarch64-buildroot-linux-gnu/sysroot/lib/aarch64-linux-gnu/8.3.0/:
             output/host/aarch64-buildroot-linux-gnu/sysroot/lib/../lib64/:
             output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/8.3.0/:
             output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/../lib64/:
             output/host/opt/ext-toolchain/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/:
             output/host/aarch64-buildroot-linux-gnu/sysroot/lib/:
             output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/

We can see that gcc default search path contains
"output/host/opt/ext-toolchain" directory where the external toolchain
has been extracted.

Since we want to use clang without additional option like -B,
patch clang in order to use GCC_INSTALL_PREFIX instead of
using automatic detection (which doesn't work for Buildroot).

We eventually want to relocate the Buildroot SDK containing the clang
cross-compiler, so we provide a relative path to GCC_INSTALL_PREFIX
in order to avoid to hardcode the path to the GCC toolchain.

Also the path between clang and the GCC external toolchain is not always
the same, we have the following case:

* Toolchain to be downloaded and installed
  The toolchain is extracted into $(HOST_DIR)/opt/ext-toolchain, so the
  path is "../opt/ext-toolchain".

* Pre-installed toolchain
  The toolchain is localed somewhere in the host filesystem and
  defined by the user using BR2_TOOLCHAIN_EXTERNAL_PATH.

So, set GCC_INSTALL_PREFIX using realpath:

-DGCC_INSTALL_PREFIX:PATH=`realpath --relative-to=$(HOST_DIR)/bin/ $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)`

When we use a Buildroot's internal toolchain, clang will find theses
crt*.o files and libgcc.

http://lists.busybox.net/pipermail/buildroot/2019-August/256204.html

Signed-off-by: Romain Naour <romain.naour@smile.fr>
Cc: Matthew Weber <matthew.weber@rockwellcollins.com>
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Tested-by: Matt Weber <matthew.weber@rockwellcollins.com>

---
Changes v1 -> v2
[Arnout
 - Can't dropped ":PATH" from "-DGCC_INSTALL_PREFIX:PATH=" as suggested,
   The string isn't set correctly and results in "cannot find crtbegin.o"
 - Attempting to post patch upstream
 - I did not address the relative vs absolute path comment. The
   current approach seemed correct per my understanding for handling
   the two toolchain install location cases
---
 ...hains-Gnu-Use-GCC_INSTALL_PREFIX-in-.patch | 78 +++++++++++++++++++
 package/clang/clang.mk                        |  7 ++
 2 files changed, 85 insertions(+)
 create mode 100644 package/clang/0001-lib-Driver-ToolChains-Gnu-Use-GCC_INSTALL_PREFIX-in-.patch

diff --git a/package/clang/0001-lib-Driver-ToolChains-Gnu-Use-GCC_INSTALL_PREFIX-in-.patch b/package/clang/0001-lib-Driver-ToolChains-Gnu-Use-GCC_INSTALL_PREFIX-in-.patch
new file mode 100644
index 0000000000..08371154d5
--- /dev/null
+++ b/package/clang/0001-lib-Driver-ToolChains-Gnu-Use-GCC_INSTALL_PREFIX-in-.patch
@@ -0,0 +1,78 @@
+From fe21cede3939a435d62efbd5799547fab6af1b0a Mon Sep 17 00:00:00 2001
+From: Romain Naour <romain.naour@smile.fr>
+Date: Mon, 5 Aug 2019 16:06:48 +0200
+Subject: [PATCH] lib/Driver/ToolChains/Gnu: Use GCC_INSTALL_PREFIX in the set
+ of prefixes for searching the gcc toolchain
+
+By default, the Gnu Toolchains driver is looking at the parent
+directory while looking for the gcc toolchain when clang is installed
+at "D.InstalledDir"
+
+But this doesn't work with Buildroot since the external
+toolchain is installed in host/opt/ext-toolchain and the sysroot is
+moved to host/<arch>-buildroot-linux-gnu/sysroot/ directory.
+
+We tried by setting GCC_INSTALL_PREFIX in clang.mk for host-clang
+but it doesn't work since we already provide a sysroot [1].
+
+Help the Gnu Toolchains driver by using GCC_INSTALL_PREFIX path.
+
+Since we want to be able to relocate the clang toolchain,
+allow to use a relative path with GCC_INSTALL_PREFIX.
+
+Buildroot will provide such relative path by using:
+HOST_CLANG_CONF_OPTS += -DGCC_INSTALL_PREFIX:PATH=`realpath --relative-to=$(HOST_DIR)/bin/ $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)`
+
+Doing so allow to use clang without providing additional search
+paths with -B option on the clang's command line.
+
+[1] https://reviews.llvm.org/D49244
+[2] http://lists.busybox.net/pipermail/buildroot/2019-August/256204.html
+
+Signed-off-by: Romain Naour <romain.naour@smile.fr>
+Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
+---
+Pending, access to llvm mailing lists to submit it is pending. They
+seem to be having issues with their listserv.
+---
+ lib/Driver/ToolChains/Gnu.cpp | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
+index 2ad45097dc..90d6b5b748 100644
+--- a/lib/Driver/ToolChains/Gnu.cpp
++++ b/lib/Driver/ToolChains/Gnu.cpp
+@@ -1725,6 +1725,8 @@ void Generic_GCC::GCCInstallationDetector::init(
+ 
+     Prefixes.push_back(GCCToolchainDir);
+   } else {
++    StringRef GccIinstallPrefix = GCC_INSTALL_PREFIX;
++
+     // If we have a SysRoot, try that first.
+     if (!D.SysRoot.empty()) {
+       Prefixes.push_back(D.SysRoot);
+@@ -1734,6 +1736,21 @@ void Generic_GCC::GCCInstallationDetector::init(
+     // Then look for gcc installed alongside clang.
+     Prefixes.push_back(D.InstalledDir + "/..");
+ 
++    // Use GCC_INSTALL_PREFIX if provided by the buildsystem.
++    if (!GccIinstallPrefix.empty())
++    {
++        if (llvm::sys::path::is_relative(GccIinstallPrefix))
++        {
++            // Use a relative path to gcc from clang install path.
++            Prefixes.push_back(D.InstalledDir + "/" + GccIinstallPrefix.str());
++        }
++        else
++        {
++            // Hardcode the absolute path provided by GCC_INSTALL_PREFIX.
++            Prefixes.push_back(GCC_INSTALL_PREFIX);
++        }
++    }
++
+     // Next, look for prefix(es) that correspond to distribution-supplied gcc
+     // installations.
+     if (D.SysRoot.empty()) {
+-- 
+2.20.1
+
diff --git a/package/clang/clang.mk b/package/clang/clang.mk
index d1667d79b6..95b4964be3 100644
--- a/package/clang/clang.mk
+++ b/package/clang/clang.mk
@@ -105,5 +105,12 @@ CLANG_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
 HOST_CLANG_CONF_OPTS += -DLLVM_DYLIB_COMPONENTS=all
 CLANG_CONF_OPTS += -DLLVM_DYLIB_COMPONENTS=all
 
+# Help host-clang to find our external toolchain, use a relative path from the clang
+# installation directory to the external toolchain installation directory in order to
+# not hardcode the toolchain absolute path.
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
+HOST_CLANG_CONF_OPTS += -DGCC_INSTALL_PREFIX:PATH=`realpath --relative-to=$(HOST_DIR)/bin/ $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)`
+endif
+
 $(eval $(cmake-package))
 $(eval $(host-cmake-package))
-- 
2.17.1

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

* [Buildroot] [PATCH v11 8/9] package/clang: install a toolchain-wrapper for the host clang cross-compiler
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
                   ` (5 preceding siblings ...)
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 7/9] package/clang: help host-clang to find our external toolchain Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 9/9] package/compiler-rt: runtime test use toolchain-wrapper Matt Weber
  7 siblings, 0 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

From: Romain Naour <romain.naour@smile.fr>

In order to use Clang as a host cross-compiler for Buildroot, we
need to provide at least the path to the sysroot (using
--sysroot) and some other compiler flags.

This series looks to reuse the toolchain wrapper for GCC since
Clang support most of the gcc flags used in the Buildroot's
toolchain wrapper. The only flag -mfused-madd (deprecated
since gcc 4.6) for mips is not supported by clang. Since
Clang require gcc >= 5.x this flag can never be used.

host-clang refers to an existing GCC-based toolchain (internal or
external) for libstdc++. However, a Buildroot external toolchain
gets a different BR_CROSS_PATH_SUFFIX. Therefore, we can't reuse the
toolchain-wrapper that gets built for the GCC-based toolchain, but
instead have to compile an additional clang-specific wrapper, called
toolchain-wrapper-clang.

After building the clang toolchain wrapper, create the symlinks needed
to force package infrastructure to use clang througt the wrapper.

Initially clang install the clang-8 binary and create all other symlinks:

 # clang -> clang-8
 # clang++ -> clang
 # clang-8
 # clang-cl -> clang
 # clang-cpp -> clang

Use a post install hook to rename the clang-8 binary to clang-8.br_real
and recreate all symlinks:

 # clang -> toolchain-wrapper-clang
 # clang++ -> toolchain-wrapper-clang
 # clang-8 -> toolchain-wrapper-clang
 # clang-8.br_real
 # clang++.br_real -> clang-8.br_real
 # clang.br_real -> clang-8.br_real
 # clang-cl -> toolchain-wrapper-clang
 # clang-cl.br_real -> clang-8.br_real
 # clang-cpp -> toolchain-wrapper-clang
 # clang-cpp.br_real -> clang-8.br_real

NOTE: *.br_real symlinks are needed as the wrapper references them

Use the previously introduced CLANG_VERSION_MAJOR variable to create
theses symlinks.

Set BR_CROSS_PATH_SUFFIX to ".br_real" as for the Buildroot's internal
GCC toolchain backend to find the "real" clang binary installed in
$(HOST_DIR)/bin.

Borrow TOOLCHAIN_WRAPPER_BUILD and TOOLCHAIN_WRAPPER_INSTALL to
build and install the specific clang toolchain wrapper.

Signed-off-by: Romain Naour <romain.naour@smile.fr>
Cc: Valentin Korenblit <valentinkorenblit@gmail.com>
Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>

---
Changes
v1 -> v2
[Arnout
 - Fixup commit description and clarified *.br_real
 - Simplified loop
---
 package/clang/clang.mk | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/package/clang/clang.mk b/package/clang/clang.mk
index 95b4964be3..3c75f8d6b1 100644
--- a/package/clang/clang.mk
+++ b/package/clang/clang.mk
@@ -112,5 +112,33 @@ ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
 HOST_CLANG_CONF_OPTS += -DGCC_INSTALL_PREFIX:PATH=`realpath --relative-to=$(HOST_DIR)/bin/ $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)`
 endif
 
+define HOST_CLANG_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
+	$(Q)cd $(HOST_DIR)/bin; \
+	rm -f clang-$(CLANG_VERSION_MAJOR).br_real; \
+	mv clang-$(CLANG_VERSION_MAJOR) clang-$(CLANG_VERSION_MAJOR).br_real; \
+	ln -sf toolchain-wrapper-clang clang-$(CLANG_VERSION_MAJOR); \
+	for i in clang clang++ clang-cl clang-cpp; do \
+		ln -snf toolchain-wrapper-clang $$i; \
+		ln -snf clang-$(CLANG_VERSION_MAJOR).br_real $$i.br_real; \
+	done
+endef
+
+define HOST_CLANG_TOOLCHAIN_WRAPPER_BUILD
+	$(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \
+		-s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \
+		toolchain/toolchain-wrapper.c \
+		-o $(@D)/toolchain-wrapper-clang
+endef
+
+define HOST_CLANG_TOOLCHAIN_WRAPPER_INSTALL
+	$(INSTALL) -D -m 0755 $(@D)/toolchain-wrapper-clang \
+		$(HOST_DIR)/bin/toolchain-wrapper-clang
+endef
+
+HOST_CLANG_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".br_real"'
+HOST_CLANG_POST_BUILD_HOOKS += HOST_CLANG_TOOLCHAIN_WRAPPER_BUILD
+HOST_CLANG_POST_INSTALL_HOOKS += HOST_CLANG_TOOLCHAIN_WRAPPER_INSTALL
+HOST_CLANG_POST_INSTALL_HOOKS += HOST_CLANG_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
+
 $(eval $(cmake-package))
 $(eval $(host-cmake-package))
-- 
2.17.1

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

* [Buildroot] [PATCH v11 9/9] package/compiler-rt: runtime test use toolchain-wrapper
  2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
                   ` (6 preceding siblings ...)
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 8/9] package/clang: install a toolchain-wrapper for the host clang cross-compiler Matt Weber
@ 2021-03-11 14:29 ` Matt Weber
  7 siblings, 0 replies; 14+ messages in thread
From: Matt Weber @ 2021-03-11 14:29 UTC (permalink / raw)
  To: buildroot

The toolchain wrapper for clang allows the build of the
libfuzzer package to not point at "-B $(HOST_DIR)/opt/ext-toolchain"
which prevents a build failure to link due to missing crtbeging.o
and libgcc.

Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
---
 .../clang-compiler-rt/package/libfuzzer/libfuzzer.mk            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk
index 6c6371bea7..0515b9da35 100644
--- a/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk
+++ b/support/testing/tests/package/br2-external/clang-compiler-rt/package/libfuzzer/libfuzzer.mk
@@ -12,7 +12,7 @@ LIBFUZZER_DEPENDENCIES = compiler-rt
 
 define LIBFUZZER_BUILD_CMDS
 	$(HOST_DIR)/bin/clang++ --sysroot=$(STAGING_DIR) \
-		-B $(HOST_DIR)/opt/ext-toolchain -fsanitize=address,fuzzer \
+		-fsanitize=address,fuzzer \
 		$(@D)/tutorial/libFuzzer/fuzz_me.cc \
 		-o $(@D)/fuzz_me
 endef
-- 
2.17.1

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

* [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0
  2021-03-11 14:29 ` [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0 Matt Weber
@ 2021-03-11 14:35   ` Matthew Weber
  2021-03-11 19:37     ` Matthew Weber
  0 siblings, 1 reply; 14+ messages in thread
From: Matthew Weber @ 2021-03-11 14:35 UTC (permalink / raw)
  To: buildroot

Romain,

On Thu, Mar 11, 2021 at 8:29 AM Matt Weber
<matthew.weber@rockwellcollins.com> wrote:
>
>  * Converts to the cmake pkg type
>  * Updates download site
>  * Adds a crosscompile fixups patch
>    * Allow prepare_builtins utility to be directly called
>      (it isn't installed into the path when cross compiling)
>    * Fix file_find() for root search limitation
>

Do you have a way to runtime test libclc?  I've verified mesa3d and
the library all built correctly on x86 and ARM64


> Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
> ---
>  .../0001-support-out-of-tree-build.patch      | 71 +++++++++++++++++++
>  package/libclc/libclc.hash                    |  2 +-
>  package/libclc/libclc.mk                      | 42 +++--------
>  3 files changed, 83 insertions(+), 32 deletions(-)
>  create mode 100644 package/libclc/0001-support-out-of-tree-build.patch
>
> diff --git a/package/libclc/0001-support-out-of-tree-build.patch b/package/libclc/0001-support-out-of-tree-build.patch
> new file mode 100644
> index 0000000000..918474c433
> --- /dev/null
> +++ b/package/libclc/0001-support-out-of-tree-build.patch
> @@ -0,0 +1,71 @@
> +From 495491e9d53bfb184c15753b5187e4bb55b19511 Mon Sep 17 00:00:00 2001
> +From: Matt Weber <matthew.weber@rockwellcollins.com>
> +Date: Tue, 9 Mar 2021 15:55:17 -0600
> +Subject: [PATCH] support out of tree build
> +
> +(1) The package has a prepare_builtins tool which is built
> +but not placed in the path for later use in the build. This
> +fix allows the later build steps to use the binary in-place.
> +
> +(2) With cmake, find_file() when used for non-host builds is
> +limited by CMAKE_FIND_ROOT_PATH* scope.
> +
> +In $(HOST_DIR)/share/buildroot/toolchainfile.cmake we set the
> +following target settings for CMAKE_FIND_ROOT_PATH* which
> +limit the scope.
> +set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/aarch64-buildroot-linux-gnu/sysroot")
> +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
> +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
> +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
> +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
> +
> +
> +Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
> +---
> + CMakeLists.txt                          | 2 +-
> + cmake/CMakeDetermineCLCCompiler.cmake   | 4 ++++
> + cmake/CMakeDetermineLLAsmCompiler.cmake | 4 ++++
> + 3 files changed, 9 insertions(+), 1 deletion(-)
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index 9472f19..a784519 100644
> +--- a/CMakeLists.txt
> ++++ b/CMakeLists.txt
> +@@ -279,7 +279,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
> +
> +               # Add prepare target
> +               add_custom_command( OUTPUT "${obj_suffix}"
> +-                                  COMMAND prepare_builtins -o
> ++                                  COMMAND ./prepare_builtins -o
> +                                   "${obj_suffix}"
> +                                   "builtins.opt.${obj_suffix}"
> +                                   DEPENDS "opt.${obj_suffix}"
> +diff --git a/cmake/CMakeDetermineCLCCompiler.cmake b/cmake/CMakeDetermineCLCCompiler.cmake
> +index 94d85d9..5de6a48 100644
> +--- a/cmake/CMakeDetermineCLCCompiler.cmake
> ++++ b/cmake/CMakeDetermineCLCCompiler.cmake
> +@@ -12,7 +12,7 @@ mark_as_advanced(CMAKE_CLC_ARCHIVE)
> +
> + set(CMAKE_CLC_COMPILER_ENV_VAR "CLC_COMPILER")
> + set(CMAKE_CLC_ARCHIVE_ENV_VAR "CLC_LINKER")
> +-find_file(clc_comp_in CMakeCLCCompiler.cmake.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
> ++set(clc_comp_in "${CMAKE_MODULE_PATH}/CMakeCLCCompiler.cmake.in" )
> + # configure all variables set in this file
> + configure_file(${clc_comp_in} ${CMAKE_PLATFORM_INFO_DIR}/CMakeCLCCompiler.cmake @ONLY)
> + mark_as_advanced(clc_comp_in)
> +diff --git a/cmake/CMakeDetermineLLAsmCompiler.cmake b/cmake/CMakeDetermineLLAsmCompiler.cmake
> +index 1c424c7..dd3bfb6 100644
> +--- a/cmake/CMakeDetermineLLAsmCompiler.cmake
> ++++ b/cmake/CMakeDetermineLLAsmCompiler.cmake
> +@@ -18,7 +18,7 @@ mark_as_advanced(CMAKE_LLAsm_ARCHIVE)
> + set(CMAKE_LLAsm_PREPROCESSOR_ENV_VAR "LL_PREPROCESSOR")
> + set(CMAKE_LLAsm_COMPILER_ENV_VAR "LL_ASSEMBLER")
> + set(CMAKE_LLAsm_ARCHIVE_ENV_VAR "LL_LINKER")
> +-find_file(ll_comp_in CMakeLLAsmCompiler.cmake.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
> ++set(ll_comp_in "${CMAKE_MODULE_PATH}/CMakeLLAsmCompiler.cmake.in" )
> + # configure all variables set in this file
> + configure_file(${ll_comp_in} ${CMAKE_PLATFORM_INFO_DIR}/CMakeLLAsmCompiler.cmake @ONLY)
> + mark_as_advanced(ll_comp_in)
> +--
> +2.17.1
> +
> diff --git a/package/libclc/libclc.hash b/package/libclc/libclc.hash
> index 2af64bc8e8..c670d92ed3 100644
> --- a/package/libclc/libclc.hash
> +++ b/package/libclc/libclc.hash
> @@ -1,3 +1,3 @@
>  # locally calculated
> -sha256  54d7ae523aabf68d533011739d6c01546cae0c294442d0f44fd657c046cb707d  libclc-d1cbc92e2ceee59963f5c3a576382e5bba31f060-br1.tar.gz
> +sha256  198dc45cdcc426c7968b9628a55062162ea338931157a18ddefb47188d119e1d  libclc-11.1.0.src.tar.xz
>  sha256  3c536c052db9afd997809e38785c9f2a9e54e2892330fa7c5b438e18a7413479  LICENSE.TXT
> diff --git a/package/libclc/libclc.mk b/package/libclc/libclc.mk
> index 6fe8e10a77..d460adcf41 100644
> --- a/package/libclc/libclc.mk
> +++ b/package/libclc/libclc.mk
> @@ -4,43 +4,23 @@
>  #
>  ################################################################################
>
> -# Use the latest commit from release_90 branch.
> -LIBCLC_VERSION = d1cbc92e2ceee59963f5c3a576382e5bba31f060
> -LIBCLC_SITE = https://github.com/llvm-mirror/libclc
> -LIBCLC_SITE_METHOD = git
> +LIBCLC_VERSION = 11.1.0
> +LIBCLC_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCLC_VERSION)
> +LIBCLC_SOURCE = libclc-$(LIBCLC_VERSION).src.tar.xz
>  LIBCLC_LICENSE = Apache-2.0 with exceptions or MIT
>  LIBCLC_LICENSE_FILES = LICENSE.TXT
>
>  LIBCLC_DEPENDENCIES = host-clang host-llvm
>  LIBCLC_INSTALL_STAGING = YES
>
> -# C++ compiler is used to build a small tool (prepare-builtins) for the host.
> -# It must be built with the C++ compiler from the host.
> +# CMAKE_*_COMPILER_FORCED=ON skips testing the tools and assumes
> +# llvm-config provided values
>  #
> -# The headers are installed in /usr/share and not /usr/include,
> -# because they are needed at runtime on the target to build the OpenCL
> -# kernels.
> +# CMAKE_CXX_COMPILER has to be set to the host compiler to build a host
> +# 'prepare_builtins' tool used during the build process
>  LIBCLC_CONF_OPTS = \
> -       --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> -       --prefix=/usr \
> -       --includedir=/usr/share \
> -       --pkgconfigdir=/usr/lib/pkgconfig \
> -       --with-cxx-compiler=$(HOSTCXX_NOCCACHE)
> +       -DCMAKE_CLC_COMPILER_FORCED=ON \
> +       -DCMAKE_LLAsm_COMPILER_FORCED=ON \
> +       -DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)"
>
> -define LIBCLC_CONFIGURE_CMDS
> -       (cd $(@D); $(TARGET_CONFIGURE_OPTS) ./configure.py $(LIBCLC_CONF_OPTS))
> -endef
> -
> -define LIBCLC_BUILD_CMDS
> -       $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
> -endef
> -
> -define LIBCLC_INSTALL_TARGET_CMDS
> -       $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
> -endef
> -
> -define LIBCLC_INSTALL_STAGING_CMDS
> -       $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
> -endef
> -
> -$(eval $(generic-package))
> +$(eval $(cmake-package))
> --
> 2.17.1
>

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

* [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0
  2021-03-11 14:35   ` Matthew Weber
@ 2021-03-11 19:37     ` Matthew Weber
  2021-05-18 21:04       ` Arnout Vandecappelle
  0 siblings, 1 reply; 14+ messages in thread
From: Matthew Weber @ 2021-03-11 19:37 UTC (permalink / raw)
  To: buildroot

" Romain,

On Thu, Mar 11, 2021 at 8:35 AM Matthew Weber
<matthew.weber@rockwellcollins.com> wrote:
>
> Romain,
>
> On Thu, Mar 11, 2021 at 8:29 AM Matt Weber
> <matthew.weber@rockwellcollins.com> wrote:
> >
> >  * Converts to the cmake pkg type
> >  * Updates download site
> >  * Adds a crosscompile fixups patch
> >    * Allow prepare_builtins utility to be directly called
> >      (it isn't installed into the path when cross compiling)
> >    * Fix file_find() for root search limitation
> >
>
> Do you have a way to runtime test libclc?  I've verified mesa3d and
> the library all built correctly on x86 and ARM64
>
>
> > Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
> > ---
> >  .../0001-support-out-of-tree-build.patch      | 71 +++++++++++++++++++
> >  package/libclc/libclc.hash                    |  2 +-
> >  package/libclc/libclc.mk                      | 42 +++--------
> >  3 files changed, 83 insertions(+), 32 deletions(-)
> >  create mode 100644 package/libclc/0001-support-out-of-tree-build.patch
> >
> > diff --git a/package/libclc/0001-support-out-of-tree-build.patch b/package/libclc/0001-support-out-of-tree-build.patch
> > new file mode 100644
> > index 0000000000..918474c433
> > --- /dev/null
> > +++ b/package/libclc/0001-support-out-of-tree-build.patch
> > @@ -0,0 +1,71 @@
> > +From 495491e9d53bfb184c15753b5187e4bb55b19511 Mon Sep 17 00:00:00 2001
> > +From: Matt Weber <matthew.weber@rockwellcollins.com>
> > +Date: Tue, 9 Mar 2021 15:55:17 -0600
> > +Subject: [PATCH] support out of tree build
> > +
> > +(1) The package has a prepare_builtins tool which is built
> > +but not placed in the path for later use in the build. This
> > +fix allows the later build steps to use the binary in-place.
> > +
> > +(2) With cmake, find_file() when used for non-host builds is
> > +limited by CMAKE_FIND_ROOT_PATH* scope.
> > +
> > +In $(HOST_DIR)/share/buildroot/toolchainfile.cmake we set the
> > +following target settings for CMAKE_FIND_ROOT_PATH* which
> > +limit the scope.
> > +set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/aarch64-buildroot-linux-gnu/sysroot")
> > +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
> > +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
> > +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
> > +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
> > +
> > +
> > +Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
> > +---
> > + CMakeLists.txt                          | 2 +-
> > + cmake/CMakeDetermineCLCCompiler.cmake   | 4 ++++
> > + cmake/CMakeDetermineLLAsmCompiler.cmake | 4 ++++
> > + 3 files changed, 9 insertions(+), 1 deletion(-)
> > +
> > +diff --git a/CMakeLists.txt b/CMakeLists.txt
> > +index 9472f19..a784519 100644
> > +--- a/CMakeLists.txt
> > ++++ b/CMakeLists.txt
> > +@@ -279,7 +279,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
> > +
> > +               # Add prepare target
> > +               add_custom_command( OUTPUT "${obj_suffix}"
> > +-                                  COMMAND prepare_builtins -o
> > ++                                  COMMAND ./prepare_builtins -o
> > +                                   "${obj_suffix}"
> > +                                   "builtins.opt.${obj_suffix}"
> > +                                   DEPENDS "opt.${obj_suffix}"
> > +diff --git a/cmake/CMakeDetermineCLCCompiler.cmake b/cmake/CMakeDetermineCLCCompiler.cmake
> > +index 94d85d9..5de6a48 100644
> > +--- a/cmake/CMakeDetermineCLCCompiler.cmake
> > ++++ b/cmake/CMakeDetermineCLCCompiler.cmake
> > +@@ -12,7 +12,7 @@ mark_as_advanced(CMAKE_CLC_ARCHIVE)
> > +
> > + set(CMAKE_CLC_COMPILER_ENV_VAR "CLC_COMPILER")
> > + set(CMAKE_CLC_ARCHIVE_ENV_VAR "CLC_LINKER")
> > +-find_file(clc_comp_in CMakeCLCCompiler.cmake.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
> > ++set(clc_comp_in "${CMAKE_MODULE_PATH}/CMakeCLCCompiler.cmake.in" )
> > + # configure all variables set in this file
> > + configure_file(${clc_comp_in} ${CMAKE_PLATFORM_INFO_DIR}/CMakeCLCCompiler.cmake @ONLY)
> > + mark_as_advanced(clc_comp_in)
> > +diff --git a/cmake/CMakeDetermineLLAsmCompiler.cmake b/cmake/CMakeDetermineLLAsmCompiler.cmake
> > +index 1c424c7..dd3bfb6 100644
> > +--- a/cmake/CMakeDetermineLLAsmCompiler.cmake
> > ++++ b/cmake/CMakeDetermineLLAsmCompiler.cmake
> > +@@ -18,7 +18,7 @@ mark_as_advanced(CMAKE_LLAsm_ARCHIVE)
> > + set(CMAKE_LLAsm_PREPROCESSOR_ENV_VAR "LL_PREPROCESSOR")
> > + set(CMAKE_LLAsm_COMPILER_ENV_VAR "LL_ASSEMBLER")
> > + set(CMAKE_LLAsm_ARCHIVE_ENV_VAR "LL_LINKER")
> > +-find_file(ll_comp_in CMakeLLAsmCompiler.cmake.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
> > ++set(ll_comp_in "${CMAKE_MODULE_PATH}/CMakeLLAsmCompiler.cmake.in" )
> > + # configure all variables set in this file
> > + configure_file(${ll_comp_in} ${CMAKE_PLATFORM_INFO_DIR}/CMakeLLAsmCompiler.cmake @ONLY)
> > + mark_as_advanced(ll_comp_in)
> > +--
> > +2.17.1
> > +
> > diff --git a/package/libclc/libclc.hash b/package/libclc/libclc.hash
> > index 2af64bc8e8..c670d92ed3 100644
> > --- a/package/libclc/libclc.hash
> > +++ b/package/libclc/libclc.hash
> > @@ -1,3 +1,3 @@
> >  # locally calculated
> > -sha256  54d7ae523aabf68d533011739d6c01546cae0c294442d0f44fd657c046cb707d  libclc-d1cbc92e2ceee59963f5c3a576382e5bba31f060-br1.tar.gz
> > +sha256  198dc45cdcc426c7968b9628a55062162ea338931157a18ddefb47188d119e1d  libclc-11.1.0.src.tar.xz
> >  sha256  3c536c052db9afd997809e38785c9f2a9e54e2892330fa7c5b438e18a7413479  LICENSE.TXT
> > diff --git a/package/libclc/libclc.mk b/package/libclc/libclc.mk
> > index 6fe8e10a77..d460adcf41 100644
> > --- a/package/libclc/libclc.mk
> > +++ b/package/libclc/libclc.mk
> > @@ -4,43 +4,23 @@
> >  #
> >  ################################################################################
> >
> > -# Use the latest commit from release_90 branch.
> > -LIBCLC_VERSION = d1cbc92e2ceee59963f5c3a576382e5bba31f060
> > -LIBCLC_SITE = https://github.com/llvm-mirror/libclc
> > -LIBCLC_SITE_METHOD = git
> > +LIBCLC_VERSION = 11.1.0
> > +LIBCLC_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCLC_VERSION)
> > +LIBCLC_SOURCE = libclc-$(LIBCLC_VERSION).src.tar.xz
> >  LIBCLC_LICENSE = Apache-2.0 with exceptions or MIT
> >  LIBCLC_LICENSE_FILES = LICENSE.TXT
> >
> >  LIBCLC_DEPENDENCIES = host-clang host-llvm
> >  LIBCLC_INSTALL_STAGING = YES
> >
> > -# C++ compiler is used to build a small tool (prepare-builtins) for the host.
> > -# It must be built with the C++ compiler from the host.
> > +# CMAKE_*_COMPILER_FORCED=ON skips testing the tools and assumes
> > +# llvm-config provided values
> >  #
> > -# The headers are installed in /usr/share and not /usr/include,
> > -# because they are needed at runtime on the target to build the OpenCL
> > -# kernels.
> > +# CMAKE_CXX_COMPILER has to be set to the host compiler to build a host
> > +# 'prepare_builtins' tool used during the build process
> >  LIBCLC_CONF_OPTS = \
> > -       --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> > -       --prefix=/usr \
> > -       --includedir=/usr/share \
> > -       --pkgconfigdir=/usr/lib/pkgconfig \
> > -       --with-cxx-compiler=$(HOSTCXX_NOCCACHE)
> > +       -DCMAKE_CLC_COMPILER_FORCED=ON \
> > +       -DCMAKE_LLAsm_COMPILER_FORCED=ON \
> > +       -DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)"

Looks like I have a couple of bugs (I didn't have opencl checked in menuconfig)

1) mesa3d.mk needs MESA3D_MESON_EXTRA_BINARIES +=
llvm-config='$(STAGING_DIR)/bin/llvm-config' updated to point to the
HOST_DIR llvm-config because it needs to be able to execute the tool.
However this doesn't work since then you get the
"host/lib/libLLVM-11.so when searching for -lLLVM-11 " error which
makes sense since that's the host llvm-config we pointed at.....
Unsure how to solve this one and we don't notice it in x86 builds.
When you enable the AMD Radeon to build for aarch64 you can cause this
error.

2) mesa3d doesn't quite build (pkgconfig can't find libclc).  I didn't
catch that CMAKE_INSTALL_PREFIX is getting ignored (we set it in the
pkg-cmake.mk infra) so the libclc.pc is getting installed in
$HOST_DIR/usr/local/share vs $HOST_DIR/usr/share .  I haven't been
able to figure out why the value doesn't take hold (ie after the
configuration step libclc-11.1.0/CMakeCache.txt still shows /usr/local
unless I force set the CMAKE_INSTALL_PREFIX value in
libclc-11.1.0/CMakeList.txt before project().


Matt

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

* [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0
  2021-03-11 19:37     ` Matthew Weber
@ 2021-05-18 21:04       ` Arnout Vandecappelle
  2021-05-19  1:33         ` [Buildroot] [External] " Weber, Matthew L Collins
  2022-03-22 23:25         ` [Buildroot] " James Hilliard
  0 siblings, 2 replies; 14+ messages in thread
From: Arnout Vandecappelle @ 2021-05-18 21:04 UTC (permalink / raw)
  To: buildroot

 Hi Matt,

 I was going to apply this series to next...

On 11/03/2021 20:37, Matthew Weber via buildroot wrote:
[snip]
>>> -# C++ compiler is used to build a small tool (prepare-builtins) for the host.
>>> -# It must be built with the C++ compiler from the host.
>>> +# CMAKE_*_COMPILER_FORCED=ON skips testing the tools and assumes
>>> +# llvm-config provided values
>>>  #
>>> -# The headers are installed in /usr/share and not /usr/include,
>>> -# because they are needed at runtime on the target to build the OpenCL
>>> -# kernels.
>>> +# CMAKE_CXX_COMPILER has to be set to the host compiler to build a host
>>> +# 'prepare_builtins' tool used during the build process
>>>  LIBCLC_CONF_OPTS = \
>>> -       --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
>>> -       --prefix=/usr \
>>> -       --includedir=/usr/share \
>>> -       --pkgconfigdir=/usr/lib/pkgconfig \
>>> -       --with-cxx-compiler=$(HOSTCXX_NOCCACHE)
>>> +       -DCMAKE_CLC_COMPILER_FORCED=ON \
>>> +       -DCMAKE_LLAsm_COMPILER_FORCED=ON \
>>> +       -DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)"
> 
> Looks like I have a couple of bugs (I didn't have opencl checked in menuconfig)

... but then I saw this. So I didn't. Instead, I've marked the series as Changes
Requested. If you think it should be applied after all, please repost (or just
update patchwork if unchanged).

 Oh, and 12.0.0 has been released now...

> 
> 1) mesa3d.mk needs MESA3D_MESON_EXTRA_BINARIES +=
> llvm-config='$(STAGING_DIR)/bin/llvm-config' updated to point to the

 Normally, the foo-config programs are script, so it's OK to use the one in
staging. If it's an actual binary, we have to somehow patch it so it has target
config but compiles for host.

 I'd expect llvm and related to be cross-compile friendly though...

> HOST_DIR llvm-config because it needs to be able to execute the tool.
> However this doesn't work since then you get the
> "host/lib/libLLVM-11.so when searching for -lLLVM-11 " error which
> makes sense since that's the host llvm-config we pointed at.....
> Unsure how to solve this one and we don't notice it in x86 builds.
> When you enable the AMD Radeon to build for aarch64 you can cause this
> error.
> 
> 2) mesa3d doesn't quite build (pkgconfig can't find libclc).  I didn't
> catch that CMAKE_INSTALL_PREFIX is getting ignored (we set it in the
> pkg-cmake.mk infra) so the libclc.pc is getting installed in
> $HOST_DIR/usr/local/share vs $HOST_DIR/usr/share .  I haven't been
> able to figure out why the value doesn't take hold (ie after the
> configuration step libclc-11.1.0/CMakeCache.txt still shows /usr/local
> unless I force set the CMAKE_INSTALL_PREFIX value in
> libclc-11.1.0/CMakeList.txt before project().

 That *is* weird...

 Regards,
 Arnout

> 
> 
> Matt
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
> 

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

* [Buildroot] [External] Re: [PATCH v11 4/9] package/libclc: bump version to 11.1.0
  2021-05-18 21:04       ` Arnout Vandecappelle
@ 2021-05-19  1:33         ` Weber, Matthew L Collins
  2022-03-22 23:25         ` [Buildroot] " James Hilliard
  1 sibling, 0 replies; 14+ messages in thread
From: Weber, Matthew L Collins @ 2021-05-19  1:33 UTC (permalink / raw)
  To: buildroot

Arnout,

> -----Original Message-----
> From: Arnout Vandecappelle <arnout@mind.be>
> Sent: Tuesday, May 18, 2021 4:04 PM
> To: Weber, Matthew L Collins <Matthew.Weber@collins.com>; buildroot
> <buildroot@buildroot.org>
> Cc: Joseph Kogut <joseph.kogut@gmail.com>; Romain Naour
> <romain.naour@gmail.com>; Samuel Martin <s.martin49@gmail.com>;
> Thomas Petazzoni <thomas.petazzoni@bootlin.com>; Valentin Korenblit
> <valentinkorenblit@gmail.com>
> Subject: [External] Re: [Buildroot] [PATCH v11 4/9] package/libclc: bump
> version to 11.1.0
> 
>  Hi Matt,
> 
>  I was going to apply this series to next...
> 
> On 11/03/2021 20:37, Matthew Weber via buildroot wrote:
> [snip]
> >>> -# C++ compiler is used to build a small tool (prepare-builtins) for the
> host.
> >>> -# It must be built with the C++ compiler from the host.
> >>> +# CMAKE_*_COMPILER_FORCED=ON skips testing the tools and
> assumes #
> >>> +llvm-config provided values
> >>>  #
> >>> -# The headers are installed in /usr/share and not /usr/include, -#
> >>> because they are needed at runtime on the target to build the OpenCL
> >>> -# kernels.
> >>> +# CMAKE_CXX_COMPILER has to be set to the host compiler to build a
> >>> +host # 'prepare_builtins' tool used during the build process
> >>>  LIBCLC_CONF_OPTS = \
> >>> -       --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> >>> -       --prefix=/usr \
> >>> -       --includedir=/usr/share \
> >>> -       --pkgconfigdir=/usr/lib/pkgconfig \
> >>> -       --with-cxx-compiler=$(HOSTCXX_NOCCACHE)
> >>> +       -DCMAKE_CLC_COMPILER_FORCED=ON \
> >>> +       -DCMAKE_LLAsm_COMPILER_FORCED=ON \
> >>> +       -DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)"
> >
> > Looks like I have a couple of bugs (I didn't have opencl checked in
> > menuconfig)
> 
> ... but then I saw this. So I didn't. Instead, I've marked the series as Changes
> Requested. If you think it should be applied after all, please repost (or just
> update patchwork if unchanged).

Thx, this is definitely still broken.  I'll update the version as well when I take another look.

-Matt

> 
>  Oh, and 12.0.0 has been released now...
> 
> >
> > 1) mesa3d.mk needs MESA3D_MESON_EXTRA_BINARIES +=
> > llvm-config='$(STAGING_DIR)/bin/llvm-config' updated to point to the
> 
>  Normally, the foo-config programs are script, so it's OK to use the one in
> staging. If it's an actual binary, we have to somehow patch it so it has target
> config but compiles for host.
> 
>  I'd expect llvm and related to be cross-compile friendly though...
> 
> > HOST_DIR llvm-config because it needs to be able to execute the tool.
> > However this doesn't work since then you get the
> > "host/lib/libLLVM-11.so when searching for -lLLVM-11 " error which
> > makes sense since that's the host llvm-config we pointed at.....
> > Unsure how to solve this one and we don't notice it in x86 builds.
> > When you enable the AMD Radeon to build for aarch64 you can cause this
> > error.
> >
> > 2) mesa3d doesn't quite build (pkgconfig can't find libclc).  I didn't
> > catch that CMAKE_INSTALL_PREFIX is getting ignored (we set it in the
> > pkg-cmake.mk infra) so the libclc.pc is getting installed in
> > $HOST_DIR/usr/local/share vs $HOST_DIR/usr/share .  I haven't been
> > able to figure out why the value doesn't take hold (ie after the
> > configuration step libclc-11.1.0/CMakeCache.txt still shows /usr/local
> > unless I force set the CMAKE_INSTALL_PREFIX value in
> > libclc-11.1.0/CMakeList.txt before project().
> 
>  That *is* weird...
> 
>  Regards,
>  Arnout
> 
> >
> >
> > Matt
> > _______________________________________________
> > buildroot mailing list
> > buildroot at busybox.net
> > https://urldefense.com/v3/__http://lists.busybox.net/mailman/listinfo/
> > buildroot__;!!MvWE!SQZRb-
> v4QExXQlkcTN3XlQyQjWlvHZdLk91QeKU2DXoT1xjmvjZ
> > TjEB3aW0gMBkR77hW$
> >

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

* Re: [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0
  2021-05-18 21:04       ` Arnout Vandecappelle
  2021-05-19  1:33         ` [Buildroot] [External] " Weber, Matthew L Collins
@ 2022-03-22 23:25         ` James Hilliard
  1 sibling, 0 replies; 14+ messages in thread
From: James Hilliard @ 2022-03-22 23:25 UTC (permalink / raw)
  To: Arnout Vandecappelle
  Cc: Joseph Kogut, Samuel Martin, Thomas Petazzoni, buildroot,
	Romain Naour, Matthew Weber, Valentin Korenblit

On Tue, May 18, 2021 at 3:04 PM Arnout Vandecappelle <arnout@mind.be> wrote:
>
>  Hi Matt,
>
>  I was going to apply this series to next...
>
> On 11/03/2021 20:37, Matthew Weber via buildroot wrote:
> [snip]
> >>> -# C++ compiler is used to build a small tool (prepare-builtins) for the host.
> >>> -# It must be built with the C++ compiler from the host.
> >>> +# CMAKE_*_COMPILER_FORCED=ON skips testing the tools and assumes
> >>> +# llvm-config provided values
> >>>  #
> >>> -# The headers are installed in /usr/share and not /usr/include,
> >>> -# because they are needed at runtime on the target to build the OpenCL
> >>> -# kernels.
> >>> +# CMAKE_CXX_COMPILER has to be set to the host compiler to build a host
> >>> +# 'prepare_builtins' tool used during the build process
> >>>  LIBCLC_CONF_OPTS = \
> >>> -       --with-llvm-config=$(HOST_DIR)/usr/bin/llvm-config \
> >>> -       --prefix=/usr \
> >>> -       --includedir=/usr/share \
> >>> -       --pkgconfigdir=/usr/lib/pkgconfig \
> >>> -       --with-cxx-compiler=$(HOSTCXX_NOCCACHE)
> >>> +       -DCMAKE_CLC_COMPILER_FORCED=ON \
> >>> +       -DCMAKE_LLAsm_COMPILER_FORCED=ON \
> >>> +       -DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)"
> >
> > Looks like I have a couple of bugs (I didn't have opencl checked in menuconfig)
>
> ... but then I saw this. So I didn't. Instead, I've marked the series as Changes
> Requested. If you think it should be applied after all, please repost (or just
> update patchwork if unchanged).
>
>  Oh, and 12.0.0 has been released now...
>
> >
> > 1) mesa3d.mk needs MESA3D_MESON_EXTRA_BINARIES +=
> > llvm-config='$(STAGING_DIR)/bin/llvm-config' updated to point to the
>
>  Normally, the foo-config programs are script, so it's OK to use the one in
> staging. If it's an actual binary, we have to somehow patch it so it has target
> config but compiles for host.
>
>  I'd expect llvm and related to be cross-compile friendly though...
>
> > HOST_DIR llvm-config because it needs to be able to execute the tool.
> > However this doesn't work since then you get the
> > "host/lib/libLLVM-11.so when searching for -lLLVM-11 " error which
> > makes sense since that's the host llvm-config we pointed at.....
> > Unsure how to solve this one and we don't notice it in x86 builds.
> > When you enable the AMD Radeon to build for aarch64 you can cause this
> > error.
> >
> > 2) mesa3d doesn't quite build (pkgconfig can't find libclc).  I didn't
> > catch that CMAKE_INSTALL_PREFIX is getting ignored (we set it in the
> > pkg-cmake.mk infra) so the libclc.pc is getting installed in
> > $HOST_DIR/usr/local/share vs $HOST_DIR/usr/share .  I haven't been
> > able to figure out why the value doesn't take hold (ie after the
> > configuration step libclc-11.1.0/CMakeCache.txt still shows /usr/local
> > unless I force set the CMAKE_INSTALL_PREFIX value in
> > libclc-11.1.0/CMakeList.txt before project().
>
>  That *is* weird...

This should fix the CMAKE_INSTALL_PREFIX issue:
https://patchwork.ozlabs.org/project/buildroot/patch/20220322232224.2842266-5-james.hilliard1@gmail.com/

>
>  Regards,
>  Arnout
>
> >
> >
> > Matt
> > _______________________________________________
> > buildroot mailing list
> > buildroot@busybox.net
> > http://lists.busybox.net/mailman/listinfo/buildroot
> >
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2022-03-22 23:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 14:29 [Buildroot] [PATCH v11 1/9] package/llvm: bump to version 11.1.0 Matt Weber
2021-03-11 14:29 ` [Buildroot] [PATCH v11 2/9] package/clang: " Matt Weber
2021-03-11 14:29 ` [Buildroot] [PATCH v11 3/9] package/lld: " Matt Weber
2021-03-11 14:29 ` [Buildroot] [PATCH v11 4/9] package/libclc: bump version to 11.1.0 Matt Weber
2021-03-11 14:35   ` Matthew Weber
2021-03-11 19:37     ` Matthew Weber
2021-05-18 21:04       ` Arnout Vandecappelle
2021-05-19  1:33         ` [Buildroot] [External] " Weber, Matthew L Collins
2022-03-22 23:25         ` [Buildroot] " James Hilliard
2021-03-11 14:29 ` [Buildroot] [PATCH v11 5/9] package/compiler-rt: new package Matt Weber
2021-03-11 14:29 ` [Buildroot] [PATCH v11 6/9] testing/tests: CLANG compiler-rt runtime test Matt Weber
2021-03-11 14:29 ` [Buildroot] [PATCH v11 7/9] package/clang: help host-clang to find our external toolchain Matt Weber
2021-03-11 14:29 ` [Buildroot] [PATCH v11 8/9] package/clang: install a toolchain-wrapper for the host clang cross-compiler Matt Weber
2021-03-11 14:29 ` [Buildroot] [PATCH v11 9/9] package/compiler-rt: runtime test use toolchain-wrapper Matt Weber

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.