Package: python3-dev
Version: 3.7.5-3
I'm trying to compile a C++ app which uses SWIG and embeds a Python
interpreter. So it uses `python3-config --cflags` to compile and
`python3-config --ldflags` to link. A few other libs like SDL are
included with `pkg-config` too, but no weird gcc option is added.
Compiling cpp files runs fine, but when linking the final executable
file, it fails badly:
```
g++ -I ../SWIG -I <bunch of includes> -I/usr/include/python3.7m
-I/usr/include/python3.7m -Wno-unused-result -Wsign-compare -g
-fdebug-prefix-map=/build/python3.7-neQ7kp/python3.7-3.7.6=.
-specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector -Wformat
-Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall
-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/libdrm
<bunch of .o files> -lglut -lGLU -lGL -L/usr/lib/x86_64-linux-gnu -lSDL
-lSDL_image -lSDL_mixer -lSDL
-L/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu -L/usr/lib
-lpython3.7m -lcrypt -lpthread -ldl -lutil -lm -o kiki
/usr/bin/ld: ../src/base/KikiAction.o: relocation R_X86_64_32S against
symbol `_ZTV10KikiAction' can not be used when making a PIE object;
recompile with -fPIE
/usr/bin/ld: ../src/base/KikiActionObject.o: relocation R_X86_64_32S
against symbol `_ZTV16KikiActionObject' can not be used when making a
PIE object; recompile with -fPIE
<the previous error repeated again and again, for a lot of .o files>
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
```
And `python3-config --cflags` generates the following params:
```
-I/usr/include/python3.7m -I/usr/include/python3.7m -Wno-unused-result
-Wsign-compare -g
-fdebug-prefix-map=/build/python3.7-neQ7kp/python3.7-3.7.6=.
-specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector -Wformat
-Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall
```
Given the linking error, I believe the incorrect option is in
`python3-config`'s output, and is
`-specs=/usr/share/dpkg/no-pie-compile.specs`. If I strip it, linking
works fine and so does the app.
By contrast, in Python 2, `python-config --cflags` does not have the
offending param:
```
-I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7
-fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g
-fdebug-prefix-map=/build/python2.7-07FOaN/python2.7-2.7.17=.
-fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG -g
-fwrapv -O2 -Wall -Wstrict-prototypes
```
Testing with a vanilla Python 3 installation from python.org, not from
Debian packages, `python3-config --cflags` does NOT have the offending
param either, so it is purely Debian-related.
Please remove the `-specs=/usr/share/dpkg/no-pie-compile.specs` option
for Debian's `python3-config`.