Skip to contentSkip to conversation

package/highway: fix riscv32 build

PATCH Applied Fabrice Fontaine 2 participants 2 messages Jan 20, 2024 – Jan 21, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/highway: fix riscv32 build

Do not set -march=rv64gcv1p0 when building for riscv32 to fix the following build failure raised since bump to version 1.0.7 in commit 0db3c08daf335571a2b2d18a16d8980ddf4567ab and
https://github.com/google/highway/commit/7c15872e81d88c77bca5e74fe0a6543cc374601a:

cc1plus: error: ABI requires '-march=rv32'

Fixes:
- http://autobuild.buildroot.org/results/3f8def50c93f73c26339f72d6a13951d5fb41c30

---
 ...1-add-required-RISC-V-flags-to-CMake.patch | 42 +++++++++++++++++++
 package/highway/highway.mk                    |  4 ++
 2 files changed, 46 insertions(+)
 create mode 100644 package/highway/0001-add-required-RISC-V-flags-to-CMake.patch
package/highway/0001-add-required-RISC-V-flags-to-CMake.patch new file +42 -0
new file mode 100644
index 0000000000..bfcbfb055c
@@ -0,0 +1,42 @@
+From 5d58d233fbcec0c6a39df8186a877329147324b3 Mon Sep 17 00:00:00 2001
+From: Mathieu Malaterre <[email protected]>
+Date: Wed, 13 Sep 2023 08:37:54 +0200
+Subject: [PATCH] Add an option to opt-out of HWY_RISCV
+
+Fixes #1740
+
+Upstream: https://github.com/google/highway/commit/5d58d233fbcec0c6a39df8186a877329147324b3
+Signed-off-by: Fabrice Fontaine <[email protected]>
+---
+ CMakeLists.txt | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c2bf57b3f5..be639c945f 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -61,6 +61,9 @@ set(HWY_CMAKE_ARM7 OFF CACHE BOOL "Set copts for Armv7 with NEON (requires vfpv4
+ # skipped. For GCC 13.1+, you can also build with -fexcess-precision=standard.
+ set(HWY_CMAKE_SSE2 OFF CACHE BOOL "Set SSE2 as baseline for 32-bit x86?")
+ 
++# Currently this will compile the entire codebase with `-march=rv64gcv1p0`:
++set(HWY_CMAKE_RVV ON CACHE BOOL "Set copts for RISCV with RVV?")
++
+ # Unconditionally adding -Werror risks breaking the build when new warnings
+ # arise due to compiler/platform changes. Enable this in CI/tests.
+ set(HWY_WARNINGS_ARE_ERRORS OFF CACHE BOOL "Add -Werror flag?")
+@@ -260,9 +263,11 @@ else()
+     # gcc(13) and recent clang both support V, but not yet runtime dispatch, so
+     # we add the gcv compiler flag, which then requires the CPU (now when using
+     # either compiler) to support V.
+-    list(APPEND HWY_FLAGS -march=rv64gcv1p0)
+-    if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
+-      list(APPEND HWY_FLAGS -menable-experimental-extensions)
++    if(HWY_CMAKE_RVV)
++      list(APPEND HWY_FLAGS -march=rv64gcv1p0)
++      if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
++        list(APPEND HWY_FLAGS -menable-experimental-extensions)
++      endif()
+     endif()
+   endif()
+ 
package/highway/highway.mk +4 -0
index 692794959a..2ae2cdc6b6 100644
@@ -41,6 +41,10 @@ else
 HIGHWAY_CONF_OPTS += -DHWY_CMAKE_ARM7=OFF
 endif
 
+ifeq ($(BR2_RISCV_32),y)
+HIGHWAY_CONF_OPTS += -DHWY_CMAKE_RVV=OFF
+endif
+
 # Workaround for gcc bug 104028 on m68k.
 # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104028
 ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_104028),y)
Signature · 6 lines
2.43.0

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

Fabrice, All,

On 2024-01-20 17:10 +0100, Fabrice Fontaine spake thusly:

Quoted 11 lines

Do not set -march=rv64gcv1p0 when building for riscv32 to fix the following build failure raised since bump to version 1.0.7 in commit 0db3c08daf335571a2b2d18a16d8980ddf4567ab and
https://github.com/google/highway/commit/7c15872e81d88c77bca5e74fe0a6543cc374601a:

cc1plus: error: ABI requires '-march=rv32'

Fixes:
- http://autobuild.buildroot.org/results/3f8def50c93f73c26339f72d6a13951d5fb41c30

Applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 76 lines
---
 ...1-add-required-RISC-V-flags-to-CMake.patch | 42 +++++++++++++++++++
 package/highway/highway.mk                    |  4 ++
 2 files changed, 46 insertions(+)
 create mode 100644 package/highway/0001-add-required-RISC-V-flags-to-CMake.patch
package/highway/0001-add-required-RISC-V-flags-to-CMake.patch new file +42 -0
new file mode 100644
index 0000000000..bfcbfb055c
@@ -0,0 +1,42 @@
+From 5d58d233fbcec0c6a39df8186a877329147324b3 Mon Sep 17 00:00:00 2001
+From: Mathieu Malaterre <[email protected]>
+Date: Wed, 13 Sep 2023 08:37:54 +0200
+Subject: [PATCH] Add an option to opt-out of HWY_RISCV
+
+Fixes #1740
+
+Upstream: https://github.com/google/highway/commit/5d58d233fbcec0c6a39df8186a877329147324b3
+Signed-off-by: Fabrice Fontaine <[email protected]>
+---
+ CMakeLists.txt | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c2bf57b3f5..be639c945f 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -61,6 +61,9 @@ set(HWY_CMAKE_ARM7 OFF CACHE BOOL "Set copts for Armv7 with NEON (requires vfpv4
+ # skipped. For GCC 13.1+, you can also build with -fexcess-precision=standard.
+ set(HWY_CMAKE_SSE2 OFF CACHE BOOL "Set SSE2 as baseline for 32-bit x86?")
+ 
++# Currently this will compile the entire codebase with `-march=rv64gcv1p0`:
++set(HWY_CMAKE_RVV ON CACHE BOOL "Set copts for RISCV with RVV?")
++
+ # Unconditionally adding -Werror risks breaking the build when new warnings
+ # arise due to compiler/platform changes. Enable this in CI/tests.
+ set(HWY_WARNINGS_ARE_ERRORS OFF CACHE BOOL "Add -Werror flag?")
+@@ -260,9 +263,11 @@ else()
+     # gcc(13) and recent clang both support V, but not yet runtime dispatch, so
+     # we add the gcv compiler flag, which then requires the CPU (now when using
+     # either compiler) to support V.
+-    list(APPEND HWY_FLAGS -march=rv64gcv1p0)
+-    if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
+-      list(APPEND HWY_FLAGS -menable-experimental-extensions)
++    if(HWY_CMAKE_RVV)
++      list(APPEND HWY_FLAGS -march=rv64gcv1p0)
++      if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
++        list(APPEND HWY_FLAGS -menable-experimental-extensions)
++      endif()
+     endif()
+   endif()
+ 
package/highway/highway.mk +4 -0
index 692794959a..2ae2cdc6b6 100644
@@ -41,6 +41,10 @@ else
 HIGHWAY_CONF_OPTS += -DHWY_CMAKE_ARM7=OFF
 endif
 
+ifeq ($(BR2_RISCV_32),y)
+HIGHWAY_CONF_OPTS += -DHWY_CMAKE_RVV=OFF
+endif
+
 # Workaround for gcc bug 104028 on m68k.
 # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104028
 ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_104028),y)
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot