[PATCH] fix --with-gmp-build= when gmp builddir != srcdir

This patch does two things:
* fixes logic error introduced in 1f0282c0 * allows --with-gmp-build= to work when gmp was built not in the source directory.
Note that --with-gmp-build= still doesn't work when --enable-shared is specified (--disable-shared is ok).
This patch is required to restore possibility to build gmp and ppl in a combined tree with gcc.
--- m4/ac_check_gmp.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Index: ppl/m4/ac_check_gmp.m4 =================================================================== --- ppl.orig/m4/ac_check_gmp.m4 +++ ppl/m4/ac_check_gmp.m4 @@ -57,13 +57,14 @@ AC_ARG_WITH(gmp-build, AS_HELP_STRING([--with-gmp-build=DIR], [use a non-installed build of GMP in DIR]), gmp_build_dir=$with_gmp_build - if test -n "$with_gmp" \ - || test -n "$with_gmp_include" || test -n "$with_gmp_lib" + if test -z "$with_gmp" && test -z "$with_gmp_include" && test -z "$with_gmp_lib" then gmp_include_options="-I$gmp_build_dir -I$gmp_build_dir/tune" gmp_library_paths="$gmp_build_dir$PATH_SEPARATOR$gmp_build_dir/.libs:$gmp_build_dir/tune" gmp_library_options="-L$gmp_build_dir -L$gmp_build_dir/.libs" gmp_library_options="$gmp_library_options -L$gmp_build_dir/tune" + gmp_srcdir=`echo @abs_srcdir@ | $gmp_build_dir/config.status --file=-` + gmp_include_options="$gmp_include_options -I$gmp_srcdir" else AC_MSG_ERROR([cannot use --with-gmp-build and other --with-gmp* options together]) fi)

On 11/05/11 21:52, Serge Belyshev wrote:
This patch does two things:
- fixes logic error introduced in 1f0282c0
- allows --with-gmp-build= to work when gmp was built not in the source directory.
Note that --with-gmp-build= still doesn't work when --enable-shared is specified (--disable-shared is ok).
This patch is required to restore possibility to build gmp and ppl in a combined tree with gcc.
Thanks Serge! Concerning the joint use of --with-gmp-build= and --enable-shared, I guess the problem is that the dynamic linker/loader must be taught where to find the GMP library just build. What might be a portable way to do that? Thanks again,
Roberto

Roberto Bagnara bagnara@cs.unipr.it writes:
Concerning the joint use of --with-gmp-build= and --enable-shared, I guess the problem is that the dynamic linker/loader must be taught where to find the GMP library just build. What might be a portable way to do that?
The problem is that @extra_libraries@ was not set for ppl-config. Here is a better patch, using libtool to find gmp libs:
--- m4/ac_check_gmp.m4 | 17 ++++++++++------- src/Makefile.am | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-)
Index: ppl/m4/ac_check_gmp.m4 =================================================================== --- ppl.orig/m4/ac_check_gmp.m4 +++ ppl/m4/ac_check_gmp.m4 @@ -53,23 +53,25 @@ then gmp_library_options="-L$gmp_library_paths" fi
+gmp_libs="-lgmpxx -lgmp" + AC_ARG_WITH(gmp-build, AS_HELP_STRING([--with-gmp-build=DIR], [use a non-installed build of GMP in DIR]), gmp_build_dir=$with_gmp_build - if test -n "$with_gmp" \ - || test -n "$with_gmp_include" || test -n "$with_gmp_lib" + if test -z "$with_gmp" && test -z "$with_gmp_include" && test -z "$with_gmp_lib" then - gmp_include_options="-I$gmp_build_dir -I$gmp_build_dir/tune" - gmp_library_paths="$gmp_build_dir$PATH_SEPARATOR$gmp_build_dir/.libs:$gmp_build_dir/tune" - gmp_library_options="-L$gmp_build_dir -L$gmp_build_dir/.libs" - gmp_library_options="$gmp_library_options -L$gmp_build_dir/tune" + gmp_srcdir=`echo @abs_srcdir@ | $gmp_build_dir/config.status --file=-` + gmp_include_options="-I$gmp_build_dir -I$gmp_srcdir" + gmp_libs="$gmp_build_dir/libgmp.la $gmp_build_dir/libgmpxx.la" else AC_MSG_ERROR([cannot use --with-gmp-build and other --with-gmp* options together]) fi)
-gmp_library_options="$gmp_library_options -lgmpxx -lgmp" +gmp_library_options="$gmp_library_options $gmp_libs"
+ac_save_CXX="$CXX" +CXX="libtool --mode=link $CXX" ac_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $gmp_include_options" ac_save_LIBS="$LIBS" @@ -220,4 +222,5 @@ AC_LANG_POP(C++) eval $shared_library_path_env_var="$ac_save_shared_library_path" LIBS="$ac_save_LIBS" CPPFLAGS="$ac_save_CPPFLAGS" +CXX="$ac_save_CXX" ]) Index: ppl/src/Makefile.am =================================================================== --- ppl.orig/src/Makefile.am +++ ppl/src/Makefile.am @@ -81,7 +81,7 @@ ppl-config.cc \ ppl.hh
ppl_config_LDADD = \ -libppl.la +libppl.la @extra_libraries@
if USE_NATIVE_INTEGERS

Here is an incremental version of an updated patch with fix for --enable-shared on top of current HEAD:
--- m4/ac_check_gmp.m4 | 11 +++++++---- src/Makefile.am | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-)
Index: ppl/m4/ac_check_gmp.m4 =================================================================== --- ppl.orig/m4/ac_check_gmp.m4 +++ ppl/m4/ac_check_gmp.m4 @@ -53,6 +53,8 @@ then gmp_library_options="-L$gmp_library_paths" fi
+gmp_libs="-lgmpxx -lgmp" + AC_ARG_WITH(gmp-build, AS_HELP_STRING([--with-gmp-build=DIR], [use a non-installed build of GMP in DIR]), @@ -62,15 +64,15 @@ AC_ARG_WITH(gmp-build, then AC_MSG_ERROR([cannot use --with-gmp-build and other --with-gmp* options together]) else - gmp_library_paths="$gmp_build_dir$PATH_SEPARATOR$gmp_build_dir/.libs:$gmp_build_dir/tune" - gmp_library_options="-L$gmp_build_dir -L$gmp_build_dir/.libs" - gmp_library_options="$gmp_library_options -L$gmp_build_dir/tune" gmp_srcdir=`echo @abs_srcdir@ | $gmp_build_dir/config.status --file=-` gmp_include_options="-I$gmp_build_dir -I$gmp_build_dir/tune -I$gmp_srcdir" + gmp_libs="$gmp_build_dir/libgmp.la $gmp_build_dir/libgmpxx.la" fi)
-gmp_library_options="$gmp_library_options -lgmpxx -lgmp" +gmp_library_options="$gmp_library_options $gmp_libs"
+ac_save_CXX="$CXX" +CXX="libtool --mode=link $CXX" ac_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $gmp_include_options" ac_save_LIBS="$LIBS" @@ -221,4 +223,5 @@ AC_LANG_POP(C++) eval $shared_library_path_env_var="$ac_save_shared_library_path" LIBS="$ac_save_LIBS" CPPFLAGS="$ac_save_CPPFLAGS" +CXX="$ac_save_CXX" ]) Index: ppl/src/Makefile.am =================================================================== --- ppl.orig/src/Makefile.am +++ ppl/src/Makefile.am @@ -81,7 +81,7 @@ ppl-config.cc \ ppl.hh
ppl_config_LDADD = \ -libppl.la +libppl.la @extra_libraries@
if USE_NATIVE_INTEGERS

On 11/06/11 13:30, Serge Belyshev wrote:
Here is an incremental version of an updated patch with fix for --enable-shared on top of current HEAD:
Thanks a lot Serge.

Roberto Bagnara bagnara@cs.unipr.it writes:
Thanks a lot Serge.
You are welcome.
The patch needs a follow-up though: below is a fix for the case when libtool cannot guess language from compiler name (which actually happens when PPL is built with gcc in a combined tree):
--- m4/ac_check_gmp.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Index: ppl/m4/ac_check_gmp.m4 =================================================================== --- ppl.orig/m4/ac_check_gmp.m4 +++ ppl/m4/ac_check_gmp.m4 @@ -72,7 +72,7 @@ AC_ARG_WITH(gmp-build, gmp_library_options="$gmp_library_options $gmp_libs"
ac_save_CXX="$CXX" -CXX="libtool --mode=link $CXX" +CXX="libtool --mode=link --tag=CXX $CXX" ac_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $gmp_include_options" ac_save_LIBS="$LIBS"
participants (2)
-
Roberto Bagnara
-
Serge Belyshev