public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/build] Check if libsource-highlight is usable
@ 2021-11-19 12:34 Tom de Vries
  2021-11-19 15:16 ` Lancelot SIX
  2021-11-19 15:56 ` Andrew Burgess
  0 siblings, 2 replies; 7+ messages in thread
From: Tom de Vries @ 2021-11-19 12:34 UTC (permalink / raw)
  To: gdb-patches

When building gdb with g++ 4.8.5, I ran into:
...
ld: source-cache.o: in function `source_cache::ensure(symtab*)':
source-cache.c:207: undefined reference to \
  srchilite::SourceHighlight::SourceHighlight(std::string const&)
...

[ I configured gdb without explicit settings related to source-highlight, so
we're excercising the enable_source_highlight=auto scenario. ]

The problem is that:
- the source-highlight library is build with system compiler
  g++ 7.5.0 which uses the new libstdc++ library abi (see
  https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
- gdb is build using g++ 4.8.5 which uses the old abi.

[ There's a compatibility macro _GLIBCXX_USE_CXX11_ABI, but that doesn't work
for this case.  Instead, it enables the opposite case where the
source-highlight library is build with g++ 4.8.5 and gdb is build with
g++ 7.5.0. ]

Fix this by checking whether the source-highlight library is usable during
configuration.

In the enable_source_highlight=auto scenario, this allows the build to skip
the unusable library and finish successfully.

In the enable_source_highlight=yes scenario, this allows the build to error
out earlier.

Tested on x86_64-linux.
---
 gdb/configure    | 158 ++++++++++++++++++++++++++++++++---------------
 gdb/configure.ac |  47 ++++++++++++--
 2 files changed, 151 insertions(+), 54 deletions(-)

diff --git a/gdb/configure b/gdb/configure
index 6e2dfb766c8..aaa622d9fcc 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -2367,6 +2367,52 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
+# ac_fn_cxx_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_link
+
 # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
 # -------------------------------------------
 # Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -2524,52 +2570,6 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_member
 
-# ac_fn_cxx_try_link LINENO
-# -------------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_cxx_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_link
-
 # ac_fn_cxx_check_func LINENO FUNC VAR
 # ------------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -12103,13 +12103,73 @@ $as_echo "no - pkg-config not found" >&6; }
           ;;
       esac
 
-      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
-      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
+      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
+      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
+
+      # Now that we have found a source-highlight library, check if we can use
+      # it.  In particular, we're trying to detect the situation that the
+      # library is using the new libstdc++ library abi ( see
+      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
+      # while the compiler being used to compile gdb is using the old abi.
+      # Such a situation will result in an undefined reference to
+      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
+      # This situation can occur when f.i. using a source highlight library
+      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
+      ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+      save_CFLAGS=$CFLAGS
+      save_LDFLAGS=$LDFLAGS
+      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
+      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <srchilite/sourcehighlight.h>
+int
+main ()
+{
+std::string outlang = "esc.outlang";
+           new srchilite::SourceHighlight (outlang);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  have_usable_source_highlight=yes
+else
+  have_usable_source_highlight=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+      CFLAGS="$SAVE_CFLAGS"
+      LDFLAGS="$SAVE_LDFLAGS"
+      ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+      if test "${have_usable_source_highlight}" = "yes"; then
 
 $as_echo "#define HAVE_SOURCE_HIGHLIGHT 1" >>confdefs.h
 
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
+        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
+        SRCHIGH_LIBS="$srchigh_pkg_libs"
+      else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	if test "${enable_source_highlight}" = "yes"; then
+          as_fn_error $? "source-highlight in your system could not be used" "$LINENO" 5
+        fi
+      fi
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
diff --git a/gdb/configure.ac b/gdb/configure.ac
index d4cfb6a7624..e4fed3c575c 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1248,11 +1248,48 @@ either use --disable-source-highlight or dnl
           ;;
       esac
 
-      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
-      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
-      AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
-                [Define to 1 if the source-highlight library is available])
-      AC_MSG_RESULT([yes])
+      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
+      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
+
+      # Now that we have found a source-highlight library, check if we can use
+      # it.  In particular, we're trying to detect the situation that the
+      # library is using the new libstdc++ library abi ( see
+      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
+      # while the compiler being used to compile gdb is using the old abi.
+      # Such a situation will result in an undefined reference to
+      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
+      # This situation can occur when f.i. using a source highlight library
+      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
+      AC_LANG_PUSH(C++)
+      save_CFLAGS=$CFLAGS
+      save_LDFLAGS=$LDFLAGS
+      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
+      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+          [#include <srchilite/sourcehighlight.h>],
+          [std::string outlang = "esc.outlang";
+           new srchilite::SourceHighlight (outlang);]
+        )],
+        [have_usable_source_highlight=yes],
+        [have_usable_source_highlight=no]
+      )
+      CFLAGS="$SAVE_CFLAGS"
+      LDFLAGS="$SAVE_LDFLAGS"
+      AC_LANG_POP(C++)
+
+      if test "${have_usable_source_highlight}" = "yes"; then
+        AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
+                  [Define to 1 if the source-highlight library is available])
+        AC_MSG_RESULT([yes])
+        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
+        SRCHIGH_LIBS="$srchigh_pkg_libs"
+      else
+	AC_MSG_RESULT([no])
+	if test "${enable_source_highlight}" = "yes"; then
+          AC_MSG_ERROR([source-highlight in your system could not be used])
+        fi
+      fi
     else
       AC_MSG_RESULT([no])
       if test "${enable_source_highlight}" = "yes"; then

base-commit: fd0ff19bf435b267caae6a1ae04e7b4a4ba64f5b
-- 
2.26.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] [gdb/build] Check if libsource-highlight is usable
  2021-11-19 12:34 [PATCH] [gdb/build] Check if libsource-highlight is usable Tom de Vries
@ 2021-11-19 15:16 ` Lancelot SIX
  2021-11-19 15:22   ` Tom de Vries
  2021-11-19 15:56 ` Andrew Burgess
  1 sibling, 1 reply; 7+ messages in thread
From: Lancelot SIX @ 2021-11-19 15:16 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index d4cfb6a7624..e4fed3c575c 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -1248,11 +1248,48 @@ either use --disable-source-highlight or dnl
>            ;;
>        esac
>  
> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
> -      AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
> -                [Define to 1 if the source-highlight library is available])
> -      AC_MSG_RESULT([yes])
> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
> +
> +      # Now that we have found a source-highlight library, check if we can use
> +      # it.  In particular, we're trying to detect the situation that the
> +      # library is using the new libstdc++ library abi ( see
> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
> +      # while the compiler being used to compile gdb is using the old abi.
> +      # Such a situation will result in an undefined reference to
> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
> +      # This situation can occur when f.i. using a source highlight library
> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
> +      AC_LANG_PUSH(C++)
> +      save_CFLAGS=$CFLAGS
> +      save_LDFLAGS=$LDFLAGS
> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
> +      AC_LINK_IFELSE(
> +        [AC_LANG_PROGRAM(
> +          [#include <srchilite/sourcehighlight.h>],
> +          [std::string outlang = "esc.outlang";
> +           new srchilite::SourceHighlight (outlang);]
> +        )],
> +        [have_usable_source_highlight=yes],
> +        [have_usable_source_highlight=no]
> +      )
> +      CFLAGS="$SAVE_CFLAGS"
> +      LDFLAGS="$SAVE_LDFLAGS"
> +      AC_LANG_POP(C++)
> +
> +      if test "${have_usable_source_highlight}" = "yes"; then
> +        AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
> +                  [Define to 1 if the source-highlight library is available])
> +        AC_MSG_RESULT([yes])
> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
> +      else
> +	AC_MSG_RESULT([no])
> +	if test "${enable_source_highlight}" = "yes"; then

Hi,

I do not know what it the indentation policy for the configure.ac file,
but you use tabs in the 'AC_MSG_RESULT' and 'if test' lines above (2
lines above), and nowhere else.

The rest of the file does not seem to be completely consistent regarding
this particular subject, so I do not know if there is a preferred
formatting that should be used, but I guess that having the same across
the patch could make sense.

Otherwise, and for what it is worth, this looks reasonable to me.

Best,
Lancelot.

> +          AC_MSG_ERROR([source-highlight in your system could not be used])
> +        fi
> +      fi 
>      else
>        AC_MSG_RESULT([no])
>        if test "${enable_source_highlight}" = "yes"; then
> 
> base-commit: fd0ff19bf435b267caae6a1ae04e7b4a4ba64f5b
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] [gdb/build] Check if libsource-highlight is usable
  2021-11-19 15:16 ` Lancelot SIX
@ 2021-11-19 15:22   ` Tom de Vries
  0 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2021-11-19 15:22 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: gdb-patches

On 11/19/21 4:16 PM, Lancelot SIX wrote:
>> diff --git a/gdb/configure.ac b/gdb/configure.ac
>> index d4cfb6a7624..e4fed3c575c 100644
>> --- a/gdb/configure.ac
>> +++ b/gdb/configure.ac
>> @@ -1248,11 +1248,48 @@ either use --disable-source-highlight or dnl
>>            ;;
>>        esac
>>  
>> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
>> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
>> -      AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
>> -                [Define to 1 if the source-highlight library is available])
>> -      AC_MSG_RESULT([yes])
>> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
>> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
>> +
>> +      # Now that we have found a source-highlight library, check if we can use
>> +      # it.  In particular, we're trying to detect the situation that the
>> +      # library is using the new libstdc++ library abi ( see
>> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
>> +      # while the compiler being used to compile gdb is using the old abi.
>> +      # Such a situation will result in an undefined reference to
>> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
>> +      # This situation can occur when f.i. using a source highlight library
>> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
>> +      AC_LANG_PUSH(C++)
>> +      save_CFLAGS=$CFLAGS
>> +      save_LDFLAGS=$LDFLAGS
>> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
>> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
>> +      AC_LINK_IFELSE(
>> +        [AC_LANG_PROGRAM(
>> +          [#include <srchilite/sourcehighlight.h>],
>> +          [std::string outlang = "esc.outlang";
>> +           new srchilite::SourceHighlight (outlang);]
>> +        )],
>> +        [have_usable_source_highlight=yes],
>> +        [have_usable_source_highlight=no]
>> +      )
>> +      CFLAGS="$SAVE_CFLAGS"
>> +      LDFLAGS="$SAVE_LDFLAGS"
>> +      AC_LANG_POP(C++)
>> +
>> +      if test "${have_usable_source_highlight}" = "yes"; then
>> +        AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
>> +                  [Define to 1 if the source-highlight library is available])
>> +        AC_MSG_RESULT([yes])
>> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
>> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
>> +      else
>> +	AC_MSG_RESULT([no])
>> +	if test "${enable_source_highlight}" = "yes"; then
> 
> Hi,
> 
> I do not know what it the indentation policy for the configure.ac file,

Me neither, I just used what I saw around.

> but you use tabs in the 'AC_MSG_RESULT' and 'if test' lines above (2
> lines above), and nowhere else.
> 

Ack, fixed now, I guess I forgot to untabify those.  Thanks for noticing.

> The rest of the file does not seem to be completely consistent regarding
> this particular subject, so I do not know if there is a preferred
> formatting that should be used, but I guess that having the same across
> the patch could make sense.
> 

Agreed.

> Otherwise, and for what it is worth, this looks reasonable to me.
> 

Thanks for the review,
- Tom

> Best,
> Lancelot.
> 
>> +          AC_MSG_ERROR([source-highlight in your system could not be used])
>> +        fi
>> +      fi 
>>      else
>>        AC_MSG_RESULT([no])
>>        if test "${enable_source_highlight}" = "yes"; then
>>
>> base-commit: fd0ff19bf435b267caae6a1ae04e7b4a4ba64f5b
>> -- 
>> 2.26.2
>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] [gdb/build] Check if libsource-highlight is usable
  2021-11-19 12:34 [PATCH] [gdb/build] Check if libsource-highlight is usable Tom de Vries
  2021-11-19 15:16 ` Lancelot SIX
@ 2021-11-19 15:56 ` Andrew Burgess
  2021-11-19 20:56   ` Tom de Vries
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2021-11-19 15:56 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

* Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> [2021-11-19 13:34:23 +0100]:

> When building gdb with g++ 4.8.5, I ran into:
> ...
> ld: source-cache.o: in function `source_cache::ensure(symtab*)':
> source-cache.c:207: undefined reference to \
>   srchilite::SourceHighlight::SourceHighlight(std::string const&)
> ...
> 
> [ I configured gdb without explicit settings related to source-highlight, so
> we're excercising the enable_source_highlight=auto scenario. ]
> 
> The problem is that:
> - the source-highlight library is build with system compiler
>   g++ 7.5.0 which uses the new libstdc++ library abi (see
>   https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
> - gdb is build using g++ 4.8.5 which uses the old abi.
> 
> [ There's a compatibility macro _GLIBCXX_USE_CXX11_ABI, but that doesn't work
> for this case.  Instead, it enables the opposite case where the
> source-highlight library is build with g++ 4.8.5 and gdb is build with
> g++ 7.5.0. ]
> 
> Fix this by checking whether the source-highlight library is usable during
> configuration.
> 
> In the enable_source_highlight=auto scenario, this allows the build to skip
> the unusable library and finish successfully.
> 
> In the enable_source_highlight=yes scenario, this allows the build to error
> out earlier.

I make no claims of being an autoconf expert, but this all looks
reasonable to me.  I had just one tiny nit..

> 
> Tested on x86_64-linux.
> ---
>  gdb/configure    | 158 ++++++++++++++++++++++++++++++++---------------
>  gdb/configure.ac |  47 ++++++++++++--
>  2 files changed, 151 insertions(+), 54 deletions(-)
> 
> diff --git a/gdb/configure b/gdb/configure
> index 6e2dfb766c8..aaa622d9fcc 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -2367,6 +2367,52 @@ $as_echo "$ac_res" >&6; }
>  
>  } # ac_fn_c_check_func
>  
> +# ac_fn_cxx_try_link LINENO
> +# -------------------------
> +# Try to link conftest.$ac_ext, and return whether this succeeded.
> +ac_fn_cxx_try_link ()
> +{
> +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> +  rm -f conftest.$ac_objext conftest$ac_exeext
> +  if { { ac_try="$ac_link"
> +case "(($ac_try" in
> +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> +  *) ac_try_echo=$ac_try;;
> +esac
> +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> +$as_echo "$ac_try_echo"; } >&5
> +  (eval "$ac_link") 2>conftest.err
> +  ac_status=$?
> +  if test -s conftest.err; then
> +    grep -v '^ *+' conftest.err >conftest.er1
> +    cat conftest.er1 >&5
> +    mv -f conftest.er1 conftest.err
> +  fi
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; } && {
> +	 test -z "$ac_cxx_werror_flag" ||
> +	 test ! -s conftest.err
> +       } && test -s conftest$ac_exeext && {
> +	 test "$cross_compiling" = yes ||
> +	 test -x conftest$ac_exeext
> +       }; then :
> +  ac_retval=0
> +else
> +  $as_echo "$as_me: failed program was:" >&5
> +sed 's/^/| /' conftest.$ac_ext >&5
> +
> +	ac_retval=1
> +fi
> +  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
> +  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
> +  # interfere with the next link command; also delete a directory that is
> +  # left behind by Apple's compiler.  We do this before executing the actions.
> +  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
> +  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
> +  as_fn_set_status $ac_retval
> +
> +} # ac_fn_cxx_try_link
> +
>  # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
>  # -------------------------------------------
>  # Tests whether TYPE exists after having included INCLUDES, setting cache
> @@ -2524,52 +2570,6 @@ $as_echo "$ac_res" >&6; }
>  
>  } # ac_fn_c_check_member
>  
> -# ac_fn_cxx_try_link LINENO
> -# -------------------------
> -# Try to link conftest.$ac_ext, and return whether this succeeded.
> -ac_fn_cxx_try_link ()
> -{
> -  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> -  rm -f conftest.$ac_objext conftest$ac_exeext
> -  if { { ac_try="$ac_link"
> -case "(($ac_try" in
> -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> -  *) ac_try_echo=$ac_try;;
> -esac
> -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> -$as_echo "$ac_try_echo"; } >&5
> -  (eval "$ac_link") 2>conftest.err
> -  ac_status=$?
> -  if test -s conftest.err; then
> -    grep -v '^ *+' conftest.err >conftest.er1
> -    cat conftest.er1 >&5
> -    mv -f conftest.er1 conftest.err
> -  fi
> -  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> -  test $ac_status = 0; } && {
> -	 test -z "$ac_cxx_werror_flag" ||
> -	 test ! -s conftest.err
> -       } && test -s conftest$ac_exeext && {
> -	 test "$cross_compiling" = yes ||
> -	 test -x conftest$ac_exeext
> -       }; then :
> -  ac_retval=0
> -else
> -  $as_echo "$as_me: failed program was:" >&5
> -sed 's/^/| /' conftest.$ac_ext >&5
> -
> -	ac_retval=1
> -fi
> -  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
> -  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
> -  # interfere with the next link command; also delete a directory that is
> -  # left behind by Apple's compiler.  We do this before executing the actions.
> -  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
> -  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
> -  as_fn_set_status $ac_retval
> -
> -} # ac_fn_cxx_try_link
> -
>  # ac_fn_cxx_check_func LINENO FUNC VAR
>  # ------------------------------------
>  # Tests whether FUNC exists, setting the cache variable VAR accordingly
> @@ -12103,13 +12103,73 @@ $as_echo "no - pkg-config not found" >&6; }
>            ;;
>        esac
>  
> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
> +
> +      # Now that we have found a source-highlight library, check if we can use
> +      # it.  In particular, we're trying to detect the situation that the
> +      # library is using the new libstdc++ library abi ( see
> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
> +      # while the compiler being used to compile gdb is using the old abi.
> +      # Such a situation will result in an undefined reference to
> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
> +      # This situation can occur when f.i. using a source highlight library

what's "f.i." ? did you mean "e.g." ?

Otherwise, LGTM.

Thanks,
Andrew

> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
> +      ac_ext=cpp
> +ac_cpp='$CXXCPP $CPPFLAGS'
> +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
> +
> +      save_CFLAGS=$CFLAGS
> +      save_LDFLAGS=$LDFLAGS
> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
> +      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include <srchilite/sourcehighlight.h>
> +int
> +main ()
> +{
> +std::string outlang = "esc.outlang";
> +           new srchilite::SourceHighlight (outlang);
> +
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_cxx_try_link "$LINENO"; then :
> +  have_usable_source_highlight=yes
> +else
> +  have_usable_source_highlight=no
> +
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +      CFLAGS="$SAVE_CFLAGS"
> +      LDFLAGS="$SAVE_LDFLAGS"
> +      ac_ext=c
> +ac_cpp='$CPP $CPPFLAGS'
> +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> +ac_compiler_gnu=$ac_cv_c_compiler_gnu
> +
> +
> +      if test "${have_usable_source_highlight}" = "yes"; then
>  
>  $as_echo "#define HAVE_SOURCE_HIGHLIGHT 1" >>confdefs.h
>  
> -      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
>  $as_echo "yes" >&6; }
> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
> +      else
> +	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +	if test "${enable_source_highlight}" = "yes"; then
> +          as_fn_error $? "source-highlight in your system could not be used" "$LINENO" 5
> +        fi
> +      fi
>      else
>        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
>  $as_echo "no" >&6; }
> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index d4cfb6a7624..e4fed3c575c 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -1248,11 +1248,48 @@ either use --disable-source-highlight or dnl
>            ;;
>        esac
>  
> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
> -      AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
> -                [Define to 1 if the source-highlight library is available])
> -      AC_MSG_RESULT([yes])
> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
> +
> +      # Now that we have found a source-highlight library, check if we can use
> +      # it.  In particular, we're trying to detect the situation that the
> +      # library is using the new libstdc++ library abi ( see
> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
> +      # while the compiler being used to compile gdb is using the old abi.
> +      # Such a situation will result in an undefined reference to
> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
> +      # This situation can occur when f.i. using a source highlight library
> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
> +      AC_LANG_PUSH(C++)
> +      save_CFLAGS=$CFLAGS
> +      save_LDFLAGS=$LDFLAGS
> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
> +      AC_LINK_IFELSE(
> +        [AC_LANG_PROGRAM(
> +          [#include <srchilite/sourcehighlight.h>],
> +          [std::string outlang = "esc.outlang";
> +           new srchilite::SourceHighlight (outlang);]
> +        )],
> +        [have_usable_source_highlight=yes],
> +        [have_usable_source_highlight=no]
> +      )
> +      CFLAGS="$SAVE_CFLAGS"
> +      LDFLAGS="$SAVE_LDFLAGS"
> +      AC_LANG_POP(C++)
> +
> +      if test "${have_usable_source_highlight}" = "yes"; then
> +        AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
> +                  [Define to 1 if the source-highlight library is available])
> +        AC_MSG_RESULT([yes])
> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
> +      else
> +	AC_MSG_RESULT([no])
> +	if test "${enable_source_highlight}" = "yes"; then
> +          AC_MSG_ERROR([source-highlight in your system could not be used])
> +        fi
> +      fi
>      else
>        AC_MSG_RESULT([no])
>        if test "${enable_source_highlight}" = "yes"; then
> 
> base-commit: fd0ff19bf435b267caae6a1ae04e7b4a4ba64f5b
> -- 
> 2.26.2
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] [gdb/build] Check if libsource-highlight is usable
  2021-11-19 15:56 ` Andrew Burgess
@ 2021-11-19 20:56   ` Tom de Vries
  2021-11-20 10:57     ` Andrew Burgess
  0 siblings, 1 reply; 7+ messages in thread
From: Tom de Vries @ 2021-11-19 20:56 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On 11/19/21 4:56 PM, Andrew Burgess wrote:
> * Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> [2021-11-19 13:34:23 +0100]:
> 
>> When building gdb with g++ 4.8.5, I ran into:
>> ...
>> ld: source-cache.o: in function `source_cache::ensure(symtab*)':
>> source-cache.c:207: undefined reference to \
>>   srchilite::SourceHighlight::SourceHighlight(std::string const&)
>> ...
>>
>> [ I configured gdb without explicit settings related to source-highlight, so
>> we're excercising the enable_source_highlight=auto scenario. ]
>>
>> The problem is that:
>> - the source-highlight library is build with system compiler
>>   g++ 7.5.0 which uses the new libstdc++ library abi (see
>>   https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
>> - gdb is build using g++ 4.8.5 which uses the old abi.
>>
>> [ There's a compatibility macro _GLIBCXX_USE_CXX11_ABI, but that doesn't work
>> for this case.  Instead, it enables the opposite case where the
>> source-highlight library is build with g++ 4.8.5 and gdb is build with
>> g++ 7.5.0. ]
>>
>> Fix this by checking whether the source-highlight library is usable during
>> configuration.
>>
>> In the enable_source_highlight=auto scenario, this allows the build to skip
>> the unusable library and finish successfully.
>>
>> In the enable_source_highlight=yes scenario, this allows the build to error
>> out earlier.
> 
> I make no claims of being an autoconf expert, but this all looks
> reasonable to me.  I had just one tiny nit..
> 
>>
>> Tested on x86_64-linux.
>> ---
>>  gdb/configure    | 158 ++++++++++++++++++++++++++++++++---------------
>>  gdb/configure.ac |  47 ++++++++++++--
>>  2 files changed, 151 insertions(+), 54 deletions(-)
>>
>> diff --git a/gdb/configure b/gdb/configure
>> index 6e2dfb766c8..aaa622d9fcc 100755
>> --- a/gdb/configure
>> +++ b/gdb/configure
>> @@ -2367,6 +2367,52 @@ $as_echo "$ac_res" >&6; }
>>  
>>  } # ac_fn_c_check_func
>>  
>> +# ac_fn_cxx_try_link LINENO
>> +# -------------------------
>> +# Try to link conftest.$ac_ext, and return whether this succeeded.
>> +ac_fn_cxx_try_link ()
>> +{
>> +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
>> +  rm -f conftest.$ac_objext conftest$ac_exeext
>> +  if { { ac_try="$ac_link"
>> +case "(($ac_try" in
>> +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
>> +  *) ac_try_echo=$ac_try;;
>> +esac
>> +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
>> +$as_echo "$ac_try_echo"; } >&5
>> +  (eval "$ac_link") 2>conftest.err
>> +  ac_status=$?
>> +  if test -s conftest.err; then
>> +    grep -v '^ *+' conftest.err >conftest.er1
>> +    cat conftest.er1 >&5
>> +    mv -f conftest.er1 conftest.err
>> +  fi
>> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
>> +  test $ac_status = 0; } && {
>> +	 test -z "$ac_cxx_werror_flag" ||
>> +	 test ! -s conftest.err
>> +       } && test -s conftest$ac_exeext && {
>> +	 test "$cross_compiling" = yes ||
>> +	 test -x conftest$ac_exeext
>> +       }; then :
>> +  ac_retval=0
>> +else
>> +  $as_echo "$as_me: failed program was:" >&5
>> +sed 's/^/| /' conftest.$ac_ext >&5
>> +
>> +	ac_retval=1
>> +fi
>> +  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
>> +  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
>> +  # interfere with the next link command; also delete a directory that is
>> +  # left behind by Apple's compiler.  We do this before executing the actions.
>> +  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
>> +  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
>> +  as_fn_set_status $ac_retval
>> +
>> +} # ac_fn_cxx_try_link
>> +
>>  # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
>>  # -------------------------------------------
>>  # Tests whether TYPE exists after having included INCLUDES, setting cache
>> @@ -2524,52 +2570,6 @@ $as_echo "$ac_res" >&6; }
>>  
>>  } # ac_fn_c_check_member
>>  
>> -# ac_fn_cxx_try_link LINENO
>> -# -------------------------
>> -# Try to link conftest.$ac_ext, and return whether this succeeded.
>> -ac_fn_cxx_try_link ()
>> -{
>> -  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
>> -  rm -f conftest.$ac_objext conftest$ac_exeext
>> -  if { { ac_try="$ac_link"
>> -case "(($ac_try" in
>> -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
>> -  *) ac_try_echo=$ac_try;;
>> -esac
>> -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
>> -$as_echo "$ac_try_echo"; } >&5
>> -  (eval "$ac_link") 2>conftest.err
>> -  ac_status=$?
>> -  if test -s conftest.err; then
>> -    grep -v '^ *+' conftest.err >conftest.er1
>> -    cat conftest.er1 >&5
>> -    mv -f conftest.er1 conftest.err
>> -  fi
>> -  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
>> -  test $ac_status = 0; } && {
>> -	 test -z "$ac_cxx_werror_flag" ||
>> -	 test ! -s conftest.err
>> -       } && test -s conftest$ac_exeext && {
>> -	 test "$cross_compiling" = yes ||
>> -	 test -x conftest$ac_exeext
>> -       }; then :
>> -  ac_retval=0
>> -else
>> -  $as_echo "$as_me: failed program was:" >&5
>> -sed 's/^/| /' conftest.$ac_ext >&5
>> -
>> -	ac_retval=1
>> -fi
>> -  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
>> -  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
>> -  # interfere with the next link command; also delete a directory that is
>> -  # left behind by Apple's compiler.  We do this before executing the actions.
>> -  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
>> -  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
>> -  as_fn_set_status $ac_retval
>> -
>> -} # ac_fn_cxx_try_link
>> -
>>  # ac_fn_cxx_check_func LINENO FUNC VAR
>>  # ------------------------------------
>>  # Tests whether FUNC exists, setting the cache variable VAR accordingly
>> @@ -12103,13 +12103,73 @@ $as_echo "no - pkg-config not found" >&6; }
>>            ;;
>>        esac
>>  
>> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
>> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
>> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
>> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
>> +
>> +      # Now that we have found a source-highlight library, check if we can use
>> +      # it.  In particular, we're trying to detect the situation that the
>> +      # library is using the new libstdc++ library abi ( see
>> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
>> +      # while the compiler being used to compile gdb is using the old abi.
>> +      # Such a situation will result in an undefined reference to
>> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
>> +      # This situation can occur when f.i. using a source highlight library
> 
> what's "f.i." ? 

For instance.

>did you mean "e.g." ?

Well, I meant for instance.  That is, I know "e.g.", but I find it hard
to use because it doesn't directly map to an english language
expression, like "f.i.".  So I'd prefer to continue to use this, unless
it's hard to understand for people in general.  I'm
not-a-native-speaker, so feedback on that is welcome :)

Thanks,
- Tom

> 
> Otherwise, LGTM.
> 
> Thanks,
> Andrew
> 
>> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
>> +      ac_ext=cpp
>> +ac_cpp='$CXXCPP $CPPFLAGS'
>> +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
>> +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
>> +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
>> +
>> +      save_CFLAGS=$CFLAGS
>> +      save_LDFLAGS=$LDFLAGS
>> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
>> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
>> +      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
>> +/* end confdefs.h.  */
>> +#include <srchilite/sourcehighlight.h>
>> +int
>> +main ()
>> +{
>> +std::string outlang = "esc.outlang";
>> +           new srchilite::SourceHighlight (outlang);
>> +
>> +  ;
>> +  return 0;
>> +}
>> +_ACEOF
>> +if ac_fn_cxx_try_link "$LINENO"; then :
>> +  have_usable_source_highlight=yes
>> +else
>> +  have_usable_source_highlight=no
>> +
>> +fi
>> +rm -f core conftest.err conftest.$ac_objext \
>> +    conftest$ac_exeext conftest.$ac_ext
>> +      CFLAGS="$SAVE_CFLAGS"
>> +      LDFLAGS="$SAVE_LDFLAGS"
>> +      ac_ext=c
>> +ac_cpp='$CPP $CPPFLAGS'
>> +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
>> +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
>> +ac_compiler_gnu=$ac_cv_c_compiler_gnu
>> +
>> +
>> +      if test "${have_usable_source_highlight}" = "yes"; then
>>  
>>  $as_echo "#define HAVE_SOURCE_HIGHLIGHT 1" >>confdefs.h
>>  
>> -      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
>> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
>>  $as_echo "yes" >&6; }
>> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
>> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
>> +      else
>> +	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
>> +$as_echo "no" >&6; }
>> +	if test "${enable_source_highlight}" = "yes"; then
>> +          as_fn_error $? "source-highlight in your system could not be used" "$LINENO" 5
>> +        fi
>> +      fi
>>      else
>>        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
>>  $as_echo "no" >&6; }
>> diff --git a/gdb/configure.ac b/gdb/configure.ac
>> index d4cfb6a7624..e4fed3c575c 100644
>> --- a/gdb/configure.ac
>> +++ b/gdb/configure.ac
>> @@ -1248,11 +1248,48 @@ either use --disable-source-highlight or dnl
>>            ;;
>>        esac
>>  
>> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
>> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
>> -      AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
>> -                [Define to 1 if the source-highlight library is available])
>> -      AC_MSG_RESULT([yes])
>> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
>> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
>> +
>> +      # Now that we have found a source-highlight library, check if we can use
>> +      # it.  In particular, we're trying to detect the situation that the
>> +      # library is using the new libstdc++ library abi ( see
>> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
>> +      # while the compiler being used to compile gdb is using the old abi.
>> +      # Such a situation will result in an undefined reference to
>> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
>> +      # This situation can occur when f.i. using a source highlight library
>> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
>> +      AC_LANG_PUSH(C++)
>> +      save_CFLAGS=$CFLAGS
>> +      save_LDFLAGS=$LDFLAGS
>> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
>> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
>> +      AC_LINK_IFELSE(
>> +        [AC_LANG_PROGRAM(
>> +          [#include <srchilite/sourcehighlight.h>],
>> +          [std::string outlang = "esc.outlang";
>> +           new srchilite::SourceHighlight (outlang);]
>> +        )],
>> +        [have_usable_source_highlight=yes],
>> +        [have_usable_source_highlight=no]
>> +      )
>> +      CFLAGS="$SAVE_CFLAGS"
>> +      LDFLAGS="$SAVE_LDFLAGS"
>> +      AC_LANG_POP(C++)
>> +
>> +      if test "${have_usable_source_highlight}" = "yes"; then
>> +        AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
>> +                  [Define to 1 if the source-highlight library is available])
>> +        AC_MSG_RESULT([yes])
>> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
>> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
>> +      else
>> +	AC_MSG_RESULT([no])
>> +	if test "${enable_source_highlight}" = "yes"; then
>> +          AC_MSG_ERROR([source-highlight in your system could not be used])
>> +        fi
>> +      fi
>>      else
>>        AC_MSG_RESULT([no])
>>        if test "${enable_source_highlight}" = "yes"; then
>>
>> base-commit: fd0ff19bf435b267caae6a1ae04e7b4a4ba64f5b
>> -- 
>> 2.26.2
>>
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] [gdb/build] Check if libsource-highlight is usable
  2021-11-19 20:56   ` Tom de Vries
@ 2021-11-20 10:57     ` Andrew Burgess
  2021-11-20 12:22       ` Tom de Vries
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2021-11-20 10:57 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

* Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> [2021-11-19 21:56:41 +0100]:

> On 11/19/21 4:56 PM, Andrew Burgess wrote:
> > * Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> [2021-11-19 13:34:23 +0100]:
> > 
> >> When building gdb with g++ 4.8.5, I ran into:
> >> ...
> >> ld: source-cache.o: in function `source_cache::ensure(symtab*)':
> >> source-cache.c:207: undefined reference to \
> >>   srchilite::SourceHighlight::SourceHighlight(std::string const&)
> >> ...
> >>
> >> [ I configured gdb without explicit settings related to source-highlight, so
> >> we're excercising the enable_source_highlight=auto scenario. ]
> >>
> >> The problem is that:
> >> - the source-highlight library is build with system compiler
> >>   g++ 7.5.0 which uses the new libstdc++ library abi (see
> >>   https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
> >> - gdb is build using g++ 4.8.5 which uses the old abi.
> >>
> >> [ There's a compatibility macro _GLIBCXX_USE_CXX11_ABI, but that doesn't work
> >> for this case.  Instead, it enables the opposite case where the
> >> source-highlight library is build with g++ 4.8.5 and gdb is build with
> >> g++ 7.5.0. ]
> >>
> >> Fix this by checking whether the source-highlight library is usable during
> >> configuration.
> >>
> >> In the enable_source_highlight=auto scenario, this allows the build to skip
> >> the unusable library and finish successfully.
> >>
> >> In the enable_source_highlight=yes scenario, this allows the build to error
> >> out earlier.
> > 
> > I make no claims of being an autoconf expert, but this all looks
> > reasonable to me.  I had just one tiny nit..
> > 
> >>
> >> Tested on x86_64-linux.
> >> ---
> >>  gdb/configure    | 158 ++++++++++++++++++++++++++++++++---------------
> >>  gdb/configure.ac |  47 ++++++++++++--
> >>  2 files changed, 151 insertions(+), 54 deletions(-)
> >>
> >> diff --git a/gdb/configure b/gdb/configure
> >> index 6e2dfb766c8..aaa622d9fcc 100755
> >> --- a/gdb/configure
> >> +++ b/gdb/configure
> >> @@ -2367,6 +2367,52 @@ $as_echo "$ac_res" >&6; }
> >>  
> >>  } # ac_fn_c_check_func
> >>  
> >> +# ac_fn_cxx_try_link LINENO
> >> +# -------------------------
> >> +# Try to link conftest.$ac_ext, and return whether this succeeded.
> >> +ac_fn_cxx_try_link ()
> >> +{
> >> +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> >> +  rm -f conftest.$ac_objext conftest$ac_exeext
> >> +  if { { ac_try="$ac_link"
> >> +case "(($ac_try" in
> >> +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> >> +  *) ac_try_echo=$ac_try;;
> >> +esac
> >> +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> >> +$as_echo "$ac_try_echo"; } >&5
> >> +  (eval "$ac_link") 2>conftest.err
> >> +  ac_status=$?
> >> +  if test -s conftest.err; then
> >> +    grep -v '^ *+' conftest.err >conftest.er1
> >> +    cat conftest.er1 >&5
> >> +    mv -f conftest.er1 conftest.err
> >> +  fi
> >> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> >> +  test $ac_status = 0; } && {
> >> +	 test -z "$ac_cxx_werror_flag" ||
> >> +	 test ! -s conftest.err
> >> +       } && test -s conftest$ac_exeext && {
> >> +	 test "$cross_compiling" = yes ||
> >> +	 test -x conftest$ac_exeext
> >> +       }; then :
> >> +  ac_retval=0
> >> +else
> >> +  $as_echo "$as_me: failed program was:" >&5
> >> +sed 's/^/| /' conftest.$ac_ext >&5
> >> +
> >> +	ac_retval=1
> >> +fi
> >> +  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
> >> +  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
> >> +  # interfere with the next link command; also delete a directory that is
> >> +  # left behind by Apple's compiler.  We do this before executing the actions.
> >> +  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
> >> +  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
> >> +  as_fn_set_status $ac_retval
> >> +
> >> +} # ac_fn_cxx_try_link
> >> +
> >>  # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
> >>  # -------------------------------------------
> >>  # Tests whether TYPE exists after having included INCLUDES, setting cache
> >> @@ -2524,52 +2570,6 @@ $as_echo "$ac_res" >&6; }
> >>  
> >>  } # ac_fn_c_check_member
> >>  
> >> -# ac_fn_cxx_try_link LINENO
> >> -# -------------------------
> >> -# Try to link conftest.$ac_ext, and return whether this succeeded.
> >> -ac_fn_cxx_try_link ()
> >> -{
> >> -  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
> >> -  rm -f conftest.$ac_objext conftest$ac_exeext
> >> -  if { { ac_try="$ac_link"
> >> -case "(($ac_try" in
> >> -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
> >> -  *) ac_try_echo=$ac_try;;
> >> -esac
> >> -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
> >> -$as_echo "$ac_try_echo"; } >&5
> >> -  (eval "$ac_link") 2>conftest.err
> >> -  ac_status=$?
> >> -  if test -s conftest.err; then
> >> -    grep -v '^ *+' conftest.err >conftest.er1
> >> -    cat conftest.er1 >&5
> >> -    mv -f conftest.er1 conftest.err
> >> -  fi
> >> -  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> >> -  test $ac_status = 0; } && {
> >> -	 test -z "$ac_cxx_werror_flag" ||
> >> -	 test ! -s conftest.err
> >> -       } && test -s conftest$ac_exeext && {
> >> -	 test "$cross_compiling" = yes ||
> >> -	 test -x conftest$ac_exeext
> >> -       }; then :
> >> -  ac_retval=0
> >> -else
> >> -  $as_echo "$as_me: failed program was:" >&5
> >> -sed 's/^/| /' conftest.$ac_ext >&5
> >> -
> >> -	ac_retval=1
> >> -fi
> >> -  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
> >> -  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
> >> -  # interfere with the next link command; also delete a directory that is
> >> -  # left behind by Apple's compiler.  We do this before executing the actions.
> >> -  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
> >> -  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
> >> -  as_fn_set_status $ac_retval
> >> -
> >> -} # ac_fn_cxx_try_link
> >> -
> >>  # ac_fn_cxx_check_func LINENO FUNC VAR
> >>  # ------------------------------------
> >>  # Tests whether FUNC exists, setting the cache variable VAR accordingly
> >> @@ -12103,13 +12103,73 @@ $as_echo "no - pkg-config not found" >&6; }
> >>            ;;
> >>        esac
> >>  
> >> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
> >> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
> >> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
> >> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
> >> +
> >> +      # Now that we have found a source-highlight library, check if we can use
> >> +      # it.  In particular, we're trying to detect the situation that the
> >> +      # library is using the new libstdc++ library abi ( see
> >> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
> >> +      # while the compiler being used to compile gdb is using the old abi.
> >> +      # Such a situation will result in an undefined reference to
> >> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
> >> +      # This situation can occur when f.i. using a source highlight library
> > 
> > what's "f.i." ? 
> 
> For instance.

OK, that makes sense.

> 
> >did you mean "e.g." ?
> 
> Well, I meant for instance.  That is, I know "e.g.", but I find it hard
> to use because it doesn't directly map to an english language
> expression, like "f.i.".  So I'd prefer to continue to use this, unless
> it's hard to understand for people in general.  I'm
> not-a-native-speaker, so feedback on that is welcome :)

I've never seen "for instance" abbreviated to "f.i." before, so, I'd
just suggest saying "for instance".

Or don't change it at all if you don't want to :)  I was still able to
understand what you were saying, so it's not really important.

Thanks,
Andrew


> 
> Thanks,
> - Tom
> 
> > 
> > Otherwise, LGTM.
> > 
> > Thanks,
> > Andrew
> > 
> >> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
> >> +      ac_ext=cpp
> >> +ac_cpp='$CXXCPP $CPPFLAGS'
> >> +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> >> +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> >> +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
> >> +
> >> +      save_CFLAGS=$CFLAGS
> >> +      save_LDFLAGS=$LDFLAGS
> >> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
> >> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
> >> +      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> >> +/* end confdefs.h.  */
> >> +#include <srchilite/sourcehighlight.h>
> >> +int
> >> +main ()
> >> +{
> >> +std::string outlang = "esc.outlang";
> >> +           new srchilite::SourceHighlight (outlang);
> >> +
> >> +  ;
> >> +  return 0;
> >> +}
> >> +_ACEOF
> >> +if ac_fn_cxx_try_link "$LINENO"; then :
> >> +  have_usable_source_highlight=yes
> >> +else
> >> +  have_usable_source_highlight=no
> >> +
> >> +fi
> >> +rm -f core conftest.err conftest.$ac_objext \
> >> +    conftest$ac_exeext conftest.$ac_ext
> >> +      CFLAGS="$SAVE_CFLAGS"
> >> +      LDFLAGS="$SAVE_LDFLAGS"
> >> +      ac_ext=c
> >> +ac_cpp='$CPP $CPPFLAGS'
> >> +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> >> +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> >> +ac_compiler_gnu=$ac_cv_c_compiler_gnu
> >> +
> >> +
> >> +      if test "${have_usable_source_highlight}" = "yes"; then
> >>  
> >>  $as_echo "#define HAVE_SOURCE_HIGHLIGHT 1" >>confdefs.h
> >>  
> >> -      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
> >> +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
> >>  $as_echo "yes" >&6; }
> >> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
> >> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
> >> +      else
> >> +	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> >> +$as_echo "no" >&6; }
> >> +	if test "${enable_source_highlight}" = "yes"; then
> >> +          as_fn_error $? "source-highlight in your system could not be used" "$LINENO" 5
> >> +        fi
> >> +      fi
> >>      else
> >>        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> >>  $as_echo "no" >&6; }
> >> diff --git a/gdb/configure.ac b/gdb/configure.ac
> >> index d4cfb6a7624..e4fed3c575c 100644
> >> --- a/gdb/configure.ac
> >> +++ b/gdb/configure.ac
> >> @@ -1248,11 +1248,48 @@ either use --disable-source-highlight or dnl
> >>            ;;
> >>        esac
> >>  
> >> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
> >> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
> >> -      AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
> >> -                [Define to 1 if the source-highlight library is available])
> >> -      AC_MSG_RESULT([yes])
> >> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
> >> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
> >> +
> >> +      # Now that we have found a source-highlight library, check if we can use
> >> +      # it.  In particular, we're trying to detect the situation that the
> >> +      # library is using the new libstdc++ library abi ( see
> >> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
> >> +      # while the compiler being used to compile gdb is using the old abi.
> >> +      # Such a situation will result in an undefined reference to
> >> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
> >> +      # This situation can occur when f.i. using a source highlight library
> >> +      # compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
> >> +      AC_LANG_PUSH(C++)
> >> +      save_CFLAGS=$CFLAGS
> >> +      save_LDFLAGS=$LDFLAGS
> >> +      CFLAGS="$CFLAGS $srchigh_pkg_cflags"
> >> +      LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
> >> +      AC_LINK_IFELSE(
> >> +        [AC_LANG_PROGRAM(
> >> +          [#include <srchilite/sourcehighlight.h>],
> >> +          [std::string outlang = "esc.outlang";
> >> +           new srchilite::SourceHighlight (outlang);]
> >> +        )],
> >> +        [have_usable_source_highlight=yes],
> >> +        [have_usable_source_highlight=no]
> >> +      )
> >> +      CFLAGS="$SAVE_CFLAGS"
> >> +      LDFLAGS="$SAVE_LDFLAGS"
> >> +      AC_LANG_POP(C++)
> >> +
> >> +      if test "${have_usable_source_highlight}" = "yes"; then
> >> +        AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
> >> +                  [Define to 1 if the source-highlight library is available])
> >> +        AC_MSG_RESULT([yes])
> >> +        SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
> >> +        SRCHIGH_LIBS="$srchigh_pkg_libs"
> >> +      else
> >> +	AC_MSG_RESULT([no])
> >> +	if test "${enable_source_highlight}" = "yes"; then
> >> +          AC_MSG_ERROR([source-highlight in your system could not be used])
> >> +        fi
> >> +      fi
> >>      else
> >>        AC_MSG_RESULT([no])
> >>        if test "${enable_source_highlight}" = "yes"; then
> >>
> >> base-commit: fd0ff19bf435b267caae6a1ae04e7b4a4ba64f5b
> >> -- 
> >> 2.26.2
> >>
> > 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] [gdb/build] Check if libsource-highlight is usable
  2021-11-20 10:57     ` Andrew Burgess
@ 2021-11-20 12:22       ` Tom de Vries
  0 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2021-11-20 12:22 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On 11/20/21 11:57 AM, Andrew Burgess wrote:
> * Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> [2021-11-19 21:56:41 +0100]:
> 
>> On 11/19/21 4:56 PM, Andrew Burgess wrote:
>>> * Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> [2021-11-19 13:34:23 +0100]:
>>>
>>>> When building gdb with g++ 4.8.5, I ran into:
>>>> ...
>>>> ld: source-cache.o: in function `source_cache::ensure(symtab*)':
>>>> source-cache.c:207: undefined reference to \
>>>>   srchilite::SourceHighlight::SourceHighlight(std::string const&)
>>>> ...
>>>>
>>>> [ I configured gdb without explicit settings related to source-highlight, so
>>>> we're excercising the enable_source_highlight=auto scenario. ]
>>>>
>>>> The problem is that:
>>>> - the source-highlight library is build with system compiler
>>>>   g++ 7.5.0 which uses the new libstdc++ library abi (see
>>>>   https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
>>>> - gdb is build using g++ 4.8.5 which uses the old abi.
>>>>
>>>> [ There's a compatibility macro _GLIBCXX_USE_CXX11_ABI, but that doesn't work
>>>> for this case.  Instead, it enables the opposite case where the
>>>> source-highlight library is build with g++ 4.8.5 and gdb is build with
>>>> g++ 7.5.0. ]
>>>>
>>>> Fix this by checking whether the source-highlight library is usable during
>>>> configuration.
>>>>
>>>> In the enable_source_highlight=auto scenario, this allows the build to skip
>>>> the unusable library and finish successfully.
>>>>
>>>> In the enable_source_highlight=yes scenario, this allows the build to error
>>>> out earlier.
>>>
>>> I make no claims of being an autoconf expert, but this all looks
>>> reasonable to me.  I had just one tiny nit..
>>>
>>>>
>>>> Tested on x86_64-linux.
>>>> ---
>>>>  gdb/configure    | 158 ++++++++++++++++++++++++++++++++---------------
>>>>  gdb/configure.ac |  47 ++++++++++++--
>>>>  2 files changed, 151 insertions(+), 54 deletions(-)
>>>>
>>>> diff --git a/gdb/configure b/gdb/configure
>>>> index 6e2dfb766c8..aaa622d9fcc 100755
>>>> --- a/gdb/configure
>>>> +++ b/gdb/configure
>>>> @@ -2367,6 +2367,52 @@ $as_echo "$ac_res" >&6; }
>>>>  
>>>>  } # ac_fn_c_check_func
>>>>  
>>>> +# ac_fn_cxx_try_link LINENO
>>>> +# -------------------------
>>>> +# Try to link conftest.$ac_ext, and return whether this succeeded.
>>>> +ac_fn_cxx_try_link ()
>>>> +{
>>>> +  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
>>>> +  rm -f conftest.$ac_objext conftest$ac_exeext
>>>> +  if { { ac_try="$ac_link"
>>>> +case "(($ac_try" in
>>>> +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
>>>> +  *) ac_try_echo=$ac_try;;
>>>> +esac
>>>> +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
>>>> +$as_echo "$ac_try_echo"; } >&5
>>>> +  (eval "$ac_link") 2>conftest.err
>>>> +  ac_status=$?
>>>> +  if test -s conftest.err; then
>>>> +    grep -v '^ *+' conftest.err >conftest.er1
>>>> +    cat conftest.er1 >&5
>>>> +    mv -f conftest.er1 conftest.err
>>>> +  fi
>>>> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
>>>> +  test $ac_status = 0; } && {
>>>> +	 test -z "$ac_cxx_werror_flag" ||
>>>> +	 test ! -s conftest.err
>>>> +       } && test -s conftest$ac_exeext && {
>>>> +	 test "$cross_compiling" = yes ||
>>>> +	 test -x conftest$ac_exeext
>>>> +       }; then :
>>>> +  ac_retval=0
>>>> +else
>>>> +  $as_echo "$as_me: failed program was:" >&5
>>>> +sed 's/^/| /' conftest.$ac_ext >&5
>>>> +
>>>> +	ac_retval=1
>>>> +fi
>>>> +  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
>>>> +  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
>>>> +  # interfere with the next link command; also delete a directory that is
>>>> +  # left behind by Apple's compiler.  We do this before executing the actions.
>>>> +  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
>>>> +  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
>>>> +  as_fn_set_status $ac_retval
>>>> +
>>>> +} # ac_fn_cxx_try_link
>>>> +
>>>>  # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
>>>>  # -------------------------------------------
>>>>  # Tests whether TYPE exists after having included INCLUDES, setting cache
>>>> @@ -2524,52 +2570,6 @@ $as_echo "$ac_res" >&6; }
>>>>  
>>>>  } # ac_fn_c_check_member
>>>>  
>>>> -# ac_fn_cxx_try_link LINENO
>>>> -# -------------------------
>>>> -# Try to link conftest.$ac_ext, and return whether this succeeded.
>>>> -ac_fn_cxx_try_link ()
>>>> -{
>>>> -  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
>>>> -  rm -f conftest.$ac_objext conftest$ac_exeext
>>>> -  if { { ac_try="$ac_link"
>>>> -case "(($ac_try" in
>>>> -  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
>>>> -  *) ac_try_echo=$ac_try;;
>>>> -esac
>>>> -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
>>>> -$as_echo "$ac_try_echo"; } >&5
>>>> -  (eval "$ac_link") 2>conftest.err
>>>> -  ac_status=$?
>>>> -  if test -s conftest.err; then
>>>> -    grep -v '^ *+' conftest.err >conftest.er1
>>>> -    cat conftest.er1 >&5
>>>> -    mv -f conftest.er1 conftest.err
>>>> -  fi
>>>> -  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
>>>> -  test $ac_status = 0; } && {
>>>> -	 test -z "$ac_cxx_werror_flag" ||
>>>> -	 test ! -s conftest.err
>>>> -       } && test -s conftest$ac_exeext && {
>>>> -	 test "$cross_compiling" = yes ||
>>>> -	 test -x conftest$ac_exeext
>>>> -       }; then :
>>>> -  ac_retval=0
>>>> -else
>>>> -  $as_echo "$as_me: failed program was:" >&5
>>>> -sed 's/^/| /' conftest.$ac_ext >&5
>>>> -
>>>> -	ac_retval=1
>>>> -fi
>>>> -  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
>>>> -  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
>>>> -  # interfere with the next link command; also delete a directory that is
>>>> -  # left behind by Apple's compiler.  We do this before executing the actions.
>>>> -  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
>>>> -  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
>>>> -  as_fn_set_status $ac_retval
>>>> -
>>>> -} # ac_fn_cxx_try_link
>>>> -
>>>>  # ac_fn_cxx_check_func LINENO FUNC VAR
>>>>  # ------------------------------------
>>>>  # Tests whether FUNC exists, setting the cache variable VAR accordingly
>>>> @@ -12103,13 +12103,73 @@ $as_echo "no - pkg-config not found" >&6; }
>>>>            ;;
>>>>        esac
>>>>  
>>>> -      SRCHIGH_CFLAGS=`${pkg_config_prog_path} --cflags source-highlight`
>>>> -      SRCHIGH_LIBS=`${pkg_config_prog_path} --libs source-highlight`
>>>> +      srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
>>>> +      srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
>>>> +
>>>> +      # Now that we have found a source-highlight library, check if we can use
>>>> +      # it.  In particular, we're trying to detect the situation that the
>>>> +      # library is using the new libstdc++ library abi ( see
>>>> +      # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
>>>> +      # while the compiler being used to compile gdb is using the old abi.
>>>> +      # Such a situation will result in an undefined reference to
>>>> +      # srchilite::SourceHighlight::SourceHighlight(std::string const&).
>>>> +      # This situation can occur when f.i. using a source highlight library
>>>
>>> what's "f.i." ? 
>>
>> For instance.
> 
> OK, that makes sense.
> 
>>
>>> did you mean "e.g." ?
>>
>> Well, I meant for instance.  That is, I know "e.g.", but I find it hard
>> to use because it doesn't directly map to an english language
>> expression, like "f.i.".  So I'd prefer to continue to use this, unless
>> it's hard to understand for people in general.  I'm
>> not-a-native-speaker, so feedback on that is welcome :)
> 
> I've never seen "for instance" abbreviated to "f.i." before, so, I'd
> just suggest saying "for instance".
> 

Updated patch accordingly, and committed.

> Or don't change it at all if you don't want to :)  I was still able to
> understand what you were saying, so it's not really important.
> 

Ack, that's good to know.

I've grepped a bit in the log messages and sources, and it seems to be
just me using this abbreviation.  I'll try to refrain from using this in
the future.

Thanks for the review.

- Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-20 12:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 12:34 [PATCH] [gdb/build] Check if libsource-highlight is usable Tom de Vries
2021-11-19 15:16 ` Lancelot SIX
2021-11-19 15:22   ` Tom de Vries
2021-11-19 15:56 ` Andrew Burgess
2021-11-19 20:56   ` Tom de Vries
2021-11-20 10:57     ` Andrew Burgess
2021-11-20 12:22       ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).