[pgpool-hackers: 4155] Porting Pgpool-II to Apple Silicon macOS

Tatsuo Ishii ishii at sraoss.co.jp
Sat Apr 30 12:46:07 JST 2022


Recently I got my own acBook Air and am working on porting Pgpool-II
to it. Here is an in-progress report on the work. Since I am totally
new to the development environment (Homebrew) and macOS, I am sure I
am doing something wrong. Any suggestions are welcome.

Here is the basic information of my MacBook Air:
- macOS Monterey (macOS 12.3.1)
- CPU: Apple M1
- Mem: 16GB

$ brew --version
Homebrew 3.4.9
Homebrew/homebrew-core (git revision 5c258e94854; last commit 2022-04-29)
Homebrew/homebrew-cask (git revision d962f7bd3e; last commit 2022-04-29)

bash-3.2$ brew list
brew list
==> Formulae
autoconf	docbook		gettext		libmemcached	memcached	openssl at 3
automake	docbook-dsssl	gmp		libmpc		mpfr		readline
bison		docbook-sgml	gnu-sed		libtool		open-sp		ruby
ca-certificates	docbook-xsl	isl		libyaml		openjade	zstd
coreutils	gcc		libevent	m4		openssl at 1.1

==> Casks
zulu

configure options:
./configure --prefix=/Users/ishiitatsuo/work/Pgpool-II --with-openssl --with-memcached=/opt/homebrew/Cellar/libmemcached/1.0.18_2

regression test options: (PostgreSQL 14 is installed under ~/work/pgsql and Pgpool-II is installed under ~/work/Pgpool-II)
./regress.sh -p ~/work/pgsql/bin -i ~/work/Pgpool-II -m noinstall -j ~/work/Pgpool-II/share/postgresql-9.2-1003.jdbc4.jar

- What I have done so far?

-- Modify some source files to adopt macOS:

-- src/auth/pool_auth.c needs to be modified because macOS does not
   have crypt.h. Instead include unistd.h.

-- src/utils/ps_status.c needs to be modified so that
   PS_USE_CLOBBER_ARGV can be used. I initially thought that
   "__darwin__" is defined by cc (I gussed so because PostgreSQL uses
   __darwin__), but actually cc does not define it. Instead I need to
   add "__MACH__" (which is defined by cc) checking.

-- /src/utils/strlcpy.c needs to be modified because macOS alredy has strlcpy.

-- regression test scripts need to be modified. macOS does not have
   sed command having -i (in place editing). Instead we need to use
   gsed (GNU sed).

Please find attached patch for more details.

- What are remaining issues?

-- regression tests mostly passed except:

testing 010.rewrite_timestamp...failed.
testing 060.memory_leak...failed.
testing 069.memory_leak_extended...failed.

The 010 test uses custom C file which is not portable. I will fix in
the next patch.  The 060 and 069 test failures are strange. They are
testing memory leaks before and after pgbench run. In general memory
leaks are caused by application level mistakes (in this case pgpool
itself) but most source codes are remaining same. I need to
investigate more.

-- I am not sure relying on __MACH_ symbol is ok. Detecting __darwin__
   will be better? What PostgreSQL actually does is, use
   AC_CANONICAL_HOST macro in configure.ac then set the symbol by
   itself. So probably we should do the same thing?

Best reagards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: macos.patch
Type: text/x-patch
Size: 16603 bytes
Desc: not available
URL: <http://www.pgpool.net/pipermail/pgpool-hackers/attachments/20220430/fe581805/attachment.bin>


More information about the pgpool-hackers mailing list