Skip to content

build failure due to zlib test in configure #4652

Closed

Description

@wesnm

Building on FreeBSD fails due to an issue in configure created in #3974 when "pkg-config --libs zlib" only contains "-lz" and the expression is not guarded in some way, e.g., with "--" or prepending fixed text such as "x"

** using staged installation
expr: illegal option -- l
expr: usage: expr [-e] expression

expr: illegal option -- l
expr: usage: expr [-e] expression

Activity

  1. mattdowle commented on Jul 28, 2020

    @mattdowle
    Member

    Thanks.

    So we're talking about these two lines in configure:

    lib=`pkg-config --libs zlib`
    expr "$lib" : ".*-lz$" >/dev/null
    

    For me, pkg-config --libs zlib contains only -lz on my machine; i.e. it returns -lz only. Could you explain a little more please? Why doesn't that work on FreeBSB? What does pkg-config --libs zlib return for you?

  2. wesnm commented on Jul 28, 2020

    @wesnm
    Author

    There are some differences in the Linux expr and FreeBSD. From the FreeBSD man page:

    Compatibility with previous implementations
    Unless FreeBSD 4.x compatibility is enabled, this version of expr adheres
    to the POSIX Utility Syntax Guidelines, which require that a leading
    argument beginning with a minus sign be considered an option to the
    program. The standard -- syntax may be used to prevent this
    interpretation. However, many historic implementations of expr,

    On my FreeBSD machine:

    [morganw@mercury:~/tmp$]: pkg-config --libs zlib           
    -lz
    [morganw@mercury:~/tmp$]: expr `pkg-config --libs zlib` : '.*-lz$'
    expr: illegal option -- l
    expr: usage: expr [-e] expression
    
    [morganw@mercury:~/tmp$]: expr -- `pkg-config --libs zlib`  : '.*-lz$'
    3
    [morganw@mercury:~/tmp$]: expr x`pkg-config --libs zlib` : '^x.*-lz$'
    4
    

    On a Linux machine:

    [morganw@media:~$]: pkg-config --libs zlib
    -lz
    [morganw@media:~$]: expr `pkg-config --libs zlib` : '.*-lz$'
    3
    [morganw@media:~$]: expr -- `pkg-config --libs zlib` : '.*-lz$'
    3
    [morganw@media:~$]: expr x`pkg-config --libs zlib` : '^x.*-lz$'
    4
    

    The "failure" occurred in 1.12.8 as well, but the end result was a successful build because the src/Makevars file exists in the tree, whereas in 1.13.0 the failure to find zlib causes the configure script to exit before src/Makevars is generated from src/Makevars.in. Perhaps that unconditional exit needs to be reconsidered, given that the OpenMP tests follow it. I don't know how universal the "--" guard for expr is, so perhaps prepending with a string is more portable?

    patch.txt

  3. mattdowle commented on Jul 28, 2020

    @mattdowle
    Member

    Thanks, Morgan! Helps a lot, especially the aspect of not creating Makevars which also occurs in #4640. The Makevars started to be generated in #3984.

    What I had really wanted to do originally was pass the result of pkg-config --libs zlib (i.e. -lz) through to R CMD build somehow. But I didn't know how to do that. So I put the -lz in Makevars (fixed, hardcoded) and added output to configure to tell us if it ever isn't "-lz", or if zlib isn't available, so that users know what to install. But if we're generating Makevars now, then maybe we have a way to pass it through. That would avoid needing to test for "-lz" at all, we could echo the value.

    Thanks again, I think I understand what's going on now.

  4. added this to the 1.13.1 milestone on Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions