Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: resolve conflict with AC_CHECK_HEADERS #766

Closed
wants to merge 4 commits into from

Conversation

Irfy
Copy link

@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
Copy link
Author

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
Copy link
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
Copy link
Author

Irfy commented Apr 15, 2016

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
Copy link
Author

Irfy commented Apr 15, 2016

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

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.
@Irfy
Copy link
Author

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 3 commits April 17, 2016 17:01
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_`.
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.
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 curl#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 curl#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_*.
@Irfy
Copy link
Author

Irfy commented Apr 17, 2016

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
Copy link
Member

bagder commented Apr 21, 2016

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

@bagder bagder closed this Apr 21, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants