From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63074 invoked by alias); 4 May 2018 14:12:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 63064 invoked by uid 89); 4 May 2018 14:12:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=configureac, preexisting, worst, UD:configure.ac X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 May 2018 14:12:44 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w44ECbJV023819 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 4 May 2018 10:12:42 -0400 Received: by simark.ca (Postfix, from userid 112) id AED1A1F213; Fri, 4 May 2018 10:12:37 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 6E8391E4F4; Fri, 4 May 2018 10:12:35 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 04 May 2018 14:12:00 -0000 From: Simon Marchi To: Paul Pluzhnikov Cc: gdb-patches ml Subject: Re: [patch] Fix BZ 11420 -- configure uses incorrect link order when testing libpython In-Reply-To: References: Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 4 May 2018 14:12:37 +0000 X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00087.txt.bz2 On 2018-04-17 11:52, Paul Pluzhnikov via gdb-patches wrote: > Greetings, > > https://stackoverflow.com/a/49868387 > https://sourceware.org/bugzilla/show_bug.cgi?id=11420 > > Configure uses "gcc -o conftest -g ... conftest.c -ldl -lncurses -lm > -ldl > ... -lpthread ... -lpython2.7" when deciding whether give libpython is > usable. > > That of course is the wrong link order, and only works for shared > libraries > (mostly by accident), and only on some systems. > > Attached patch fixes this. Hi Paul, Sorry for letting this slip through the cracks. It looks like our python-config.py is a (modified) copy of an old python-config from CPython. A similar bug was reported and fixed upstream a while ago: https://bugs.python.org/issue18096 and your fix in python-config.py makes our version closer to the upstream version, so this part LGTM. > I am not sure about this part of the patch: > > - LIBS="$LIBS $new_LIBS" > + LIBS="$new_LIBS $LIBS" > > I think it's always better to prepend new libraries. > > Thanks, > > 2018-04-17 Paul Pluzhnikov > > PR gdb/11420 > * gdb/configure.ac: Prepend libpython. > * gdb/python/python-config.py: Likewise. > * gdb/configure: Regenerate. The configure changes seem good as well, or at worst noops. For example, in this context, I am wondering if the python_libs value can be other than empty: elif test "${have_python_config}" != failed; then if test "${have_libpython}" = no; then AC_TRY_LIBPYTHON(python2.7, have_libpython, ${python_includes}, "-lpython2.7 ${python_libs}") fi If we are in that context, it's because have_python_config is "no". And it looks like the only code path that sets have_python_config to "no" also sets python_libs to empty. If you want to investigate that further and possibly simplify the code, you are welcome. I've pushed your patch with these changes: - Fix pre-existing formatting issue in the python-config.py line - Re-generate configure (those changes were not included in the patch) - Remove the gdb/ prefixes in the ChangeLog filenames (they should be relative to the ChangeLog file itself, which is in gdb/). Thanks! Simon