Skip to content

Problematic check for run-time libs availability in autoconf scripts #11114

@jbulow

Description

@jbulow

curl/m4/curl-functions.m4

Lines 5856 to 5876 in f157610

dnl CURL_RUN_IFELSE
dnl -------------------------------------------------
dnl Wrapper macro to use instead of AC_RUN_IFELSE. It
dnl sets LD_LIBRARY_PATH locally for this run only, from the
dnl CURL_LIBRARY_PATH variable. It keeps the LD_LIBRARY_PATH
dnl changes contained within this macro.
AC_DEFUN([CURL_RUN_IFELSE], [
case $host_os in
darwin*)
AC_RUN_IFELSE([AC_LANG_SOURCE([$1])], $2, $3, $4)
;;
*)
old=$LD_LIBRARY_PATH
LD_LIBRARY_PATH=$CURL_LIBRARY_PATH:$old
export LD_LIBRARY_PATH
AC_RUN_IFELSE([AC_LANG_SOURCE([$1])], $2, $3, $4)
LD_LIBRARY_PATH=$old # restore
;;
esac
])

When compiling a projects and its dependencies (curl) with custom compiler flags (such as enabling address sanitizers) this autoconf macro will also test that the compiler can run with the libraries found on the path(s) set in LD_LIBRARY_PATH. This will result in a failure when a library used by both the compiler and curl is used. libz is such a library.

This is how configure fails:

checking for sys/time.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for struct timeval... yes
checking run-time libs availability... failed
configure: error: one or more libs available at link-time are not available run-time. Libs used at link-time: -lpsl -lssl -lcrypto -lssl -lcrypto -lz

Looking in config.log the error is seen:

clang: symbol lookup error: /my_projects_sysroots/lib/libz.so.1: undefined symbol: __asan_option_detect_stack_use_after_return

Running from command line the problem can be reproduced by:

LD_LIBRARY_PATH=/my_projects_sysroots/lib clang
clang: symbol lookup error: /my_projects_sysroots/lib/libz.so.1: undefined symbol: __asan_option_detect_stack_use_after_return

To summarize: LD_LIBRARY_PATH should not be set when compiling conftest.c in the configure script. It should only be set when running the resulting program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions