Xpce on mac

Cannot get xpce into the build on macOS for love or money. Please forgive my barfing up all the details below. Any guidance would be appreciated.

% brew list
aom			fribidi			jpeg			libtasn1		opencore-amr		snappy
apr			gcc			krb5			libtiff			openjdk@11		speex
apr-util		gd			lame			libtool			openjpeg		sqlite
argon2			gdbm			leptonica		libunistring		openldap		srt
aspell			gettext			libarchive		libvidstab		openssl@1.1	
autoconf		ghostscript		libass			libvorbis		opus			tcl-tk
bdw-gc			giflib			libb2			libvpx			ossp-uuid		tesseract
berkeley-db		git			libbluray		libx11			p11-kit			texinfo
brotli			glib			libev			libxau			pcre			theora
c-ares			gmp			libevent		libxcb			pcre2			tidy-html5
cairo			gnu-sed			libffi			libxdmcp		php			unbound
cmake			gnutls			libidn2			libxpm			pixman			unixodbc
curl			gobject-introspection	libmetalink		libyaml			pkg-config		w3m
cvs			grakn-core		libmpc			libzip			postgresql		webp
datomic			graphite2		libogg			little-cms2		postgresql@11		wget
dav1d			guile			libpng			lz4			python@3.8		x264
emacs			harfbuzz		libpq			lzo			python@3.9		x265
ffmpeg			httpd			libpthread-stubs	mpfr			q			xorgproto
flac			icu4c			libsamplerate		neo4j			rav1e			xvid
fontconfig		iftop			libsndfile		nettle			readline		xz
freetds			isl			libsodium		nghttp2			rtmpdump		zeromq
freetype		jansson			libsoxr			ninja			rubberband		zimg
frei0r			jemalloc		libssh2			oniguruma		sdl2			zstd
emacs                      grakn-workbase             inkscape                   java                       mactex                     xquartz

And the install:

% brew install --build-from-source swi-prolog --HEAD

==> **Cloning https://github.com/SWI-Prolog/swipl-devel.git**

Updating /Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git

==> **Checking out branch master**

Already on 'master'

Your branch is up to date with 'origin/master'.

HEAD is now at 264c8fe DOC: csv_read_file_row/3: to be done note was outdated. Boris Vassilev.

Entering 'bench'

Entering 'debian'

Entering 'packages/PDT'

Entering 'packages/RDF'

Entering 'packages/archive'

Entering 'packages/bdb'

Entering 'packages/chr'

Entering 'packages/clib'

Entering 'packages/clpqr'

Entering 'packages/cpp'

Entering 'packages/cppproxy'

Entering 'packages/cql'

Entering 'packages/http'

Entering 'packages/inclpr'

Entering 'packages/jpl'

Entering 'packages/libedit'

Entering 'packages/ltx2htm'

Entering 'packages/nlp'

Entering 'packages/odbc'

Entering 'packages/paxos'

Entering 'packages/pcre'

Entering 'packages/pengines'

Entering 'packages/pldoc'

Entering 'packages/plunit'

Entering 'packages/protobufs'

Entering 'packages/readline'

Entering 'packages/redis'

Entering 'packages/semweb'

Entering 'packages/sgml'

Entering 'packages/ssl'

Entering 'packages/swipl-win'

Entering 'packages/table'

Entering 'packages/tipc'

Entering 'packages/utf8proc'

Entering 'packages/windows'

Entering 'packages/xpce'

Entering 'packages/yaml'

Entering 'packages/zlib'

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/bench

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/debian

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/PDT

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/RDF

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/archive

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/bdb

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/chr

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/clib

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/clpqr

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/cpp

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/cppproxy

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/cql

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/http

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/inclpr

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/jpl

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/libedit

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/ltx2htm

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/nlp

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/odbc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/paxos

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/pcre

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/pengines

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/pldoc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/plunit

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/protobufs

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/readline

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/redis

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/semweb

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/sgml

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/ssl

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/swipl-win

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/table

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/tipc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/utf8proc

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/windows

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/xpce

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/yaml

/Users/theneonryu/Library/Caches/Homebrew/swi-prolog--git/packages/zlib

==> **cmake .. -DSWIPL_PACKAGES_JAVA=OFF -DSWIPL_PACKAGES_X=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/swi-prolog/HEAD-264c8fe/libexec**

==> **make install**

🍺 /usr/local/Cellar/swi-prolog/HEAD-264c8fe: 946 files, 22MB, built in 2 minutes 39 seconds

This disables building xpce …

