Eric Blake <ebb9 <at> byu.net> writes: > This is because test-avltree_oset.c relies on progname.c to provide > program_name. Since m4 didn't use progname.c (only the test programs did), > progname.o is now part of libtests.a rather than ../lib/libm4.a. Yet, the use > of program_name doesn't occur until error.o in ../lib/libm4.a, so progname.o > didn't get linked into the executable when libtests.a was listed first. > > Is this patch okay to apply, or do you think we will ever encounter circular > library dependencies that would require listing libtests.a twice in LDADD, both > before and after ../lib/libm4.a?
And indeed, there can be circular dependencies. I tested the same m4 setup on mingw. If libtests.a is listed first, progname.o is not included. But if it is listed second only, then gl_array_list.o generates a missing link to xmalloc and friends. The only solution is repeating the LDADD. I'm committing the following: From: Eric Blake <[EMAIL PROTECTED]> Date: Mon, 10 Dec 2007 09:54:54 -0700 Subject: [PATCH] Avoid link failures with separate libtests.a. * gnulib-tool (func_emit_tests_Makefile_am): Also list local_ldadd last, to satisfy circular dependencies. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> --- ChangeLog | 6 ++++++ gnulib-tool | 5 ++++- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7af7f9..ed8799b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ 2007-12-11 Eric Blake <[EMAIL PROTECTED]> + + Avoid link failures with separate libtests.a. + * gnulib-tool (func_emit_tests_Makefile_am): Also list local_ldadd + last, to satisfy circular dependencies. + +2007-12-11 Eric Blake <[EMAIL PROTECTED]> and Bruno Haible <[EMAIL PROTECTED]> Fix OpenBSD 4.0 <float.h> handling of long double. diff --git a/gnulib-tool b/gnulib-tool index 39ac977..e70d982 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -1923,7 +1923,10 @@ func_emit_tests_Makefile_am () if $use_libtests; then local_ldadd=' libtests.a $(LIBTESTS_LIBDEPS)' fi - echo "LDADD =${local_ldadd} ${testsbase_inverse}/${sourcebase-lib}/ ${libname}.${libext}" + # local_ldadd must be listed first, since it often depends on non-test + # modules; it must also be listed last, since it can include modules + # such as progname that satisfy dependencies of non-test modules. + echo "LDADD =${local_ldadd} ${testsbase_inverse}/${sourcebase-lib}/ ${libname}.${libext}${local_ldadd}" echo if $use_libtests; then echo "libtests_a_SOURCES =" -- 1.5.3.5