Skip to content

Commit 55c8e92

Browse files
committed
libyices: with --enable-static and --with-pic, enforce PIC libgmp.a
One problem I came across was that most of the time, when I was doing ./configure --enable-static --with-pic the produced libyices.a would still contain non-PIC libgmp.a, although being itself PIC. In this commit, I enforce that if --with-pic is given, then: 1) either --with-pic-gmp has been given, in this case we use that for creating the PIC libyices.a; 2) or --with-pic-gmp has not been given and thus we try to simply use the shared gmp through -lgmp. Reminder: we also check that the system libgmp.a or the libgmp.a given with --with-static-gmp is PIC. If it is the case, the PIC libgmp.a will be used for --with-pic.
1 parent 38200b0 commit 55c8e92

2 files changed

Lines changed: 94 additions & 18 deletions

File tree

ext/yices/configure

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14069,7 +14069,7 @@ $SHELL libtool --mode=clean $RM -f conftest.* lib.la 2>&5 >&5
1406914069

1407014070
# If shared library is enabled and --with-pic-gmp is given, test that
1407114071
# it is in fact PIC.
14072-
if test $enable_shared = yes -a "x$pic_libgmp" != x; then
14072+
if test "x$pic_libgmp" != x; then
1407314073

1407414074
testincludedir=""
1407514075
for incldir in $pic_includegmp "$(dirname $pic_libgmp)" "$(dirname $pic_libgmp)/../include"; do
@@ -14246,6 +14246,14 @@ $SHELL libtool --mode=clean $RM -f conftest.* lib.la 2>&5 >&5
1424614246
fi
1424714247
PIC_GMP=$testlib
1424814248
PIC_GMP_INCLUDE_DIR=$testincludedir
14249+
# If the PIC mode is enabled, we want the produced libyices.a to be
14250+
# built against a PIC version of libgmp.a.
14251+
if test $pic_mode = yes; then
14252+
STATIC_GMP=$PIC_GMP
14253+
STATIC_GMP_INCLUDE_DIR=$PIC_GMP_INCLUDE_DIR
14254+
STATIC_GMP_HAS_PIC=yes
14255+
PIC_GMP_HAS_PIC=yes
14256+
fi
1424914257
fi
1425014258
;;
1425114259
mingw* | cygwin*)
@@ -15531,13 +15539,44 @@ fi
1553115539
LIBS=$previous_libs
1553215540

