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 39EAF3858D35 for ; Thu, 25 Nov 2021 18:11:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 39EAF3858D35 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-xdUoq31FN5Cb3uD1ZoFTyw-1; Thu, 25 Nov 2021 13:11:49 -0500 X-MC-Unique: xdUoq31FN5Cb3uD1ZoFTyw-1 Received: by mail-wm1-f71.google.com with SMTP id y141-20020a1c7d93000000b0033c2ae3583fso3611161wmc.5 for ; Thu, 25 Nov 2021 10:11:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=ofQ/sBSAHZNAUJhAlt/Wy9IRJH4iggkc6ezlWVOZ7mg=; b=bwnQnatfcd7iVje2F0nYt55BBoE3hRcAemGpHcgoLAWXxb0E4jALEPxFtvZByFiwDn ldm9tWi0DB6wV0FoEZIIS2bbYX8axl62AeB6tTIjpoQa6YaFUCViGJrjqgFrXycsxPE3 JK1BcZKw48rb03ZLmfwmPF1fnRLd5vhqLq9HueTxVnc65rDuib/IQCQ3zG9zqsmVwdi4 WFG9A+cJbrLbi8h+F2GnStCG6+dFXaJXNwVYOUvDfMjXjvyxRUCe0iN7ngVvOEIBC+Ya Rexr6f60b3oRrHA1QZcGzfhZPpnwYfU3ccNg66jOSce/XI+IrmvG1RjnSXGkwXvStW9I +gfQ== X-Gm-Message-State: AOAM5311uVXuxVMRZXX+flKVTQS2gkKsRAL4xV7y5yhxdJriIqpR7DIx /gBK3Dc0kAQMs8nE+7ecnKlxxqqDoNJidnB8p+M55fXCXOYDASZVRuIfr44USkS1IR9V7/Ik1xE PZ5djdnGp2sWVOI+NutLctA== X-Received: by 2002:a5d:456e:: with SMTP id a14mr8779557wrc.256.1637863908274; Thu, 25 Nov 2021 10:11:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmiOinW4i2qZntCEf47clxnHvovykTIWzwBHz8uXJno6xbv+GV2FDnTXHCfDWWTpKp31A6pQ== X-Received: by 2002:a5d:456e:: with SMTP id a14mr8779514wrc.256.1637863908020; Thu, 25 Nov 2021 10:11:48 -0800 (PST) Received: from localhost (92.40.178.38.threembb.co.uk. [92.40.178.38]) by smtp.gmail.com with ESMTPSA id a1sm4693133wri.89.2021.11.25.10.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 10:11:47 -0800 (PST) Date: Thu, 25 Nov 2021 18:11:45 +0000 From: Andrew Burgess To: Enze Li Cc: Tom Tromey , Andrew Burgess , gdb-patches@sourceware.org Subject: Re: [PATCH 1/4] gdb/python: make some global variables static Message-ID: <20211125181145.GU2662946@redhat.com> References: <666b1efbde4e68a870a448a921e4c0d3746a8d1b.1635241044.git.andrew.burgess@embecosm.com> <87sfwmnrta.fsf@tromey.com> <20211125101242.GQ2662946@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 18:10:20 up 6 days, 7:08, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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: Thu, 25 Nov 2021 18:11:52 -0000 * Enze Li [2021-11-25 23:02:49 +0800]: > Hi Andrew, >=20 > After using this patch, I encountered the following error when > compiling. >=20 > ----------------------------------------------------------------------- > CXXLD gdb > /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse- > linux/bin/ld: extension.o: in function `ext_lang_before_prompt(char > const*)': > /home/lee/dev/binutils-gdb/gdb/extension.c:914: undefined reference to > `extension_language_python' > /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse- > linux/bin/ld: extension.o: in function > `get_ext_lang_defn(extension_language)': > /home/lee/dev/binutils-gdb/gdb/extension.c:107: undefined reference to > `extension_language_python' > /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse- > linux/bin/ld: /home/lee/dev/binutils-gdb/gdb/extension.c:105: undefined > reference to `extension_language_python' > /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse- > linux/bin/ld: extension.o: in function `get_ext_lang_of_file(char > const*)': > /home/lee/dev/binutils-gdb/gdb/extension.c:132: undefined reference to > `extension_language_python' > /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse- > linux/bin/ld: extension.o: in function `ext_lang_initialization()': > /home/lee/dev/binutils-gdb/gdb/extension.c:331: undefined reference to > `extension_language_python' > /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse- > linux/bin/ld: extension.o:/home/lee/dev/binutils- > gdb/gdb/extension.c:359: more undefined references to > `extension_language_python' follow > collect2: error: ld returned 1 exit status > make[2]: *** [Makefile:1904: gdb] Error 1 > make[2]: Leaving directory '/home/lee/dev/binutils-gdb/gdb' > make[1]: *** [Makefile:13458: all-gdb] Error 2 > make[1]: Leaving directory '/home/lee/dev/binutils-gdb' > make: *** [Makefile:1000: all] Error 2 > ---------------------------------------------------------------------- >=20 > On Thu, 2021-11-25 at 10:12 +0000, Andrew Burgess via Gdb-patches > wrote: > > * Tom Tromey [2021-10-27 14:20:01 -0600]: > >=20 > > > > > > > > "Andrew" =3D=3D Andrew Burgess > > > > > > > > writes: > > >=20 > > > Andrew> Make a couple of global variables static in python/python.c.= =C2=A0 > > > To do > > > Andrew> this I had to move the definition of > > > extension_language_python to > > > Andrew> later in the file. > > >=20 > > > Andrew> There should be no user visible changes after this commit. > > >=20 > > > This looks good to me. > >=20 > > Thanks, I've pushed this patch. > >=20 > > Andrew > >=20 >=20 > Here is my system environment, > OpenSuse Tumbleweed (Updated just now) > - gcc 11.2.1 20210816=20 > [revision 056e324ce46a7924b5cf10f61010cf9dd2ca10e9] >=20 > I executed the following command to compile=EF=BC=8C > # ./configure --prefix=3D/path/to/gdb-src/build/ > # make >=20 > I guess the problem may be in the macro definition. I tested with the > following patch and the problem disappeared. Hope this may help to > solve this problem. >=20 > ----------------------------------------------------------------------- > diff --git a/gdb/python/python.c b/gdb/python/python.c > index d8a6a5978de..bfb691f0eac 100644 > --- a/gdb/python/python.c > +++ b/gdb/python/python.c > @@ -164,6 +164,8 @@ static const struct extension_language_ops > python_extension_ops =3D > gdbpy_colorize, > }; > =20 > +#endif /* HAVE_PYTHON */ > + > /* The main struct describing GDB's interface to the Python > extension language. */ > const struct extension_language_defn extension_language_python =3D > @@ -186,6 +188,8 @@ const struct extension_language_defn > extension_language_python =3D > #endif > }; > =20 > +#ifdef HAVE_PYTHON > + > /* Architecture and language to be used in callbacks from > the Python interpreter. */ > struct gdbarch *python_gdbarch; > ----------------------------------------------------------------------- Enze, Thanks for reporting this, and thanks for looking into the problem and providing a fix. I pushed the patch below to resolve this issue. Thanks, Andrew --- commit 9e99facd6cae1a94923166bd02f716d96395c19f Author: Enze Li Date: Thu Nov 25 18:05:46 2021 +0000 gdb: ensure extension_language_python is always defined =20 In this commit: =20 commit c6a6aad52d9e839d6a84ac31cabe2b7e1a2a31a0 Date: Mon Oct 25 17:25:45 2021 +0100 =20 gdb/python: make some global variables static =20 building without Python was broken. The extension_language_python global was moved from being always defined, to only being defined when the HAVE_PYTHON macro was defined. As a consequence, building without Python support would result in errors like: =20 /usr/bin/ld: extension.o:(.rodata+0x120): undefined reference to `ext= ension_language_python' =20 This commit fixes the problem by moving the definition of extension_language_python outside of the HAVE_PYTHON macro protection. diff --git a/gdb/python/python.c b/gdb/python/python.c index d8a6a5978de..bfb691f0eac 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -164,6 +164,8 @@ static const struct extension_language_ops python_exten= sion_ops =3D gdbpy_colorize, }; =20 +#endif /* HAVE_PYTHON */ + /* The main struct describing GDB's interface to the Python extension language. */ const struct extension_language_defn extension_language_python =3D @@ -186,6 +188,8 @@ const struct extension_language_defn extension_language= _python =3D #endif }; =20 +#ifdef HAVE_PYTHON + /* Architecture and language to be used in callbacks from the Python interpreter. */ struct gdbarch *python_gdbarch;