From 12a5bedc88cca4c6b871c457b4d09168f575ca53 Mon Sep 17 00:00:00 2001 From: U2FsdGVkX1 Date: Wed, 13 Dec 2023 17:54:26 +0800 Subject: [PATCH] Add riscv64 support --- ...st_lock_free_type_selector-on-RISC-V.patch | 73 +++++++++++++++++++ mysql.spec | 31 ++++++-- 2 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 0200-Use-Largest_lock_free_type_selector-on-RISC-V.patch diff --git a/0200-Use-Largest_lock_free_type_selector-on-RISC-V.patch b/0200-Use-Largest_lock_free_type_selector-on-RISC-V.patch new file mode 100644 index 0000000..747159b --- /dev/null +++ b/0200-Use-Largest_lock_free_type_selector-on-RISC-V.patch @@ -0,0 +1,73 @@ +From a50a5c1e966d89fb9cbaa1c284a249612a7e54a1 Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Tue, 18 Oct 2022 19:08:57 +0300 +Subject: [PATCH] Use Largest_lock_free_type_selector on RISC-V + +This patch is necessary because RISC-V doesn't guarantee the +always-lock-free property on certain types (like boolean), which +causes a static_assert to trigger when compiling MySQL on the +architecture. + +Author: Sergio Durigan Junior +Forwarded: no +Last-Updated: 2020-07-27 + +See: +https://git.launchpad.net/ubuntu/+source/mysql-8.0/commit/?id=152424bbd175737d9805aeffd63f0bf5b3196449 +--- + .../include/temptable/lock_free_type.h | 24 ++++++++++++++++++- + 1 file changed, 23 insertions(+), 1 deletion(-) + +diff --git a/storage/temptable/include/temptable/lock_free_type.h b/storage/temptable/include/temptable/lock_free_type.h +index 2383dfe5..6ddcb367 100644 +--- a/storage/temptable/include/temptable/lock_free_type.h ++++ b/storage/temptable/include/temptable/lock_free_type.h +@@ -102,6 +102,19 @@ enum class Alignment { NATURAL, L1_DCACHE_SIZE }; + * More details and motivation can be found at: + * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0152r0.html + * */ ++ ++/** Ubuntu patch for RISC-V: ++ ++ On RISC-V, some types are not always lock-free. For example, ++ ATOMIC_BOOL_LOCK_FREE is 1, meaning that it is sometimes ++ lock-free. This causes a compilation error of ++ Lock_free_type_selector because of the static_asserts below. For ++ this reason, we have to guard the Lock_free_type_selector code ++ with an ifndef when compiling for RISC-V. We also have to force ++ the use of Largest_lock_free_type_selector instead of ++ Lock_free_type_selector. */ ++ ++#ifndef __riscv + template + struct Lock_free_type_selector { + static_assert( +@@ -224,6 +237,13 @@ struct Lock_free_type_selector< + "always-lock-free property. Bailing out ..."); + #endif + }; ++#else ++ /** As explained above, if we're compiling for RISC-V then we have ++ to force the use of Largest_lock_free_type_selector instead of ++ Lock_free_type_selector, because the former will work ++ normally, while the latter will fail to compile. */ ++#define Lock_free_type_selector Largest_lock_free_type_selector ++#endif /* ! __riscv */ + + /** Largest lock-free type selector, a helper utility very much similar + * to Lock_free_type_selector with the difference being that it tries hard +@@ -290,7 +310,9 @@ struct Largest_lock_free_type_selector< + * + * Always-lock-free guarantee is implemented through the means of + * Lock_free_type_selector or Largest_lock_free_type_selector. User code can +- * opt-in for any of those. By default, Lock_free_type_selector is used. ++ * opt-in for any of those. By default, Lock_free_type_selector is ++ * used, except on RISC-V, where Largest_lock_free_type_selector is ++ * used by default due to atomic type limitations. + * + * In addition, this type provides an ability to redefine the + * alignment-requirement of the underlying always-lock-free type, basically +-- +2.35.1 + + diff --git a/mysql.spec b/mysql.spec index 5e3eb00..edadc27 100644 --- a/mysql.spec +++ b/mysql.spec @@ -1,8 +1,12 @@ -%define anolis_release 1 +%define anolis_release 2 # Name of the package without any prefixes %global pkg_name %{name} %global pkgnamepatch mysql +%ifarch riscv64 +%define _lto_cflags %{nil} +%endif + # Regression tests may take a long time (many cores recommended), skip them by # passing --nocheck to rpmbuild or by setting runselftest to 0 if defining # --nocheck is not possible (e.g. in koji build) @@ -117,6 +121,8 @@ Patch53: %{pkgnamepatch}-mtr.patch Patch111: boost-1.57.0-mpl-print.patch Patch112: boost-1.58.0-pool.patch +Patch200: 0200-Use-Largest_lock_free_type_selector-on-RISC-V.patch + BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: libaio-devel @@ -375,6 +381,10 @@ pushd boost/boost_$(echo %{boost_bundled_version}| tr . _) %patch112 -p1 popd +%ifarch riscv64 +%patch200 -p1 +%endif + # generate a list of tests that fail, but are not disabled by upstream cat %{SOURCE50} | tee -a mysql-test/%{skiplist} @@ -428,6 +438,9 @@ cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} \ -DWITH_INNODB_MEMCACHED=ON \ %ifnarch aarch64 -DWITH_NUMA=ON \ +%endif +%ifarch riscv64 + -DUSE_LD_GOLD=OFF \ %endif -DWITH_ROUTER=OFF \ -DWITH_SYSTEM_LIBS=ON \ @@ -435,15 +448,15 @@ cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} \ -DWITH_FIDO=system \ -DWITH_BOOST=boost \ -DREPRODUCIBLE_BUILD=OFF \ - -DCMAKE_C_FLAGS="%{optflags}%{?with_debug: -fno-strict-overflow -Wno-unused-result -Wno-unused-function -Wno-unused-but-set-variable}" \ - -DCMAKE_CXX_FLAGS="%{optflags}%{?with_debug: -fno-strict-overflow -Wno-unused-result -Wno-unused-function -Wno-unused-but-set-variable}" \ - -DCMAKE_EXE_LINKER_FLAGS="-pie %{build_ldflags}" \ + -DCMAKE_C_FLAGS="%{optflags} -latomic %{?with_debug: -fno-strict-overflow -Wno-unused-result -Wno-unused-function -Wno-unused-but-set-variable}" \ + -DCMAKE_CXX_FLAGS="%{optflags} -latomic %{?with_debug: -fno-strict-overflow -Wno-unused-result -Wno-unused-function -Wno-unused-but-set-variable}" \ + -DCMAKE_EXE_LINKER_FLAGS="-pie %{build_ldflags} -latomic" \ %{?with_debug: -DWITH_DEBUG=1} \ %{?with_debug: -DMYSQL_MAINTAINER_MODE=0} \ -DTMPDIR=/var/tmp \ - -DWITH_MYSQLD_LDFLAGS="%{build_ldflags}" \ - -DCMAKE_C_LINK_FLAGS="%{build_ldflags}" \ - -DCMAKE_CXX_LINK_FLAGS="%{build_ldflags}" \ + -DWITH_MYSQLD_LDFLAGS="%{build_ldflags} -latomic" \ + -DCMAKE_C_LINK_FLAGS="%{build_ldflags} -latomic" \ + -DCMAKE_CXX_LINK_FLAGS="%{build_ldflags} -latomic" \ -DCMAKE_SKIP_INSTALL_RPATH=YES \ -DWITH_UNIT_TESTS=0 @@ -927,6 +940,10 @@ fi %endif %changelog +* Sat Nov 11 2023 Guoguo - 8.0.33-2 +- Add support for riscv64 +- Patch from https://git.launchpad.net/ubuntu/+source/mysql-8.0/commit/?id=152424bbd175737d9805aeffd63f0bf5b3196449 + * Tue Aug 01 2023 happy_orange - 8.0.33-1 - update to 8.0.33 to fix cves -- Gitee