1553315541
STATIC_YICES_USES_SHARED_GMP=no
15534-
if test $enable_static = yes -a "$HAS_STATIC_GMP" != yes; then
15535-
if test "$HAS_SHARED_GMP" != yes; then
15536-
as_fn_error $? "*** You have --enable-static but no static or shared libgmp found." "$LINENO" 5
15537-
as_fn_error $? "*** Try giving --with-static-gmp= or setting LDFLAGS." "$LINENO" 5
15538-
else
15539-
STATIC_LIBS+=" -lgmp"
15540-
STATIC_YICES_USES_SHARED_GMP=yes
15542+
if test $enable_static = yes; then
15543+
if test $pic_mode != yes; then
15544+
# A) Normal static mode: libyices.a is built against either
15545+
# 1) a non-pic libgmp.a
15546+
# or 2) a shared libgmp
15547+
if test "$HAS_STATIC_GMP" != yes; then
15548+
if test "$HAS_SHARED_GMP" != yes; then
15549+
as_fn_error $? "*** You have --enable-static but no static or shared libgmp found." "$LINENO" 5
15550+
as_fn_error $? "*** Try giving --with-static-gmp= or setting LDFLAGS." "$LINENO" 5
15551+
else
15552+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** You have --enable-static and no static libgmp.a found." >&5
15553+
$as_echo "$as_me: WARNING: *** You have --enable-static and no static libgmp.a found." >&2;}
15554+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** You can give --with-static-gmp= or pass LDFLAGS. Defaulting to shared gmp -lgmp." >&5
15555+
$as_echo "$as_me: WARNING: *** You can give --with-static-gmp= or pass LDFLAGS. Defaulting to shared gmp -lgmp." >&2;}
15556+
STATIC_LIBS+=" -lgmp"
15557+
STATIC_YICES_USES_SHARED_GMP=yes
15558+
fi
15559+
fi
15560+
else # $pic_mode = yes
15561+
# B) PIC static mode: libyices.a is built against either
15562+
# 1) a pic libgmp.a
15563+
# or 2) a shared libgmp
15564+
if test "$HAS_PIC_GMP" != yes; then
15565+
if test "$HAS_SHARED_GMP" != yes; then
15566+
as_fn_error $? "*** You have --enable-static and --with-pic but no PIC libgmp.a or shared libgmp found." "$LINENO" 5
15567+
as_fn_error $? "*** Try giving --with-pic-gmp= or setting LDFLAGS." "$LINENO" 5
15568+
else
15569+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** You have --enable-static and --with-pic and no static PIC libgmp.a found." >&5
15570+
$as_echo "$as_me: WARNING: *** You have --enable-static and --with-pic and no static PIC libgmp.a found." >&2;}
15571+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** You can give --with-pic-gmp= or pass LDFLAGS. Defaulting to shared gmp -lgmp." >&5
15572+
$as_echo "$as_me: WARNING: *** You can give --with-pic-gmp= or pass LDFLAGS. Defaulting to shared gmp -lgmp." >&2;}
15573+
STATIC_LIBS+=" -lgmp"
15574+
STATIC_YICES_USES_SHARED_GMP=yes
15575+
fi
15576+
else
15577+
STATIC_GMP=$PIC_GMP
15578+
STATIC_GMP_INCLUDE_DIR=$PIC_GMP_INCLUDE_DIR
15579+
fi
1554115580
fi
1554215581
fi
1554315582

@@ -17776,7 +17815,8 @@ For static library $libyices_a:
1777617815
STATIC_LIBS: $STATIC_LIBS
1777717816
Libgmp.a found: $HAS_STATIC_GMP
1777817817
Libgmp.a path: $STATIC_GMP
17779-
Libgmp.a is pic: $STATIC_GMP_HAS_PIC (non-PIC is faster for the static library)
17818+
Libgmp.a is pic: $STATIC_GMP_HAS_PIC (non-PIC is faster for the static library)
17819+
PIC mode for libyices.a: $pic_mode
1778017820
Use shared gmp instead of libgmp.a: $STATIC_YICES_USES_SHARED_GMP
1778117821
Embed gmp in libyices.a: $GMP_EMBEDDED
1778217822

ext/yices/configure.ac

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ case $host_os,$FORCE_SHARED_GMP in
387387

388388
# If shared library is enabled and --with-pic-gmp is given, test that
389389
# it is in fact PIC.
390-
if test $enable_shared = yes -a "x$pic_libgmp" != x; then
390+
if test "x$pic_libgmp" != x; then
391391
CSL_CHECK_HEADER([gmp.h],[$pic_includegmp "$(dirname $pic_libgmp)" "$(dirname $pic_libgmp)/../include"],--with-pic-gmp-include-dir)
392392
CSL_CHECK_LIB_PATH($pic_libgmp,--with-pic-gmp)
393393
CSL_CHECK_GMP($testlib,$testincludedir)
@@ -405,6 +405,14 @@ case $host_os,$FORCE_SHARED_GMP in
405405
fi
406406
PIC_GMP=$testlib
407407
PIC_GMP_INCLUDE_DIR=$testincludedir
408+
# If the PIC mode is enabled, we want the produced libyices.a to be
409+
# built against a PIC version of libgmp.a.
410+
if test $pic_mode = yes; then
411+
STATIC_GMP=$PIC_GMP
412+
STATIC_GMP_INCLUDE_DIR=$PIC_GMP_INCLUDE_DIR
413+
STATIC_GMP_HAS_PIC=yes
414+
PIC_GMP_HAS_PIC=yes
415+
fi
408416
fi
409417
;;
410418
mingw* | cygwin*)
@@ -709,13 +717,40 @@ AC_SUBST(HAS_SHARED_GMP)
709717
LIBS=$previous_libs
710718

