Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh/pcre module breakage when static build enabled



On 2018-03-20 at 00:33 +0700, Vadim A. Misbakh-Soloviov wrote:
> Hi there!
> I faced strange issue: when I build zsh-5.4.2 as static binary and trying to 
> run, for example, something like that:
> 
> > $  [[ 'foo→bar' =~ .([^[:ascii:]]). ]]; print $MATCH
> 
> I'm getting following errors:
> 
> > zsh: module `zsh/pcre' has no such feature: `C:pcre-match'
> > zsh: -pcre-match not available for regex
> 
> Although, when I rebuild it as dynamically linked binary, pcre starting to 
> work again
> 
> I think, it looks like a bug.
> 
> Isn't it a way to fix it?

I went to do a static build on FreeBSD (Darwin doesn't support static
binaries) and when grabbing the configure options used by Ports, saw
this:

  ## Some modules can only be built as a shared library.
  ## If you enable STATIC, you may get strange errors if you, a script,
  ## or a plugin tries to use the regex module.

So someone has spotted this before, but I don't recall seeing a
bug-report.

I can't reproduce on FreeBSD, as long as I follow the 'INSTALL'
instructions.  Perhaps it could be made easier to build static shells
with variant features, but I suspect that if you really need a static
shell, you can follow the steps.

Here's what I did.  Did you perhaps skip the '--disable-dynamic' option,
required to change how zsh manages the module code when building
statically?

----------------8< zsh build zsh-5.4.2-198-gd2350a1e8 >8----------------
git pull
git status
git clean -fxd
./.preconfig
CPPFLAGS=-I/usr/local/include LDFLAGS='-L/usr/local/lib -static' \
  ./configure --prefix=$HOME/uzsh \
    --enable-etcdir=/etc --with-tcsetpgrp \
    --enable-function-subdirs --enable-maildir-support \
    --enable-multibyte --enable-zsh-mem --enable-zsh-secure-free \
    --sysconfdir=/usr/local \
    --disable-dynamic --with-term-lib="tinfow tinfo" \
    --enable-pcre --disable-dynamic
sed -Ei '' -e '/name=zsh\/(pcre|regex)/s/link=no/link=static/' config.modules
make && make install.bin install.modules install.fns

~/uzsh/bin/zsh -f

tower% [[ 'foo→bar' =~ .([^[:ascii:]]). ]]; print $MATCH
zsh: failed to compile regex: invalid character class

tower% setopt rematchpcre
tower% [[ 'foo→bar' =~ .([^[:ascii:]]). ]]; print $MATCH
o→b
----------------8< zsh build zsh-5.4.2-198-gd2350a1e8 >8----------------

I just rebuilt with 'config.modules' saying 'link=static' for every
module except: zsh/attr, zsh/db/gdbm, zsh/example

I can use the resulting shell quite well.  It even functions well enough
to display my prompt, which is a bit of a torture test. :^)

-Phil



Messages sorted by: Reverse Date, Date, Thread, Author