Indeed it does. I’m not sure how it is getting set. As best I can tell, I have all prerequisites installed. I was assuming a configure step wasn’t happy and set -DSWIPL_PACKAGES_X=OFF because it didn’t see something it wanted to see.

Thanks for your reply — and for creating such an important system.

Someone should probably try to get the Homebrew formulas updated. I once tried, but getting X11 dependency into a formula accepted seems hard. Building a good working SWI-Prolog is a bit hard on the Mac these days. The Xcode clang compiler creates a working, but rather slow system after serious performance regression with Xcode 11. Compiled using a modern GCC version and PGO guided optimization results in a system that is over twice as fast.

If anyone wants to give it a try to create good formulas and get them accepted with the Homebrew project, please do. I’m happy to help.

Thanks for taking the time to explain. It helps knowing why things are goofy.

I’ve never built a Homebrew formula, never mind navigated the Xcode jungle. If you consider it hard, it’s probably a moon shot for me. That said, I’ll try.

It was mostly (too) hard to get the formula accepted with the Homebrew team. They have zillions of guidelines and policies that must be respected. That is fair enough and necessary to avoid a project getting a big mess. Typically if a patch is “close enough” I fix the details and indicate what I changed why. That is IMO a lot more productive than pointing at yet another policy, in particular for one-time contributors.

I had a similar encounter with Macports, but one of the maintainers there kindly made it completely in accordance with their guidelines and I wrote a script to update the Portfile automatically. The Macport releases are smooth now. It should only be possible to select gcc and PGO driven opmization :frowning:

If you want to give it a try, tell me and I’ll see whether I can still find the work I did.

Thanks again. Navigating Homebrew’s guidelines under current circumstances is out of my wheelhouse. Thanks for your Macports work. I’ll head over there.

1 Like

After doing some poking, it’s not at all clear Macports and Homebrew play well together. Is Docker a solid option on Mac?

I guess I’m out of luck for X on Docker too. I guess that makes sense.

?- check_installation.

% Checking your SWI-Prolog kit for common issues ...

%

% Version: ............. 8.3.18

% Address bits: ........ 64

% Architecture: ........ x86_64-linux

% Installed at: ........ /usr/lib/swipl

% Cores: ............... 4

%

% Checking tcmalloc ............................ ok

% Checking gmp ................................. ok

% Loading library(archive) ..................... ok

% Supported filters: bzip2, compress, gzip, grzip, lrzip, lzip, lzma, lzop, none, rpm, uu, xz

% Supported formats: 7zip, ar, cab, cpio, empty, gnutar, iso9660, lha, mtree, rar, raw, tar, xar, zip

% Loading library(cgi) ......................... ok

% Loading library(crypt) ....................... ok

% Loading library(bdb) ......................... ok

% Loading library(double_metaphone) ............ ok

% Loading library(filesex) ..................... ok

% Loading library(http/http_stream) ............ ok

% Loading library(http/json) ................... ok

% Loading library(http/jquery) ................. ok

% jQuery from /usr/lib/swipl/library/http/web/js/jquery-1.11.3.min.js

% Loading library(isub) ........................ ok

Warning: library(jpl) .......................... NOT FOUND

Warning: See http://www.swi-prolog.org/build/issues/jpl.html

% Loading library(memfile) ..................... ok

% Loading library(odbc) ........................ ok

Warning: library(pce) .......................... NOT FOUND

Warning: See http://www.swi-prolog.org/build/issues/xpce.html

% Loading library(pcre) ........................ ok

% Loading library(pdt_console) ................. ok

% Loading library(porter_stem) ................. ok

% Loading library(process) ..................... ok

% Loading library(protobufs) ................... ok

% Loading library(editline) .................... ok

% Loading library(readline) .................... ok

% Loading library(readutil) .................... ok

% Loading library(rlimit) ...................... ok

% Loading library(semweb/rdf_db) ............... ok

% Loading library(semweb/rdf_ntriples) ......... ok

% Loading library(semweb/turtle) ............... ok

% Loading library(sgml) ........................ ok

% Loading library(sha) ......................... ok

% Loading library(snowball) .................... ok

% Loading library(socket) ...................... ok

% Loading library(ssl) ......................... ok

% Loading library(crypto) ...................... ok

% Loading library(syslog) ...................... ok

% Loading library(table) ....................... ok

% Loading library(time) ........................ ok

% Loading library(tipc/tipc) ................... ok

% Loading library(unicode) ..................... ok

% Loading library(uri) ......................... ok

% Loading library(uuid) ........................ ok

% Loading library(zlib) ........................ ok

% Loading library(yaml) ........................ ok

Warning: Found 2 issues.

**true.**

?-

Going to try Debian in VMWare

I tried to see how the whole thing works on my Mac, and it turns out it doesn’t work too well.

First, what works:

I am able to compile from source after installing all dependencies, including gcc, using homebrew. I am able to tell cmake to do what I mean, like this, from inside the build directory (see SWI-Prolog -- Installation on Linux, *BSD (Unix)):

cmake -DCMAKE_C_COMPILER=/usr/bin/gcc \
      -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
      -DCMAKE_INSTALL_PREFIX="$HOME"/bin/swipl \
      -DSWIPL_PACKAGES_JAVA=OFF \
      -DCMAKE_BUILD_TYPE=Release \
      -G Ninja ..

However, now, when I start the graphical editor or debugger, I am getting never seen before warnings and the text is somehow very wide (every character is followed by about two white spaces?).

?- edit(aggregate_all/3).
true.

?- XPCE Xt warning: locale not supported by Xlib, locale set to C
Fontconfig warning: ignoring UTF-8: not a valid region tag

Some googling tells me that many projects suffer from similar issues. I can’t be now bothered to figure out how to fix it :frowning:

This is annoying because I had managed to get it to work after some effort, but now it is broken. I suspect the MacOS upgrades.

Altogether the development experience on a (pretty modern) Mac has been crap. Every time the OS forcefully upgrades itself (every other week), a lot of stuff is broken (like, git doesn’t work) and I need to do this one trick:

xcode-select --install

I won’t complain more, but depending on what you are doing, it might indeed be easier to just do your development on a developer-friendly OS :slight_smile:

1 Like

Some remarks.

  • Using /usr/bin/gcc doesn’t work. These are links to the Xcode clang compiler. If you install gcc using Macports, gcc is named gcc-mp-10 (depending on the version). You find the way the various binary releases are build in scripts/make-distribution.
  • Typically it should be enough to install using the binary bundle from the download page. That version is fully optimized and provides X11 if you install XQuartz. Unfortunately the thing is really brittle recently. Indeed, most MacOS and XQuartz upgrades break the thing over and over again. Sometimes it works to deinstall and reinstall XQuartz. Sometimes it doesn’t. That is, for the App. The commandline version is included in the app and can (normal installation) be found at the location below. That version runs fine
    /Applications/SWI-Prolog.app/Contents/MacOS/swipl
    
  • MacOS locale handling and POSIX applications do not play well. I think most is fixed if you set the LANG environment in your shell’s profile file. I use export LANG=en_GB.UTF-8.

All in all you can develop on a Mac but it is all way more brittle than on a Linux machine.

I run everyday the following shell script to update SWIPL git, without enough knowledge to explain meaning of the script. So far, fortunately, it works for me on macOS Big Sur, emacs, ediprolog mode.

#! /bin/sh
echo " updating swipl ..."
pushd ~/src/swipl-devel/build
git pull

# only for prepare.
# git submodule update --init

echo "Continue ? (Y/n/r(emove cache, then ninja ...))"
stty raw -echo
char=`dd bs=1 count=1 2>/dev/null`
stty -raw echo

if  [ $char == y ]
then
	 echo "Compiling SWI-Prolog."
     continue
elif [ $char == r ]
then
	echo " Removing cmake cache, and Compiling. "
	rm -f "${HOME}/${USER}/src/swipl-devel/build/CMakeCache.txt"
	cmake -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_INSTALL_PREFIX=$HOME -G Ninja ..
	continue
else
	 echo "No updates."
     exit 0
fi

# only on first time
# cmake -DCMAKE_INSTALL_PREFIX=$HOME -G Ninja ..
ninja

# BUILDSWIPL=${HOME}/src/swipl-devel/build/src/swipl
# codesign -s "My Signing Identity" -f ${BUILDSWIPL}
# echo "\nninja codesign done\n"
# ctest -j 8
ninja install


echo "\nDone: swipl built.\n"
# codesign -s "My Signing Identity" -f ${SWIPL}
# echo "\ncodesign done\n"

# dump-pacs
popd;
exit 0
1 Like

You are correct and this is almost evil :slight_smile:

% gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I guess it is gcc-10 when installed with homebrew:

% gcc-10 --version   
gcc-10 (Homebrew GCC 10.2.0_4) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Well, thanks for poking around for me and everyone else. My check_installation. looks good running a snap install on Debian running in VMWare Fusion.

might indeed be easier to just do your development on a developer-friendly OS

Amen.

Again, thanks.