711719
STATIC_YICES_USES_SHARED_GMP=no
712-
if test $enable_static = yes -a "$HAS_STATIC_GMP" != yes; then
713-
if test "$HAS_SHARED_GMP" != yes; then
714-
AC_MSG_ERROR([*** You have --enable-static but no static or shared libgmp found.])
715-
AC_MSG_ERROR([*** Try giving --with-static-gmp= or setting LDFLAGS.])
716-
else
717-
STATIC_LIBS+=" -lgmp"
718-
STATIC_YICES_USES_SHARED_GMP=yes
720+
if test $enable_static = yes; then
721+
if test $pic_mode != yes; then
722+
# A) Normal static mode: libyices.a is built against either
723+
# 1) a non-pic libgmp.a
724+
# or 2) a shared libgmp
725+
if test "$HAS_STATIC_GMP" != yes; then
726+
if test "$HAS_SHARED_GMP" != yes; then
727+
AC_MSG_ERROR([*** You have --enable-static but no static or shared libgmp found.])
728+
AC_MSG_ERROR([*** Try giving --with-static-gmp= or setting LDFLAGS.])
729+
else
730+
AC_MSG_WARN([*** You have --enable-static and no static libgmp.a found.])
731+
AC_MSG_WARN([*** You can give --with-static-gmp= or pass LDFLAGS. Defaulting to shared gmp -lgmp.])
732+
STATIC_LIBS+=" -lgmp"
733+
STATIC_YICES_USES_SHARED_GMP=yes
734+
fi
735+
fi
736+
else # $pic_mode = yes
737+
# B) PIC static mode: libyices.a is built against either
738+
# 1) a pic libgmp.a
739+
# or 2) a shared libgmp
740+
if test "$HAS_PIC_GMP" != yes; then
741+
if test "$HAS_SHARED_GMP" != yes; then
742+
AC_MSG_ERROR([*** You have --enable-static and --with-pic but no PIC libgmp.a or shared libgmp found.])
743+
AC_MSG_ERROR([*** Try giving --with-pic-gmp= or setting LDFLAGS.])
744+
else
745+
AC_MSG_WARN([*** You have --enable-static and --with-pic and no static PIC libgmp.a found.])
746+
AC_MSG_WARN([*** You can give --with-pic-gmp= or pass LDFLAGS. Defaulting to shared gmp -lgmp.])
747+
STATIC_LIBS+=" -lgmp"
748+
STATIC_YICES_USES_SHARED_GMP=yes
749+
fi
750+
else
751+
STATIC_GMP=$PIC_GMP
752+
STATIC_GMP_INCLUDE_DIR=$PIC_GMP_INCLUDE_DIR
753+
fi
719754
fi
720755
fi
721756
AC_SUBST(STATIC_LIBS)
@@ -862,7 +897,8 @@ For static library $libyices_a:
862897
STATIC_LIBS: $STATIC_LIBS
863898
Libgmp.a found: $HAS_STATIC_GMP
864899
Libgmp.a path: $STATIC_GMP
865-
Libgmp.a is pic: $STATIC_GMP_HAS_PIC (non-PIC is faster for the static library)
900+
Libgmp.a is pic: $STATIC_GMP_HAS_PIC (non-PIC is faster for the static library)
901+
PIC mode for libyices.a: $pic_mode
866902
Use shared gmp instead of libgmp.a: $STATIC_YICES_USES_SHARED_GMP
867903
Embed gmp in libyices.a: $GMP_EMBEDDED
868904

0 commit comments

Comments
 (0)