From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E071E388CC39 for ; Tue, 22 Feb 2022 14:43:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E071E388CC39 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-347-9puIEFlcPr6uPkPBCMImVA-1; Tue, 22 Feb 2022 09:43:50 -0500 X-MC-Unique: 9puIEFlcPr6uPkPBCMImVA-1 Received: by mail-wm1-f70.google.com with SMTP id c10-20020a7bc84a000000b00380e42a6926so27970wml.0 for ; Tue, 22 Feb 2022 06:43:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=zMdLgzhBE+S+7flepfZFuyfU4BM7h+PQTaSnixxI5ck=; b=XUvKiyw1CgEsrNa3ILYGDQrQLWb/+swDMStumnqhoKSQA31tR8T8tPM6vjErVq8X2Y iLgbFcS6IL5215+XV5Mqs/ApFa4h6thdj4PkExY0xy7jsOT4i/PCYYAUelRnJxs3/Mth rFWev2s75f/4uNDDZB60K90oqLGiv6e7/QNJyYgvAaLaSSGuDLQdJXKqOLAzhuOLlTyW sHxM4atfZcD90EH4sL36TIdfjKpgeOlFVVC83lyk4bXYTZXwmNHH2E4+H52M0ADvHRJc djPGvjrB7ZssBSrkr39ZseBikKxr9dPeGFZZM35/FHyGwfk9J11eHasJRuiu7B1zDVXZ pXjg== X-Gm-Message-State: AOAM5331xFx2NEvS8lRLW4dht2peeRyb6C/rdacd09nputcF7YvYefWa pyYI1vMn+XKNWg93CazsUuVnU0K+XixWOg9Q6m9W7sTpEsF2DBe+XeCEV5xHqHp7jF5ZpmkX4Dh XMc/F4xCXLXR1HIjv1DaOag== X-Received: by 2002:a05:600c:284a:b0:37e:9244:abea with SMTP id r10-20020a05600c284a00b0037e9244abeamr3694352wmb.2.1645541029072; Tue, 22 Feb 2022 06:43:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYA95oK4LkZcdro622ch/5PJkn3EOmT+QyBpy6fo/6DyD6TDsoR1Fz8iQUKpQjIFvnfKMkwg== X-Received: by 2002:a05:600c:284a:b0:37e:9244:abea with SMTP id r10-20020a05600c284a00b0037e9244abeamr3694333wmb.2.1645541028747; Tue, 22 Feb 2022 06:43:48 -0800 (PST) Received: from localhost (host86-169-131-29.range86-169.btcentralplus.com. [86.169.131.29]) by smtp.gmail.com with ESMTPSA id r2sm3488743wmq.24.2022.02.22.06.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 06:43:48 -0800 (PST) From: Andrew Burgess To: Ruslan Kabatsayev , GDB Patches Subject: Re: [PATCH] Fix detection of compilation and linking flags for source-highlight In-Reply-To: References: <20220211171023.20246-1-b7.10110111@gmail.com> Date: Tue, 22 Feb 2022 14:43:46 +0000 Message-ID: <87ley3arml.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2022 14:43:57 -0000 Ruslan Kabatsayev via Gdb-patches writes: > Ping! > > On Fri, 11 Feb 2022 at 20:10, wrote: >> >> From: Ruslan Kabatsayev >> >> 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 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 @@ -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 ], @@ -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