configure: resolve conflict with AC_CHECK_HEADERS #766

Closed
wants to merge 4 commits into
from

Projects

None yet

2 participants

@Irfy
Irfy commented Apr 14, 2016

AC_CHECK_HEADERS produces `ac_cv_header_*_h' cache variables, which
conflict with curl-specific header check for windows.h. By renaming the
variable used by curl, any conflict with other projects and shared
config.caches is resolved. The conflict occurs under CYGWIN, as
AC_CHECK_HEADERS (from a different project) will set
ac_cv_header_windows_h=1, while the expected value for curl is 0.

@Irfy
Irfy commented Apr 14, 2016

According to autoconf docs curl ought to use the curl_cv_* prefix for variables not directly created by AC_* macros.

There are 16 such variables, and an alternative to this patch would be to rename them all to curl_cv_*.

@bagder bagder added the build label Apr 15, 2016
@bagder
Member
bagder commented Apr 15, 2016

Yes, I think they all should be renamed to use the curl_cv_ prefix. You think you can update the patch to do that? Will that change fix #603 ?

@Irfy
Irfy commented Apr 15, 2016 edited

I agree that fixing them all is the Right thing to do.

On second analysis, there are 107 ac_cv_* variables and 281 references in
curl's configure.ac and m4 files combined, just so you know the diff will
be big. It's likely that some of those are proper ac_cv_* variable
references, but most will likely be curl-specific, I'll look into it later
today.

@Irfy
Irfy commented Apr 15, 2016 edited

And yes, this fix would fix #603 and any other similar conflict.

Irfan Adilovic configure: ac_cv_ -> curl_cv_ for all cached vars
This was automated by:

sed -b -i -f <(ack -A1 AC_CACHE_CHECK | \
               ack -o 'ac_cv_.*?\b' | \
               sort -u | xargs -n1 bash -c \
                    'echo "s/$0/curl_cv_${0#ac_cv_}/g"') \
    $(git ls-files)

This only changed the prefix for 16 variables actually checked with
AC_CACHE_CHECK.
80eeebc
@Irfy
Irfy commented Apr 15, 2016

The following 71 ac_cv_* variables are modified in curl m4 macros, which makes them candidates for renaming, but they are never used within AC_CACHE_CHECK, which makes the _cv_ part of their name meaningless (they are cached but the cached values are never taken into account). They should either be renamed to curl_* and left at that, or to curl_cv_* with appropriately added AC_CACHE_CHECK checks. Since checking them with AC_CACHE_CHECK is preferable, I'm going to rename them to curl_cv_* and leave the AC_CACHE_CHECK addition for someone else / some later time.

Note that some of the variables, like the #603's ac_cv_func_gethostbyname is not going to be trivial to cache, as each level of checking (i.e. -lnsl, -lsocket, -lwatt, ...) would require a separate variable for each of the various library checks. Best would be to cache the actual result "what needs to be included in LIBS for gethostbyname" -- but all this is a separate issue.

ac_cv_func_alarm
ac_cv_func_basename
ac_cv_func_clock_gettime
ac_cv_func_closesocket
ac_cv_func_closesocket_camel
ac_cv_func_connect
ac_cv_func_fcntl
ac_cv_func_fcntl_o_nonblock
ac_cv_func_fdopen
ac_cv_func_fgetxattr
ac_cv_func_flistxattr
ac_cv_func_freeaddrinfo
ac_cv_func_freeifaddrs
ac_cv_func_fremovexattr
ac_cv_func_fsetxattr
ac_cv_func_ftruncate
ac_cv_func_gai_strerror
ac_cv_func_getaddrinfo
ac_cv_func_getaddrinfo_threadsafe
ac_cv_func_gethostbyaddr
ac_cv_func_gethostbyaddr_r
ac_cv_func_gethostbyname
ac_cv_func_gethostbyname_r
ac_cv_func_gethostname
ac_cv_func_getifaddrs
ac_cv_func_getnameinfo
ac_cv_func_getservbyport_r
ac_cv_func_getxattr
ac_cv_func_gmtime_r
ac_cv_func_inet_ntoa_r
ac_cv_func_inet_ntop
ac_cv_func_inet_pton
ac_cv_func_ioctl
ac_cv_func_ioctl_fionbio
ac_cv_func_ioctl_siocgifaddr
ac_cv_func_ioctlsocket
ac_cv_func_ioctlsocket_camel
ac_cv_func_ioctlsocket_camel_fionbio
ac_cv_func_ioctlsocket_fionbio
ac_cv_func_listxattr
ac_cv_func_localtime_r
ac_cv_func_memrchr
ac_cv_func_pipe
ac_cv_func_poll
ac_cv_func_recv
ac_cv_func_removexattr
ac_cv_func_select
ac_cv_func_send
ac_cv_func_setsockopt
ac_cv_func_setsockopt_so_nonblock
ac_cv_func_setxattr
ac_cv_func_sigaction
ac_cv_func_siginterrupt
ac_cv_func_signal
ac_cv_func_sigsetjmp
ac_cv_func_socket
ac_cv_func_socketpair
ac_cv_func_strcasecmp
ac_cv_func_strcmpi
ac_cv_func_strdup
ac_cv_func_strerror_r
ac_cv_func_stricmp
ac_cv_func_strncasecmp
ac_cv_func_strncmpi
ac_cv_func_strnicmp
ac_cv_func_strstr
ac_cv_func_strtok_r
ac_cv_func_strtoll
ac_cv_func_writev
ac_cv_header_stdint_h
ac_cv_sig_atomic_t_volatile

Irfan Adilovic added some commits Apr 17, 2016
Irfan Adilovic configure: ac_cv_func_clock_gettime -> curl_...
This variable must not be cached in its current form, as any cached
information will prevent the next configure run from determining the
correct LIBS needed for the function. Thus, rename prefix `ac_cv_` to
just `curl_`.
65aa591
Irfan Adilovic configure: ac_cv_ -> curl_cv_ for r/w vars
These configure vars are modified in a curl-specific way and modified by
the configure process, but are never loaded from cache, even though they
are designated as _cv_. We should implement proper AC_CACHE_CHECKs for
them eventually.
295df18
Irfan Adilovic configure: ac_cv_ -> curl_cv_ for write-only vars
These configure vars are modified in a curl-specific way but never
evaluated or loaded from cache, even though they are designated as
_cv_. We could either implement proper AC_CACHE_CHECKs for them, or
remove them completely.

Fixes #603 as ac_cv_func_gethostbyname is no longer clobbered, and
AC_CHECK_FUNC(gethostbyname...) will no longer spuriously succeed after
the first configure run with caching.

`ac_cv_func_strcasecmp` is curious, see #770.

`eval "ac_cv_func_$func=yes"` can still cause problems as it works in
tandem with AC_CHECK_FUNCS and then potentially modifies its result. It
would be best to rewrite this test to use a new CURL_CHECK_FUNCS macro,
which works the same as AC_CHECK_FUNCS but relies on caching the values
of curl_cv_func_* variables, without modifiying ac_cv_func_*.
fdf5b5c
@Irfy
Irfy commented Apr 17, 2016 edited

I have now renamed the variables, inspecting each single one to make sure it's correct to rename them. A few ac_cv_ variables rename remain, with mostly correct usage. One offender is reported in #770.

The other one is a major call to AC_CHECK_FUNCS in configure.ac:3299-3337 with potential modification of the ac_cv_func_* variables in its handling of action-if-not-found case. I've documented what could be done about that in the commit message itself, but I'd leave it for now. (Also, I'm highly curious as to how that handling is any "deeper" than AC_CHECK_FUNCS by itself)

@bagder
Member
bagder commented Apr 21, 2016

Thanks a bunch, this is now merged as of commit d9f3b36.

@bagder bagder closed this Apr 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment