Bug 250664 - databases/galera26: ARM64/Aarch64 support
Summary: databases/galera26: ARM64/Aarch64 support
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Mikael Urankar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-27 05:14 UTC by Vincent Milum Jr
Modified: 2020-11-15 09:57 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (devel)


Attachments
v1 (2.22 KB, patch)
2020-10-27 20:16 UTC, Mikael Urankar
no flags Details | Diff
v2 (4.59 KB, patch)
2020-10-27 20:39 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Milum Jr 2020-10-27 05:14:56 UTC
The Galera26 port for compiling on ARM64/Aarch64 is only missing a single function call to make it work.

I pulled this out of sys/x86/include/endian.h


#define	__bswap64_gen(x)		\
	(((__uint64_t)__bswap32((x) & 0xffffffff) << 32) | __bswap32((x) >> 32))

static __inline __uint64_t __bswap64_var(__uint64_t _x)
{
	return (__bswap64_gen(_x));
}


After this, Galera26 compiles just fine on ARM.

Next up, the MariaDB ports need a small fix as well. They're missing the wasrep_ shell scripts due to the following in databases/mariadb10x-sever/Makefile

.if ${ARCH} != amd64
PLIST_SUB+= WSREP="@comment "
.endif


With this, I now have a Galera cluster up and running across 3 ARM VMs.
Comment 1 Daniel Engberg freebsd_committer freebsd_triage 2020-10-27 07:36:31 UTC
Hi, 
Please submit Galera fix upstream, https://github.com/codership/galera seems to be upstream repo.
Best regards
Daniel
Comment 2 Vincent Milum Jr 2020-10-27 17:46:27 UTC
In this particular case, the "upstream" I think is actually FreeBSD itself. The missing function is defined in the FreeBSD source tree for i386, amd64, and other platforms, but missing for arm and arm64. This was noted in my initial report showing that I pulled in the copy from i386, which made this port functional in arm64.
Comment 3 Mikael Urankar freebsd_committer freebsd_triage 2020-10-27 20:16:21 UTC
Created attachment 219152 [details]
v1

Can you try this patch?
Comment 4 Mikael Urankar freebsd_committer freebsd_triage 2020-10-27 20:39:58 UTC
Created attachment 219153 [details]
v2

with hwcap fix
Comment 5 Mikael Urankar freebsd_committer freebsd_triage 2020-10-27 20:40:25 UTC
(In reply to Vincent Milum Jr from comment #0)
can you open another pr for mariadb please?
Comment 6 Vincent Milum Jr 2020-10-29 07:16:32 UTC
(In reply to Mikael Urankar from comment #4)

Applied the patch, compiled cleanly, and am now running it on my test aarch64 cluster.

As a side note, did a rolling upgrade from my 26.4.5 patch to your 26.4.6 patch without taking the cluster offline. All worked exactly as expected. :)
Comment 7 Vincent Milum Jr 2020-10-31 16:45:41 UTC
While I think its good to try to get upstream support, I'm going to once again reiterate that the missing functionality (64-bit byte swapping) is something that should be provided by the main FreeBSD source tree. I'm running into issues with other ports now that have similar endian/byte swapping functions missing. 

Please compare these two files

https://github.com/freebsd/freebsd/blob/master/sys/x86/include/endian.h

https://github.com/freebsd/freebsd/blob/master/sys/arm64/include/endian.h

Correcting this in the FreeBSD source tree itself for arm64, getting its endian support up to date with x86 targets, will enable a number of ports beyond just databases/galera26 to start working.
Comment 8 Mikael Urankar freebsd_committer freebsd_triage 2020-10-31 17:08:59 UTC
(In reply to Vincent Milum Jr from comment #7)
Do you have a phabricator account? Can you provide a patch and add the aarch64 group?

Do you have a list of affected ports? We'll have to patch them anyway to support FreeBSD < 13.x
Comment 9 commit-hook freebsd_committer freebsd_triage 2020-11-09 16:00:22 UTC
A commit references this bug:

Author: mikael
Date: Mon Nov  9 15:59:43 UTC 2020
New revision: 554729
URL: https://svnweb.freebsd.org/changeset/ports/554729

Log:
  databases/galera26: fix build on aarch64

  The __bswapXX_var macro are not available on arm*, use bswapXX instead
  Add cpu feature detection on arm*

  PR:		250664
  Reported by:	Vincent Milum Jr
  Approved by:	portmgr (tier-2 blanket)

Changes:
  head/databases/galera26/Makefile
  head/databases/galera26/files/patch-galerautils_SConscript
  head/databases/galera26/files/patch-galerautils_src_gu__byteswap.h
  head/databases/galera26/files/patch-galerautils_src_gu__crc32c__arm64.c
Comment 10 Mark Linimon freebsd_committer freebsd_triage 2020-11-15 09:57:11 UTC
Committed Nov  9 15:59:43 UTC 2020.