Skip to contentSkip to conversation

package/pkg-cmake: allow overriding toolchain

PATCH In review Alsey Coleman Miller 3 participants 11 messages Mar 29, 2022 – Feb 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 package/pkg-cmake: allow overriding toolchain

---
 package/pkg-cmake.mk | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +24 -1
index 3b1db35fb6..9b36ee2b47 100644
@@ -57,7 +57,7 @@ $(2)_INSTALL_STAGING_OPTS	?= DESTDIR=$$(STAGING_DIR) install/fast
 $(2)_INSTALL_TARGET_OPTS	?= DESTDIR=$$(TARGET_DIR) install/fast
 
 $(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
-
+$(3)_SUPPORTS_CMAKE_TOOLCHAIN ?= YES
 
 ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
 $(2)_BUILDDIR			= $$($(2)_SRCDIR)
@@ -82,6 +82,7 @@ ifeq ($(4),target)
 #   documented as a standard CMake variable. If a package supports it,
 #   it must handle it explicitly.
 #
+ifeq ($(3)_SUPPORTS_CMAKE_TOOLCHAIN),YES)
 define $(2)_CONFIGURE_CMDS
 	(mkdir -p $$($$(PKG)_BUILDDIR) && \
 	cd $$($$(PKG)_BUILDDIR) && \
@@ -104,6 +105,28 @@ define $(2)_CONFIGURE_CMDS
 	)
 endef
 else
+define $(2)_CONFIGURE_CMDS
+	(mkdir -p $$($$(PKG)_BUILDDIR) && \
+	cd $$($$(PKG)_BUILDDIR) && \
+	rm -f CMakeCache.txt && \
+	PATH=$$(BR_PATH) \
+	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+		-DCMAKE_INSTALL_PREFIX="/usr" \
+		-DCMAKE_COLOR_MAKEFILE=OFF \
+		-DBUILD_DOC=OFF \
+		-DBUILD_DOCS=OFF \
+		-DBUILD_EXAMPLE=OFF \
+		-DBUILD_EXAMPLES=OFF \
+		-DBUILD_TEST=OFF \
+		-DBUILD_TESTS=OFF \
+		-DBUILD_TESTING=OFF \
+		-DBUILD_SHARED_LIBS=$$(if $$(BR2_STATIC_LIBS),OFF,ON) \
+		$$(CMAKE_QUIET) \
+		$$($$(PKG)_CONF_OPTS) \
+	)
+endef
+endif
+else
 
 # Configure package for host
 define $(2)_CONFIGURE_CMDS
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/4 package/libdispatch: add libdispatch package

---
 package/Config.in                    |  1 +
 package/libdispatch/Config.in        | 43 ++++++++++++++++++++++
 package/libdispatch/libdispatch.hash |  1 +
 package/libdispatch/libdispatch.mk   | 53 ++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)
 create mode 100644 package/libdispatch/Config.in
 create mode 100644 package/libdispatch/libdispatch.hash
 create mode 100644 package/libdispatch/libdispatch.mk
package/Config.in +1 -0
index 0d5d763180..e217ff5282 100644
@@ -1968,6 +1968,7 @@ menu "Other"
 	source "package/libcrossguid/Config.in"
 	source "package/libcsv/Config.in"
 	source "package/libdaemon/Config.in"
+	source "package/libdispatch/Config.in"
 	source "package/libeastl/Config.in"
 	source "package/libee/Config.in"
 	source "package/libev/Config.in"
package/libdispatch/Config.in new file +43 -0

44 lines not on this page · raw message

package/libdispatch/libdispatch.hash new file +1 -0
new file mode 100644
index 0000000000..64543b56eb
@@ -0,0 +1 @@
+sha256 d2bbfb5b98d129caa2c6bd7662c850bf57cb434572d09844b56641c4558906ab libdispatch-swift-5.6-RELEASE.tar.gz
package/libdispatch/libdispatch.mk new file +53 -0

53 lines not on this page · raw message

Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH 3/4 package/libdispatch: add fix for 32-bit arm

In reply to Alsey Coleman Miller
---
 package/libdispatch/arm-yield.patch | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 package/libdispatch/arm-yield.patch
