From patchwork Wed Jan 22 02:04:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?5YKF57un5pmX?= X-Patchwork-Id: 37462 Received: (qmail 69932 invoked by alias); 22 Jan 2020 02:04:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 69922 invoked by uid 89); 22 Jan 2020 02:04:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.5 required=5.0 tests=AWL, BAYES_00, BODY_8BITS, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GARBLED_BODY, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-ed1-f68.google.com Received: from mail-ed1-f68.google.com (HELO mail-ed1-f68.google.com) (209.85.208.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Jan 2020 02:04:50 +0000 Received: by mail-ed1-f68.google.com with SMTP id j17so5156360edp.3 for ; Tue, 21 Jan 2020 18:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zQ3uJejPLlDf2Rv8WqiuQEUNR8Wrkdc20P1AZ9jygFI=; b=EGtkTb5n2ZE4qTvcJDPY19r2F93SDthJ15bpD8bP/LtxaJzl2IDbpKmvckkFEW9nHl eGAI/gIrXEOIt1Mecmln+dj3nFCe1gjdABWxrwXVRuszTAVL8ldJ7+4tmTNnyetZD8U6 vSbNeorMsCVxWTP+aZwAjDRPQI3+MexIC5iDxCO0by9SH1cH3BXW54l7hao/geofQx75 PxdL0x0BNdxdi6GPPNqJqdMCcJ3vXDA/fysMSLwWdkFqlMcU69IWYz71bQNKzz8Eg/OS GSHES5u1/tODz6eENqgISxUdblbkNS5uk6OpKoI3MyrRctsiLFyqeSPoDlCZ/f7tleVq rpTw== MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?5YKF57un5pmX?= Date: Wed, 22 Jan 2020 10:04:37 +0800 Message-ID: Subject: Re: [PATCH] Modify python-config.py or replace it with official one to support python3 To: gdb-patches Cc: Christian Biesinger fix some typo. else 傅继晗 于2020年1月22日周三 上午9:56写道: > > now I improve the patch to be compatible with python2.7 python 3.7 and > python3.8+ > > > index gdb/configure.ac > ============================ > > --- a/gdb/configure.ac > +++ b/gdb/configure.ac > @@ -834,29 +834,35 @@ else > esac > esac > > + python_config= > if test "${python_prog}" != missing; then > + AC_CHECK_FILE([${python_prog}-config],[python_config="${python_prog}-config"],[python_config="${python_prog} > ${srcdir}/python/python-config.py"]) > # We have a python program to use, but it may be too old. > # Don't flag an error for --with-python=auto (the default). > have_python_config=yes > - python_includes=`${python_prog} ${srcdir}/python/python-config.py > --includes` > + python_includes=`${python_config} --includes` > if test $? != 0; then > have_python_config=failed > if test "${with_python}" != auto; then > - AC_ERROR(failure running python-config --includes) > + AC_ERROR(failure running ${python-config} --includes) > fi > fi > - python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags` > +# For python 3.8+ there must be a "--embed" flag to show lib version. > + python_libs=`${python_config} --ldflags --embed` > if test $? != 0; then > - have_python_config=failed > - if test "${with_python}" != auto; then > - AC_ERROR(failure running python-config --ldflags) > + python_libs=`${python_config} --ldflags` > + if test $? != 0; then > + have_python_config=failed > + if test "${with_python}" != auto; then > + AC_ERROR(failure running ${python-config} --ldflags) > + fi > fi > fi > - python_prefix=`${python_prog} ${srcdir}/python/python-config.py > --exec-prefix` > + python_prefix=`${python_config} --exec-prefix` > if test $? != 0; then > have_python_config=failed > if test "${with_python}" != auto; then > - AC_ERROR(failure running python-config --exec-prefix) > + AC_ERROR(failure running ${python-config} --exec-prefix) > fi > fi > else > > 傅继晗 于2020年1月21日周二 下午7:41写道: > > > > ok.that is,and here is my patch. > > Tested with autoconf 2.69 and python3.8. > > > > > > index:gdb/configure.ac > > ============================ > > --- a/gdb/configure.ac > > +++ b/gdb/configure.ac > > @@ -834,29 +834,31 @@ > > esac > > esac > > > > + python_config= > > if test "${python_prog}" != missing; then > > + AC_CHECK_FILE([${python_prog}-config],[python_config="${python_prog}-config > > --embed"],[python_config="${python_prog} > > ${srcdir}/python/python-config.py"]) > > # We have a python program to use, but it may be too old. > > # Don't flag an error for --with-python=auto (the default). > > have_python_config=yes > > - python_includes=`${python_prog} ${srcdir}/python/python-config.py > > --includes` > > + python_includes=`${python_config} --includes` > > if test $? != 0; then > > have_python_config=failed > > if test "${with_python}" != auto; then > > - AC_ERROR(failure running python-config --includes) > > + AC_ERROR(failure running ${python_config} --includes) > > fi > > fi > > - python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags` > > + python_libs=`${python_config} --ldflags` > > if test $? != 0; then > > have_python_config=failed > > if test "${with_python}" != auto; then > > - AC_ERROR(failure running python-config --ldflags) > > + AC_ERROR(failure running ${python_config} --ldflags) > > fi > > fi > > - python_prefix=`${python_prog} ${srcdir}/python/python-config.py > > --exec-prefix` > > + python_prefix=`${python_config} --exec-prefix` > > if test $? != 0; then > > have_python_config=failed > > if test "${with_python}" != auto; then > > - AC_ERROR(failure running python-config --exec-prefix) > > + AC_ERROR(failure running ${python_config} --exec-prefix) > > fi > > fi > > else > > > > Christian Biesinger 于2020年1月21日周二 上午8:30写道: > > > > > > On Mon, Jan 20, 2020 at 8:05 AM 傅继晗 wrote: > > > > > > > > The formal patch only works on OSX.And here is the patch to make the > > > > crossbuild available. > > > > > > configure is a generated file. Please edit configure.ac instead, and > > > run autoconf to regenerate configure. Make sure to use autoconf > > > version 2.69. > > > > > > Christian > > > > > > > diff --git a/gdb/configure-origin b/gdb/configure > > > > --- a/gdb/configure-origin > > > > +++ b/gdb/configure > > > > @@ -9858,21 +9858,21 @@ fi > > > > # We have a python program to use, but it may be too old. > > > > # Don't flag an error for --with-python=auto (the default). > > > > have_python_config=yes > > > > - python_includes=`${python_prog} ${srcdir}/python/python-config.py --includes` > > > > + python_includes=`${python_prog}-config --includes` > > > > if test $? != 0; then > > > > have_python_config=failed > > > > if test "${with_python}" != auto; then > > > > as_fn_error "failure running python-config --includes" "$LINENO" 5 > > > > fi > > > > fi > > > > - python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags` > > > > + python_libs=`${python_prog}-config --ldflags` > > > > if test $? != 0; then > > > > have_python_config=failed > > > > if test "${with_python}" != auto; then > > > > as_fn_error "failure running python-config --ldflags" "$LINENO" 5 > > > > fi > > > > fi > > > > - python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix` > > > > + python_prefix=`${python_prog}-config --exec-prefix` > > > > if test $? != 0; then > > > > have_python_config=failed > > > > if test "${with_python}" != auto; then > > > > > > > > > > > > 傅继晗 于2020年1月20日周一 下午8:02写道: > > > > > > > > > > By default,gdb is compiled with python2 script support on OSX. However,when compiled with arg "--with-python=/path/to/python3 " to support python3 ,some error occurred that seems python3 is not recognized. > > > > > The reason is that the python-config.py is not the same as the official one.BTW,this issue was once referred at 20 Dec 2012 mail :https://sourceware.org/ml/gdb-patches/2012-12/msg00751.html. > > > > > Somehow,It is not committed(maybe the maintainer forgot it due to the happy chrismas holiday). > > > > > And here is my patch: > > > > > > > > > > index: b/gdb/python/python-config.py > > > > > =============================== > > > > > --- a/gdb/python/python-config.py > > > > > +++ b/gdb/python/python-config.py > > > > > @@ -72,7 +72,7 @@ for opt in opt_flags: > > > > > libs.insert(0, '-L' + getvar('LIBPL')) > > > > > elif os.name == 'nt': > > > > > libs.insert(0, '-L' + sysconfig.PREFIX + '/libs') > > > > > - if getvar('LINKFORSHARED') is not None: > > > > > + if not getvar('PYTHONFRAMEWORK'): > > > > > libs.extend(getvar('LINKFORSHARED').split()) > > > > > print (to_unix_path(' '.join(libs))) --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -834,29 +834,35 @@ else esac esac + python_config= if test "${python_prog}" != missing; then + AC_CHECK_FILE([${python_prog}-config],[python_config="${python_prog}-config"],[python_config="${python_prog} ${srcdir}/python/python-config.py"]) # We have a python program to use, but it may be too old. # Don't flag an error for --with-python=auto (the default). have_python_config=yes - python_includes=`${python_prog} ${srcdir}/python/python-config.py --includes` + python_includes=`${python_config} --includes` if test $? != 0; then have_python_config=failed if test "${with_python}" != auto; then - AC_ERROR(failure running python-config --includes) + AC_ERROR(failure running ${python_config} --includes) fi fi - python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags` +# For python 3.8+ there must be a "--embed" flag to show lib version. + python_libs=`${python_config} --ldflags --embed` if test $? != 0; then - have_python_config=failed - if test "${with_python}" != auto; then - AC_ERROR(failure running python-config --ldflags) + python_libs=`${python_config} --ldflags` + if test $? != 0; then + have_python_config=failed + if test "${with_python}" != auto; then + AC_ERROR(failure running ${python_config} --ldflags) + fi fi fi - python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix` + python_prefix=`${python_config} --exec-prefix` if test $? != 0; then have_python_config=failed if test "${with_python}" != auto; then - AC_ERROR(failure running python-config --exec-prefix) + AC_ERROR(failure running ${python_config} --exec-prefix) fi fi