From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 07BA53858C3A; Mon, 17 Apr 2023 21:29:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07BA53858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681766959; bh=3IBkLPzQtZpxnyA0xz4TEPJgEMGF/l3KQCwzHmvAuDE=; h=From:To:Subject:Date:From; b=IGPnVxYQxMBVzw9vULuD/ChyIdDt4nrbVsStahCNEXk4XGZHr0NwGr+YWprsE2WFR AXwqFsaeq/xVUvwRT0Zp1lmpGCA5Fv93Y1WKjXAmEviVfoQsKaGYrJeJBnpsYuW9eR pWqfDfFN2o/QIy8ywTWSnJqr/DFdzNpr/JXFERHQ= From: "justinpopo6 at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/30368] New: GDB Python Failing to Import Zlib Module Date: Mon, 17 Apr 2023 21:29:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: justinpopo6 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30368 Bug ID: 30368 Summary: GDB Python Failing to Import Zlib Module Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: justinpopo6 at gmail dot com Target Milestone: --- When compiling GDB for a non-native target, in my case x86_64 host and aarc= h64 target, it fails to import zlib when python library is statically linked. (gdb) python >import zlib >print("hello world") >end Traceback (most recent call last): File "", line 1, in ImportError: /local/users/jc957059/gcc123/build/opt/toolchains/python-runtime/lib/python= 3.10/lib-dynload/zlib.cpython-310-x86_64-linux-gnu.so: undefined symbol: PyExc_MemoryError Error while executing Python code. (gdb) exit The python library is being statically linked to gdb, but the symbols are n= ot being exported. Thus the PyExc_MemoryError symbol is missing when trying to import zlib. Looking at this in gdb/configure:21954 # Work around Python http://bugs.python.org/issue10112. See also # http://bugs.python.org/issue11410, otherwise -Wl,--dynamic-list has # no effect. Note that the only test after this that uses Python is # the -rdynamic/-Wl,--dynamic-list test, and we do want that one to be # run without -export-dynamic too. PYTHON_LIBS=3D`echo $PYTHON_LIBS | sed -e 's/-Xlinker -export-dynamic//'` We remove -export-dynamic and expect to add -rdynamic/--dynamic-list. Howev= er this is only added for native builds using configure.nat. gdb/configure:29677 # Import nat definitions. nat_makefile_frag=3D/dev/null if test "${gdb_native}" =3D "yes"; then . ${srcdir}/configure.nat nativefile=3D$NAT_FILE fi gdb/configure.nat:54 case ${gdb_host} in *linux*) ... LOADLIBES=3D'-ldl $(RDYNAMIC)' I don't see this error for native builds since the -rdynamic flag is present during linking, but for non-native builds this fails. Shouldn't we be adding the -rdynamic flag for all builds? Manually setting LDFLAGS=3D"-rdynamic" f= ixes this problem for me. uname -a: Linux stbirv-lnx-1 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC = 2022 x86_64 x86_64 x86_64 GNU/Linux gcc -v: Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu 11.3.0-1ubuntu1~22.04' --with-bugurl=3Dfile:///usr/share/doc/gcc-11/README.= Bugs --enable-languages=3Dc,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix= =3D/usr --with-gcc-major-version-only --program-suffix=3D-11 --program-prefix=3Dx86_64-linux-gnu- --enable-shared --enable-linker-build-= id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --enable-bootstrap --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-= zlib --enable-libphobos-checking=3Drelease --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enable-multiarch --disable-werror --enable-cet --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --enable-offload-targets=3Dnvptx-none=3D/build/gcc-11-xKiWfi/gcc-11-11.3.0/= debian/tmp-nvptx/usr,amdgcn-amdhsa=3D/build/gcc-11-xKiWfi/gcc-11-11.3.0/deb= ian/tmp-gcn/usr --without-cuda-driver --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu --with-build-config=3Dbootstrap-lto-lean --enable-link-serialization=3D2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) Thanks, Justin --=20 You are receiving this mail because: You are on the CC list for the bug.=