package/libdispatch/arm-yield.patch new file +13 -0
new file mode 100644
index 0000000000..fa7cf7cce4
@@ -0,0 +1,13 @@
+diff --git a/src/shims/yield.c b/src/shims/yield.c
+index 43f0017..d0c5fff 100644
+--- a/src/shims/yield.c
++++ b/src/shims/yield.c
+@@ -36,7 +36,7 @@ void *
+ _dispatch_wait_for_enqueuer(void **ptr)
+ {
+ #if !DISPATCH_HW_CONFIG_UP
+-#if defined(__arm__) || defined(__arm64__)
++#if (defined(__arm__) && defined(__APPLE__)) || defined(__arm64__)
+ 	int spins = DISPATCH_WAIT_SPINS_WFE;
+ 	void *value;
+ 	while (unlikely(spins-- > 0)) {
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH 3/4] package/libdispatch: add fix for 32-bit arm

Hi Alsey,

This patch should be included in the first one.

package/libdispatch/arm-yield.patch

Quoted 12 lines · Alsey Coleman Miller
---
  package/libdispatch/arm-yield.patch | 13 +++++++++++++
  1 file changed, 13 insertions(+)

create mode 100644 package/libdispatch/arm-yield.patch

package/libdispatch/arm-yield.patch new file +0 -0
new file mode 100644
index 0000000000..fa7cf7cce4
@@ -0,0 +1,13 @@

Patches should be git formatted. They should have a full commit message that
explains the issue, and a Signed-off-by. There should also be an upstream reference, or something like "Not applicable" and an explaantion why it's not applicable for upstream.

Regards,
Arnout

package/libdispatch/arm-yield.patch line 13

Quoted 13 lines
package/libdispatch/arm-yield.patch new file +13 -0
+diff --git a/src/shims/yield.c b/src/shims/yield.c
+index 43f0017..d0c5fff 100644
+--- a/src/shims/yield.c
++++ b/src/shims/yield.c
+@@ -36,7 +36,7 @@ void *
+ _dispatch_wait_for_enqueuer(void **ptr)
+ {
+ #if !DISPATCH_HW_CONFIG_UP
+-#if defined(__arm__) || defined(__arm64__)
++#if (defined(__arm__) && defined(__APPLE__)) || defined(__arm64__)
+ 	int spins = DISPATCH_WAIT_SPINS_WFE;
+ 	void *value;
+ 	while (unlikely(spins-- > 0)) {

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

PATCH 4/4 DEVELOPERS: add Alsey Miller for libdispatch

In reply to Alsey Coleman Miller
---
 DEVELOPERS | 3 +++
 1 file changed, 3 insertions(+)
DEVELOPERS +3 -0
index a66b9d7eee..555ec0175b 100644
@@ -122,6 +122,9 @@ F:	boot/opensbi/
 F:	configs/hifive_unleashed_defconfig
 F:	package/xen/
 
+N:	Alsey Miller <[email protected]>
+F:	package/libdispatch/
+
 N:	Alvaro G. M <[email protected]>
 F:	package/dcron/
 F:	package/libxmlrpc/
Signature · 6 lines
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw
In reply to Alsey Coleman Miller

This change is necessary because if you specify the toolchain it will always use the GCC toolchain and C flags instead of the Clang cross compiler and custom C flags. This is not an issue for host packages, only for target.

Quoted 55 lines · Alsey Coleman Miller

---
package/pkg-cmake.mk | 25 ++++++++++++++++++++++++-

1 file changed, 24 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +0 -0
index 3b1db35fb6..9b36ee2b47 100644
@@ -57,7 +57,7 @@ $(2)_INSTALL_STAGING_OPTS	?= DESTDIR=$$(STAGING_DIR) install/fast

$(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install/fast

$(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
-
+$(3)_SUPPORTS_CMAKE_TOOLCHAIN ?= YES

ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
$(2)_BUILDDIR = $$($(2)_SRCDIR)

package/pkg-cmake.mk +1 -0
@@ -82,6 +82,7 @@ ifeq ($(4),target)
 #   documented as a standard CMake variable. If a package supports it,
 #   it must handle it explicitly.
 #
+ifeq ($(3)_SUPPORTS_CMAKE_TOOLCHAIN),YES)

define $(2)_CONFIGURE_CMDS

	(mkdir -p $$($$(PKG)_BUILDDIR) && \
	cd $$($$(PKG)_BUILDDIR) && \
package/pkg-cmake.mk +0 -0
@@ -104,6 +105,28 @@ define $(2)_CONFIGURE_CMDS
 	)

endef
else

package/pkg-cmake.mk +22 -0
+define $(2)_CONFIGURE_CMDS
+	(mkdir -p $$($$(PKG)_BUILDDIR) && \
+	cd $$($$(PKG)_BUILDDIR) && \
+	rm -f CMakeCache.txt && \
+	PATH=$$(BR_PATH) \
+	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+		-DCMAKE_INSTALL_PREFIX="/usr" \
+		-DCMAKE_COLOR_MAKEFILE=OFF \
+		-DBUILD_DOC=OFF \
+		-DBUILD_DOCS=OFF \
+		-DBUILD_EXAMPLE=OFF \
+		-DBUILD_EXAMPLES=OFF \
+		-DBUILD_TEST=OFF \
+		-DBUILD_TESTS=OFF \
+		-DBUILD_TESTING=OFF \
+		-DBUILD_SHARED_LIBS=$$(if $$(BR2_STATIC_LIBS),OFF,ON) \
+		$$(CMAKE_QUIET) \
+		$$($$(PKG)_CONF_OPTS) \
+	)
+endef
+endif
+else
Quoted 5 lines

# Configure package for host
define $(2)_CONFIGURE_CMDS

Signature · 1 line
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw
Quoted 2 lines · Alsey Miller

This change is necessary because if you specify the toolchain it will always use the GCC toolchain and C flags instead of the Clang cross compiler and custom C flags. This is not an issue for host packages, only for target.

I think this is probably a better way of dealing with the issue:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 56 lines
Quoted 56 lines · Alsey Coleman Miller

---
package/pkg-cmake.mk | 25 ++++++++++++++++++++++++-

1 file changed, 24 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +0 -0
index 3b1db35fb6..9b36ee2b47 100644
@@ -57,7 +57,7 @@ $(2)_INSTALL_STAGING_OPTS   ?= DESTDIR=$$(STAGING_DIR) install/fast

$(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install/fast

$(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
-
+$(3)_SUPPORTS_CMAKE_TOOLCHAIN ?= YES

ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
$(2)_BUILDDIR = $$($(2)_SRCDIR)

package/pkg-cmake.mk +1 -0
@@ -82,6 +82,7 @@ ifeq ($(4),target)
 #   documented as a standard CMake variable. If a package supports it,
 #   it must handle it explicitly.
 #
+ifeq ($(3)_SUPPORTS_CMAKE_TOOLCHAIN),YES)

define $(2)_CONFIGURE_CMDS

      (mkdir -p $$($$(PKG)_BUILDDIR) && \
      cd $$($$(PKG)_BUILDDIR) && \
package/pkg-cmake.mk +0 -0
@@ -104,6 +105,28 @@ define $(2)_CONFIGURE_CMDS
      )

endef
else

package/pkg-cmake.mk +22 -0
+define $(2)_CONFIGURE_CMDS
+     (mkdir -p $$($$(PKG)_BUILDDIR) && \
+     cd $$($$(PKG)_BUILDDIR) && \
+     rm -f CMakeCache.txt && \
+     PATH=$$(BR_PATH) \
+     $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+             -DCMAKE_INSTALL_PREFIX="/usr" \
+             -DCMAKE_COLOR_MAKEFILE=OFF \
+             -DBUILD_DOC=OFF \
+             -DBUILD_DOCS=OFF \
+             -DBUILD_EXAMPLE=OFF \
+             -DBUILD_EXAMPLES=OFF \
+             -DBUILD_TEST=OFF \
+             -DBUILD_TESTS=OFF \
+             -DBUILD_TESTING=OFF \
+             -DBUILD_SHARED_LIBS=$$(if $$(BR2_STATIC_LIBS),OFF,ON) \
+             $$(CMAKE_QUIET) \
+             $$($$(PKG)_CONF_OPTS) \
+     )
+endef
+endif
+else
Quoted 10 lines
Quoted 5 lines

# Configure package for host
define $(2)_CONFIGURE_CMDS
--
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#7 lore raw

That commit is not merged and only seems to override the C flags. How can we force cmake to use Clang for target packages? I would be fine with basing my work that patch if support for using Clang and as the C and C++ compiler is added.

Quoted 75 lines · James Hilliard
Quoted 2 lines · Alsey Miller

This change is necessary because if you specify the toolchain it will always use the GCC toolchain and C flags instead of the Clang cross compiler and custom C flags. This is not an issue for host packages, only for target.

I think this is probably a better way of dealing with the issue:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 66 lines
Quoted 56 lines · Alsey Coleman Miller

---
package/pkg-cmake.mk | 25 ++++++++++++++++++++++++-

1 file changed, 24 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +0 -0
index 3b1db35fb6..9b36ee2b47 100644
@@ -57,7 +57,7 @@ $(2)_INSTALL_STAGING_OPTS   ?= DESTDIR=$$(STAGING_DIR) install/fast

$(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install/fast

$(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
-
+$(3)_SUPPORTS_CMAKE_TOOLCHAIN ?= YES

ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
$(2)_BUILDDIR = $$($(2)_SRCDIR)

package/pkg-cmake.mk +1 -0
@@ -82,6 +82,7 @@ ifeq ($(4),target)
 #   documented as a standard CMake variable. If a package supports it,
 #   it must handle it explicitly.
 #
+ifeq ($(3)_SUPPORTS_CMAKE_TOOLCHAIN),YES)

define $(2)_CONFIGURE_CMDS

     (mkdir -p $$($$(PKG)_BUILDDIR) && \
     cd $$($$(PKG)_BUILDDIR) && \
package/pkg-cmake.mk +0 -0
@@ -104,6 +105,28 @@ define $(2)_CONFIGURE_CMDS
     )

endef
else

package/pkg-cmake.mk +22 -0
+define $(2)_CONFIGURE_CMDS
+     (mkdir -p $$($$(PKG)_BUILDDIR) && \
+     cd $$($$(PKG)_BUILDDIR) && \
+     rm -f CMakeCache.txt && \
+     PATH=$$(BR_PATH) \
+     $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+             -DCMAKE_INSTALL_PREFIX="/usr" \
+             -DCMAKE_COLOR_MAKEFILE=OFF \
+             -DBUILD_DOC=OFF \
+             -DBUILD_DOCS=OFF \
+             -DBUILD_EXAMPLE=OFF \
+             -DBUILD_EXAMPLES=OFF \
+             -DBUILD_TEST=OFF \
+             -DBUILD_TESTS=OFF \
+             -DBUILD_TESTING=OFF \
+             -DBUILD_SHARED_LIBS=$$(if $$(BR2_STATIC_LIBS),OFF,ON) \
+             $$(CMAKE_QUIET) \
+             $$($$(PKG)_CONF_OPTS) \
+     )
+endef
+endif
+else
Quoted 5 lines

# Configure package for host
define $(2)_CONFIGURE_CMDS
--
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#8 lore raw
Quoted 2 lines · Alsey Miller

That commit is not merged and only seems to override the C flags. How can we force cmake to use Clang for target packages? I would be fine with basing my work that patch if support for using Clang and as the C and C++ compiler is added.

It should allow overriding any of the toolchain variables like this:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

I think this will pretty much work as is with your libdispatch patch:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

It should allow you to drop this part:
LIBDISPATCH_SUPPORTS_CMAKE_TOOLCHAIN = NO

You might also be able to drop some of the other conf opts since the toolchain file can then still be used with partial overrides.

Quoted 66 lines
Quoted 66 lines · James Hilliard
Quoted 2 lines · Alsey Miller

This change is necessary because if you specify the toolchain it will always use the GCC toolchain and C flags instead of the Clang cross compiler and custom C flags. This is not an issue for host packages, only for target.

I think this is probably a better way of dealing with the issue:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 56 lines
Quoted 56 lines · Alsey Coleman Miller

---
package/pkg-cmake.mk | 25 ++++++++++++++++++++++++-

1 file changed, 24 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +0 -0
index 3b1db35fb6..9b36ee2b47 100644
@@ -57,7 +57,7 @@ $(2)_INSTALL_STAGING_OPTS   ?= DESTDIR=$$(STAGING_DIR) install/fast

$(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install/fast

$(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
-
+$(3)_SUPPORTS_CMAKE_TOOLCHAIN ?= YES

ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
$(2)_BUILDDIR = $$($(2)_SRCDIR)

package/pkg-cmake.mk +1 -0
@@ -82,6 +82,7 @@ ifeq ($(4),target)
 #   documented as a standard CMake variable. If a package supports it,
 #   it must handle it explicitly.
 #
+ifeq ($(3)_SUPPORTS_CMAKE_TOOLCHAIN),YES)

define $(2)_CONFIGURE_CMDS

     (mkdir -p $$($$(PKG)_BUILDDIR) && \
     cd $$($$(PKG)_BUILDDIR) && \
package/pkg-cmake.mk +0 -0
@@ -104,6 +105,28 @@ define $(2)_CONFIGURE_CMDS
     )

endef
else

package/pkg-cmake.mk +22 -0
+define $(2)_CONFIGURE_CMDS
+     (mkdir -p $$($$(PKG)_BUILDDIR) && \
+     cd $$($$(PKG)_BUILDDIR) && \
+     rm -f CMakeCache.txt && \
+     PATH=$$(BR_PATH) \
+     $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+             -DCMAKE_INSTALL_PREFIX="/usr" \
+             -DCMAKE_COLOR_MAKEFILE=OFF \
+             -DBUILD_DOC=OFF \
+             -DBUILD_DOCS=OFF \
+             -DBUILD_EXAMPLE=OFF \
+             -DBUILD_EXAMPLES=OFF \
+             -DBUILD_TEST=OFF \
+             -DBUILD_TESTS=OFF \
+             -DBUILD_TESTING=OFF \
+             -DBUILD_SHARED_LIBS=$$(if $$(BR2_STATIC_LIBS),OFF,ON) \
+             $$(CMAKE_QUIET) \
+             $$($$(PKG)_CONF_OPTS) \
+     )
+endef
+endif
+else
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

# Configure package for host
define $(2)_CONFIGURE_CMDS
--
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#9 lore raw

I’ve submitted a new series of patches that I’ve tested with your patch. So the LIBDISPATCH_SUPPORTS_CMAKE_TOOLCHAIN line is remove and all pkg-cmake changes.

Quoted 9 lines · James Hilliard
Quoted 2 lines · Alsey Miller

That commit is not merged and only seems to override the C flags. How can we force cmake to use Clang for target packages? I would be fine with basing my work that patch if support for using Clang and as the C and C++ compiler is added.

It should allow overriding any of the toolchain variables like this:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 86 lines

I think this will pretty much work as is with your libdispatch patch:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

It should allow you to drop this part:
LIBDISPATCH_SUPPORTS_CMAKE_TOOLCHAIN = NO

You might also be able to drop some of the other conf opts since the toolchain file can then still be used with partial overrides.

Quoted 77 lines
Quoted 76 lines · James Hilliard
Quoted 2 lines · Alsey Miller

This change is necessary because if you specify the toolchain it will always use the GCC toolchain and C flags instead of the Clang cross compiler and custom C flags. This is not an issue for host packages, only for target.

I think this is probably a better way of dealing with the issue:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 66 lines
Quoted 56 lines · Alsey Coleman Miller

---
package/pkg-cmake.mk | 25 ++++++++++++++++++++++++-

1 file changed, 24 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +0 -0
index 3b1db35fb6..9b36ee2b47 100644
@@ -57,7 +57,7 @@ $(2)_INSTALL_STAGING_OPTS   ?= DESTDIR=$$(STAGING_DIR) install/fast

$(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install/fast

$(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
-
+$(3)_SUPPORTS_CMAKE_TOOLCHAIN ?= YES

ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
$(2)_BUILDDIR = $$($(2)_SRCDIR)

package/pkg-cmake.mk +1 -0
@@ -82,6 +82,7 @@ ifeq ($(4),target)
 #   documented as a standard CMake variable. If a package supports it,
 #   it must handle it explicitly.
 #
+ifeq ($(3)_SUPPORTS_CMAKE_TOOLCHAIN),YES)

define $(2)_CONFIGURE_CMDS

    (mkdir -p $$($$(PKG)_BUILDDIR) && \
    cd $$($$(PKG)_BUILDDIR) && \
package/pkg-cmake.mk +0 -0
@@ -104,6 +105,28 @@ define $(2)_CONFIGURE_CMDS
    )

endef
else

package/pkg-cmake.mk +22 -0
+define $(2)_CONFIGURE_CMDS
+     (mkdir -p $$($$(PKG)_BUILDDIR) && \
+     cd $$($$(PKG)_BUILDDIR) && \
+     rm -f CMakeCache.txt && \
+     PATH=$$(BR_PATH) \
+     $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+             -DCMAKE_INSTALL_PREFIX="/usr" \
+             -DCMAKE_COLOR_MAKEFILE=OFF \
+             -DBUILD_DOC=OFF \
+             -DBUILD_DOCS=OFF \
+             -DBUILD_EXAMPLE=OFF \
+             -DBUILD_EXAMPLES=OFF \
+             -DBUILD_TEST=OFF \
+             -DBUILD_TESTS=OFF \
+             -DBUILD_TESTING=OFF \
+             -DBUILD_SHARED_LIBS=$$(if $$(BR2_STATIC_LIBS),OFF,ON) \
+             $$(CMAKE_QUIET) \
+             $$($$(PKG)_CONF_OPTS) \
+     )
+endef
+endif
+else
Quoted 5 lines

# Configure package for host
define $(2)_CONFIGURE_CMDS
--
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#10 lore raw
Quoted 2 lines · Alsey Miller

I’ve submitted a new series of patches that I’ve tested with your patch. So the LIBDISPATCH_SUPPORTS_CMAKE_TOOLCHAIN line is remove and all pkg-cmake changes.

FYI toolchain variable override support is now merged:
https://github.com/buildroot/buildroot/commit/56a27d7d00ea3a1851a46045bbc9472091412e76

Quoted 85 lines
Quoted 85 lines · James Hilliard
Quoted 2 lines · Alsey Miller

That commit is not merged and only seems to override the C flags. How can we force cmake to use Clang for target packages? I would be fine with basing my work that patch if support for using Clang and as the C and C++ compiler is added.

It should allow overriding any of the toolchain variables like this:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

I think this will pretty much work as is with your libdispatch patch:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

It should allow you to drop this part:
LIBDISPATCH_SUPPORTS_CMAKE_TOOLCHAIN = NO

You might also be able to drop some of the other conf opts since the toolchain file can then still be used with partial overrides.

Quoted 66 lines
Quoted 66 lines · James Hilliard
Quoted 2 lines · Alsey Miller

This change is necessary because if you specify the toolchain it will always use the GCC toolchain and C flags instead of the Clang cross compiler and custom C flags. This is not an issue for host packages, only for target.

I think this is probably a better way of dealing with the issue:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 56 lines
Quoted 56 lines · Alsey Coleman Miller

---
package/pkg-cmake.mk | 25 ++++++++++++++++++++++++-

1 file changed, 24 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +0 -0
index 3b1db35fb6..9b36ee2b47 100644
@@ -57,7 +57,7 @@ $(2)_INSTALL_STAGING_OPTS   ?= DESTDIR=$$(STAGING_DIR) install/fast

$(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install/fast

$(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
-
+$(3)_SUPPORTS_CMAKE_TOOLCHAIN ?= YES

ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES)
$(2)_BUILDDIR = $$($(2)_SRCDIR)

package/pkg-cmake.mk +1 -0
@@ -82,6 +82,7 @@ ifeq ($(4),target)
 #   documented as a standard CMake variable. If a package supports it,
 #   it must handle it explicitly.
 #
+ifeq ($(3)_SUPPORTS_CMAKE_TOOLCHAIN),YES)

define $(2)_CONFIGURE_CMDS

    (mkdir -p $$($$(PKG)_BUILDDIR) && \
    cd $$($$(PKG)_BUILDDIR) && \
package/pkg-cmake.mk +0 -0
@@ -104,6 +105,28 @@ define $(2)_CONFIGURE_CMDS
    )

endef
else

package/pkg-cmake.mk +22 -0
+define $(2)_CONFIGURE_CMDS
+     (mkdir -p $$($$(PKG)_BUILDDIR) && \
+     cd $$($$(PKG)_BUILDDIR) && \
+     rm -f CMakeCache.txt && \
+     PATH=$$(BR_PATH) \
+     $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
+             -DCMAKE_INSTALL_PREFIX="/usr" \
+             -DCMAKE_COLOR_MAKEFILE=OFF \
+             -DBUILD_DOC=OFF \
+             -DBUILD_DOCS=OFF \
+             -DBUILD_EXAMPLE=OFF \
+             -DBUILD_EXAMPLES=OFF \
+             -DBUILD_TEST=OFF \
+             -DBUILD_TESTS=OFF \
+             -DBUILD_TESTING=OFF \
+             -DBUILD_SHARED_LIBS=$$(if $$(BR2_STATIC_LIBS),OFF,ON) \
+             $$(CMAKE_QUIET) \
+             $$($$(PKG)_CONF_OPTS) \
+     )
+endef
+endif
+else
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

# Configure package for host
define $(2)_CONFIGURE_CMDS
--
2.35.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot