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: fix AC_CHECK_LIB usage #718

Closed
wants to merge 1 commit into from
Closed

configure: fix AC_CHECK_LIB usage #718

wants to merge 1 commit into from

Conversation

HonzaCholasta
Copy link
Contributor

@HonzaCholasta HonzaCholasta commented Apr 18, 2017

Replace empty string with a single space in the third argument of
AC_CHECK_LIB (action-if-found) where applicable.

Empty string in the argument causes AC_CHECK_LIB to use the default
action when a library is found which includes adding the library to LIBS,
which specifies libraries to be linked in every binary and library in the
project.

This fixes libkrad, liblber, libldap_r and libsss_nss_idmap being linked to
every binary and library in IPA, even where unused.

https://pagure.io/freeipa/issue/6846

Replace empty string with a single space in the third argument of
`AC_CHECK_LIB` (`action-if-found`) where applicable.

Empty string in the argument causes `AC_CHECK_LIB` to use the default
action when a library is found which includes adding the library to `LIBS`,
which specifies libraries to be linked in every binary and library in the
project.

This fixes libkrad, liblber, libldap_r and libsss_nss_idmap being linked to
every binary and library in IPA, even where unused.

https://pagure.io/freeipa/issue/6846
@tiran
Copy link
Member

tiran commented Apr 18, 2017

Is this peculiar behavior of AC_CHECK_LIB documented somewhere?

@HonzaCholasta
Copy link
Contributor Author

info autoconf Libraries says:

If ACTION-IF-FOUND is not
specified, the default action prepends -lLIBRARY' to LIBS' and
defines `HAVE_LIBLIBRARY' (in all capitals).

It does not explicitly say what constitutes an unspecified value though.

@lslebodn
Copy link
Contributor

lslebodn commented Apr 18, 2017

It does not explicitly say what constitutes an unspecified value though.

, , or , [] , are considered as unspecified values and therefore default action was used.

BTW it is not peculiar behaviour because most project define custom LIBS using the 3rd argument
and not after invocation of macro.
e.g.

AC_CHECK_HEADER(krad.h, [], [AC_MSG_ERROR([krad.h not found])])
-AC_CHECK_LIB(krad, main, [], [AC_MSG_ERROR([libkrad not found])])
+AC_CHECK_LIB(krad, main, [KRAD_LIBS="-lkrad"], [AC_MSG_ERROR([libkrad not found])])
-KRAD_LIBS="-lkrad"

And link to online documentation https://www.gnu.org/software/autoconf/manual/autoconf.html#Libraries

@lslebodn
Copy link
Contributor

A little bit offtopic. It is interesting that you look for the function main in libkrad. Because it does not exist there. I've just noticed it.

sh# nm --defined-only --dynamic /usr/lib64/libkrad.so
0000000000000000 A HIDDEN
0000000000000000 A krad_0_MIT
0000000000002540 T krad_attr_name2num
00000000000025d0 T krad_attr_num2name
0000000000002780 T krad_attrset_add
0000000000002850 T krad_attrset_add_number
0000000000002a00 T krad_attrset_copy
00000000000028b0 T krad_attrset_del
00000000000026a0 T krad_attrset_free
0000000000002990 T krad_attrset_get
0000000000002630 T krad_attrset_new
0000000000003310 T krad_client_free
00000000000032a0 T krad_client_new
0000000000003380 T krad_client_send
00000000000036c0 T krad_code_name2num
0000000000003750 T krad_code_num2name
0000000000003940 T krad_packet_bytes_needed
0000000000003f70 T krad_packet_decode_request
0000000000004040 T krad_packet_decode_response
00000000000041a0 T krad_packet_encode
00000000000039c0 T krad_packet_free
0000000000004220 T krad_packet_get_attr
00000000000041e0 T krad_packet_get_code
0000000000003b20 T krad_packet_new_request
0000000000003e10 T krad_packet_new_response

@stlaz stlaz self-assigned this Apr 19, 2017
@stlaz
Copy link
Contributor

stlaz commented Apr 19, 2017

This patch seems to have fixed the problem, ACK.

@stlaz stlaz added the ack Pull Request approved, can be merged label Apr 19, 2017
@HonzaCholasta
Copy link
Contributor Author

master:

  • 4322b57 configure: fix AC_CHECK_LIB usage

ipa-4-5:

  • 207864a configure: fix AC_CHECK_LIB usage

@HonzaCholasta HonzaCholasta added the pushed Pull Request has already been pushed label Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
4 participants