* [PATCH] Fix detection of compilation and linking flags for source-highlight
@ 2022-02-11 17:10 b7.10110111--- via Gdb-patches
2022-02-21 21:10 ` Ruslan Kabatsayev via Gdb-patches
0 siblings, 1 reply; 3+ messages in thread
From: b7.10110111--- via Gdb-patches @ 2022-02-11 17:10 UTC (permalink / raw)
To: gdb-patches
From: Ruslan Kabatsayev <b7.10110111@gmail.com>
Currently there are two problems with the detection via pkg-config:
1. LDFLAGS variable is used to pass --libs to AC_LINK_IFELSE, which
results in the "-L/some/path -lsource-highlight" preceding the
conftest.cpp, which results in failure to find symbol referenced in
conftest.cpp.
2. CFLAGS variable is used to compile C++ code instead of CXXFLAGS. This
results in --cflags not being passed to the compiler at all.
This patch fixes both of these mistakes, letting me get a working GDB
with source-highlight installed into a custom prefix ~/opt/gdb-git
(because system repos provide too old version).
---
gdb/configure.ac | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 5a380ce38d9..c6fa19b20bc 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1242,10 +1242,10 @@ either use --disable-source-highlight or dnl
# This situation can occur for instance when 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"
+ save_CXXFLAGS="$CXXFLAGS"
+ save_LIBS="$LIBS"
+ CXXFLAGS="$CXXFLAGS $srchigh_pkg_cflags"
+ LIBS="$LIBS $srchigh_pkg_libs"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include <srchilite/sourcehighlight.h>],
@@ -1255,8 +1255,8 @@ either use --disable-source-highlight or dnl
[have_usable_source_highlight=yes],
[have_usable_source_highlight=no]
)
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
+ CXXFLAGS="$save_CXXFLAGS"
+ LIBS="$save_LIBS"
AC_LANG_POP(C++)
if test "${have_usable_source_highlight}" = "yes"; then
--
2.16.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix detection of compilation and linking flags for source-highlight
2022-02-11 17:10 [PATCH] Fix detection of compilation and linking flags for source-highlight b7.10110111--- via Gdb-patches
@ 2022-02-21 21:10 ` Ruslan Kabatsayev via Gdb-patches
2022-02-22 14:43 ` Andrew Burgess via Gdb-patches
0 siblings, 1 reply; 3+ messages in thread
From: Ruslan Kabatsayev via Gdb-patches @ 2022-02-21 21:10 UTC (permalink / raw)
To: GDB Patches
Ping!
On Fri, 11 Feb 2022 at 20:10, <b7.10110111@gmail.com> wrote:
>
> From: Ruslan Kabatsayev <b7.10110111@gmail.com>
>
> Currently there are two problems with the detection via pkg-config:
> 1. LDFLAGS variable is used to pass --libs to AC_LINK_IFELSE, which
> results in the "-L/some/path -lsource-highlight" preceding the
> conftest.cpp, which results in failure to find symbol referenced in
> conftest.cpp.
> 2. CFLAGS variable is used to compile C++ code instead of CXXFLAGS. This
> results in --cflags not being passed to the compiler at all.
>
> This patch fixes both of these mistakes, letting me get a working GDB
> with source-highlight installed into a custom prefix ~/opt/gdb-git
> (because system repos provide too old version).
> ---
> gdb/configure.ac | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index 5a380ce38d9..c6fa19b20bc 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -1242,10 +1242,10 @@ either use --disable-source-highlight or dnl
> # This situation can occur for instance when 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"
> + save_CXXFLAGS="$CXXFLAGS"
> + save_LIBS="$LIBS"
> + CXXFLAGS="$CXXFLAGS $srchigh_pkg_cflags"
> + LIBS="$LIBS $srchigh_pkg_libs"
> AC_LINK_IFELSE(
> [AC_LANG_PROGRAM(
> [#include <srchilite/sourcehighlight.h>],
> @@ -1255,8 +1255,8 @@ either use --disable-source-highlight or dnl
> [have_usable_source_highlight=yes],
> [have_usable_source_highlight=no]
> )
> - CFLAGS="$save_CFLAGS"
> - LDFLAGS="$save_LDFLAGS"
> + CXXFLAGS="$save_CXXFLAGS"
> + LIBS="$save_LIBS"
> AC_LANG_POP(C++)
>
> if test "${have_usable_source_highlight}" = "yes"; then
> --
> 2.16.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix detection of compilation and linking flags for source-highlight
2022-02-21 21:10 ` Ruslan Kabatsayev via Gdb-patches
@ 2022-02-22 14:43 ` Andrew Burgess via Gdb-patches
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess via Gdb-patches @ 2022-02-22 14:43 UTC (permalink / raw)
To: Ruslan Kabatsayev, GDB Patches
Ruslan Kabatsayev via Gdb-patches <gdb-patches@sourceware.org> writes:
> Ping!
>
> On Fri, 11 Feb 2022 at 20:10, <b7.10110111@gmail.com> wrote:
>>
>> From: Ruslan Kabatsayev <b7.10110111@gmail.com>
>>
>> Currently there are two problems with the detection via pkg-config:
>> 1. LDFLAGS variable is used to pass --libs to AC_LINK_IFELSE, which
>> results in the "-L/some/path -lsource-highlight" preceding the
>> conftest.cpp, which results in failure to find symbol referenced in
>> conftest.cpp.
>> 2. CFLAGS variable is used to compile C++ code instead of CXXFLAGS. This
>> results in --cflags not being passed to the compiler at all.
>>
>> This patch fixes both of these mistakes, letting me get a working GDB
>> with source-highlight installed into a custom prefix ~/opt/gdb-git
>> (because system repos provide too old version).
>> ---
>> gdb/configure.ac | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
Thanks for this.
I pushed the patch below.
Andrew
---
commit 6a8fe63330c922255a4ced4b6491d35f6c384bba
Author: Ruslan Kabatsayev <b7.10110111@gmail.com>
Date: Fri Feb 11 20:10:23 2022 +0300
gdb: fix detection of compilation and linking flags for source-highlight
Currently there are two problems with the detection of
source-highlight via pkg-config in GDB's configure script:
1. The LDFLAGS variable is used to pass the 'pkg-config --libs' output
to AC_LINK_IFELSE, which results in the "-L/some/path
-lsource-highlight" preceding the conftest.cpp, which can result in a
failure to find symbols referenced in conftest.cpp, if the linker is
using --as-needed by default.
2. The CFLAGS variable is used to pass the 'pkg-config --cflags'
output to AC_LINK_IFELSE. However, as the current language is C++,
AC_LINK_IFELSE will actuall use CXXFLAGS, not CFLAGS, so any flags
returned from pkg-config will not be seen.
This patch fixes both of these mistakes, allowing GDB to correctly
configure and build using source-highlight installed into a custom
prefix, e.g. ~/opt/gdb-git (because the system version of
source-highlight is too old).
diff --git a/gdb/configure b/gdb/configure
index e751edc3f9a..425bdb08a73 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12148,10 +12148,10 @@ 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"
+ save_CXXFLAGS="$CXXFLAGS"
+ save_LIBS="$LIBS"
+ CXXFLAGS="$CXXFLAGS $srchigh_pkg_cflags"
+ LIBS="$LIBS $srchigh_pkg_libs"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <srchilite/sourcehighlight.h>
@@ -12173,8 +12173,8 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
+ CXXFLAGS="$save_CXXFLAGS"
+ LIBS="$save_LIBS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 5a380ce38d9..c6fa19b20bc 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1242,10 +1242,10 @@ either use --disable-source-highlight or dnl
# This situation can occur for instance when 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"
+ save_CXXFLAGS="$CXXFLAGS"
+ save_LIBS="$LIBS"
+ CXXFLAGS="$CXXFLAGS $srchigh_pkg_cflags"
+ LIBS="$LIBS $srchigh_pkg_libs"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include <srchilite/sourcehighlight.h>],
@@ -1255,8 +1255,8 @@ either use --disable-source-highlight or dnl
[have_usable_source_highlight=yes],
[have_usable_source_highlight=no]
)
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
+ CXXFLAGS="$save_CXXFLAGS"
+ LIBS="$save_LIBS"
AC_LANG_POP(C++)
if test "${have_usable_source_highlight}" = "yes"; then
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-22 14:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11 17:10 [PATCH] Fix detection of compilation and linking flags for source-highlight b7.10110111--- via Gdb-patches
2022-02-21 21:10 ` Ruslan Kabatsayev via Gdb-patches
2022-02-22 14:43 ` Andrew Burgess via Gdb-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox