#1006261 "ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object"

#1006261#5
Date:
2022-02-22 08:16:50 UTC
From:
To:
Dear Maintainer,

I noticed that since version 2.110, lintian fails Ubuntu autopkgtests
[1][2] because of the following compilation error, any clue?

make[1]: Entering directory '/tmp/autopkgtest.wCvt5C/autopkgtest_tmp/build-and-evaluate-test-packages/packages/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/binaries-missing-depends-on-numpy-abi-1.0'
debian/rules:7: target 'binary' does not exist
dh binary --buildsystem pybuild
   dh_update_autotools_config -O--buildsystem=pybuild
   dh_autoreconf -O--buildsystem=pybuild
   dh_auto_configure -O--buildsystem=pybuild
I: pybuild base:237: python3.9 setup.py config
running config
I: pybuild base:237: python3.10 setup.py config
/tmp/autopkgtest.wCvt5C/autopkgtest_tmp/build-and-evaluate-test-packages/packages/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/binaries-missing-depends-on-numpy-abi-1.0/setup.py:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  import distutils.core
running config
   dh_auto_build -O--buildsystem=pybuild
I: pybuild base:237: /usr/bin/python3.9 setup.py build
running build
running build_ext
building 'basic' extension
creating build
creating build/temp.linux-x86_64-3.9
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -O2 -ffile-prefix-map=/tmp/autopkgtest.wCvt5C/autopkgtest_tmp/build-and-evaluate-test-packages/packages/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/binaries-missing-depends-on-numpy-abi-1.0=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c basic.c -o build/temp.linux-x86_64-3.9/basic.o
In file included from /usr/include/python3.9/numpy/ndarraytypes.h:1969,
                 from /usr/include/python3.9/numpy/ndarrayobject.h:12,
                 from /usr/include/python3.9/numpy/arrayobject.h:4,
                 from basic.c:2:
/usr/include/python3.9/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   17 | #warning "Using deprecated NumPy API, disable it with " \
      |  ^~~~~~~
basic.c: In function 'do_import_array':
basic.c:17:5: warning: 'return' with a value, in function returning void [-Wreturn-type]
   17 |     import_array();
      |     ^~~~~~~~~~~~
basic.c:15:6: note: declared here
   15 | void do_import_array(void)
      |      ^~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now -Wl,--no-as-needed -g -O2 -ffile-prefix-map=/tmp/autopkgtest.wCvt5C/autopkgtest_tmp/build-and-evaluate-test-packages/packages/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/binaries-missing-depends-on-numpy-abi-1.0=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.9/basic.o -o /tmp/autopkgtest.wCvt5C/autopkgtest_tmp/build-and-evaluate-test-packages/packages/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/binaries-missing-depends-on-numpy-abi-1.0/.pybuild/cpython3_3.9/build/basic.cpython-39-x86_64-linux-gnu.so
/usr/bin/ld: /tmp/ccqS1KST.ltrans0.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

[1] https://autopkgtest.ubuntu.com/packages/lintian/jammy/amd64
[2] https://autopkgtest.ubuntu.com/results/autopkgtest-jammy/jammy/amd64/l/lintian/20211105_201948_f270b@/log.gz

#1006261#10
Date:
2022-02-22 13:30:06 UTC
From:
To:
I finally found a fix for this issue, any comment is welcome:

diff -Nru lintian-2.114.0/t/recipes/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/build-spec/debian/rules
lintian-2.114.0ubuntu2/t/recipes/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/build-spec/debian/rules
--- lintian-2.114.0/t/recipes/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/build-spec/debian/rules
   2021-11-27 18:20:56.000000000 +0100
+++ lintian-2.114.0ubuntu2/t/recipes/checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi/build-spec/debian/rules2022-02-22
11:12:19.000000000 +0100
@@ -1,7 +1,7 @@
 #!/usr/bin/make -f

 export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
-export DEB_LDFLAGS_MAINT_APPEND=-Wl,--no-as-needed
+export DEB_LDFLAGS_MAINT_APPEND=-Wl,--no-as-needed -fPIC

 %:
     dh $@ --buildsystem pybuild