Bug#909396: systemd: FTBFS on hppa and x32 - relocation can not be used when making a shared object
John David Anglin
dave.anglin at bell.net
Sun Nov 18 18:18:45 GMT 2018
On 2018-11-14 2:19 p.m., John David Anglin wrote:
> The LTO plugin merges the PIC and PIE options used for the compiled
> objects:
>
> /* Merge PIC options:
> -fPIC + -fpic = -fpic
> -fPIC + -fno-pic = -fno-pic
> -fpic/-fPIC + nothin = nothing.
> It is a common mistake to mix few -fPIC compiled objects into
> otherwise
> non-PIC code. We do not want to build everything with PIC then.
>
> Similarly we merge PIE options, however in addition we keep
> -fPIC + -fPIE = -fPIE
> -fpic + -fPIE = -fpie
> -fPIC/-fpic + -fpie = -fpie
>
> It would be good to warn on mismatches, but it is bit hard to do as
> we do not know what nothing translates to. */
>
> As noted above, the most common mistake is to miss a -fPIC or -fPIE
> option in one of the objects.
> Adding -fPIE to the PIE link options causes the LTO plugin to use it
> for the compilations it does. Given
> that it works, implies that all objects in the failing link are in
> fact PIE, but for some reason the option
> determination has failed.
I understand the problem. The merge comment shown above is from gcc-9.
Systemd compiles fine
on hppa using gcc-9.
The merging of PIC and PIE options is not supported using gcc-8. This is
the corresponding comment in gcc-8:
/* Merge PIC options:
-fPIC + -fpic = -fpic
-fPIC + -fno-pic = -fno-pic
-fpic/-fPIC + nothin = nothing.
It is a common mistake to mix few -fPIC compiled objects into
otherwise
non-PIC code. We do not want to build everything with PIC then.
It would be good to warn on mismatches, but it is bit hard to do as
we do not know what nothing translates to. */
If one looks at one of the failing links,
[422/1547] cc -o src/udev/ata_id
'src/udev/src at udev@@ata_id at exe/ata_id_ata_id.c.o' -flto
-Wl,--no-undefined -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -pie
-Wl,--gc-sections -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat
-Werror=format-security -Wl,--start-group src/udev/libudev_static.a
src/shared/libsystemd-shared-239.a src/libsystemd/libsystemd_static.a
src/basic/libbasic.a src/udev/libudev-basic.a -lrt
/usr/lib/hppa-linux-gnu/libcap.so -lacl
/usr/lib/hppa-linux-gnu/libcryptsetup.so -lgcrypt
/usr/lib/hppa-linux-gnu/libip4tc.so /usr/lib/hppa-linux-gnu/libip6tc.so
/usr/lib/hppa-linux-gnu/libselinux.so /usr/lib/hppa-linux-gnu/libidn.so
/usr/lib/hppa-linux-gnu/liblzma.so /usr/lib/hppa-linux-gnu/liblz4.so
/usr/lib/hppa-linux-gnu/libblkid.so -lrt
/usr/lib/hppa-linux-gnu/libmount.so -Wl,--end-group -pthread
'-Wl,-rpath,$ORIGIN/:$ORIGIN/../shared:$ORIGIN/../libsystemd:$ORIGIN/../basic'
-Wl,-rpath-link,/<<PKGBUILDDIR>>/build-deb/src/udev:/<<PKGBUILDDIR>>/build-deb/src/shared:/<<PKGBUILDDIR>>/build-deb/src/libsystemd:/<<PKGBUILDDIR>>/build-deb/src/basic
one sees that ata_id_ata_id.c.o was compiled with just -fPIE:
[393/1547] cc -Isrc/udev/src at udev@@scsi_id at exe -Isrc/udev -I../src/udev
-Isrc/basic -I../src/basic -Isrc/shared -I../src/shared -Isrc/systemd
-I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote
-I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve
-I../src/resolve -Isrc/timesync -I../src/timesync
-I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/libudev
-I../src/libudev -Isrc/core -I../src/core -I../src/libsystemd/sd-bus
-I../src/libsystemd/sd-device -I../src/libsystemd/sd-hwdb
-I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink
-I../src/libsystemd/sd-network -Isrc/libsystemd-network
-I../src/libsystemd-network -I. -I../ -flto -fdiagnostics-color=always
-pipe -D_FILE_OFFSET_BITS=64 -std=gnu99 -Wextra -Werror=undef
-Wlogical-op -Wmissing-include-dirs -Wold-style-definition
-Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn
-Werror=missing-prototypes -Werror=implicit-function-declaration
-Werror=missing-declarations -Werror=return-type
-Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes
-Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow
-Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow
-Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time
-Wnested-externs -ffast-math -fno-common -fdiagnostics-show-option
-fno-strict-aliasing -fvisibility=hidden -fstack-protector
-fstack-protector-strong --param=ssp-buffer-size=4 -fPIE
-ffunction-sections -fdata-sections -Wno-unused-parameter
-Wno-missing-field-initializers -Wno-unused-result
-Wno-format-signedness -Wno-error=nonnull -Werror=shadow -include
config.h -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
-DLOG_REALM=LOG_REALM_UDEV -MD -MQ
'src/udev/src at udev@@scsi_id at exe/scsi_id_scsi_serial.c.o' -MF
'src/udev/src at udev@@scsi_id at exe/scsi_id_scsi_serial.c.o.d' -o
'src/udev/src at udev@@scsi_id at exe/scsi_id_scsi_serial.c.o' -c
../src/udev/scsi_id/scsi_serial.c
However, the objects in the archives used in the link are compiled with
both -fPIE and -fPIC. -fPIC is last in the argument list. For example,
[259/1547] cc -Isrc/shared/src at shared@@systemd-shared-239 at sta
-Isrc/shared -I../src/shared -Isrc/basic -I../src/basic -Isrc/systemd
-I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote
-I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve
-I../src/resolve -Isrc/timesync -I../src/timesync
-I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev
-I../src/udev -Isrc/libudev -I../src/libudev -Isrc/core -I../src/core
-I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device
-I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128
-I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network
-Isrc/libsystemd-network -I../src/libsystemd-network -I. -I../
-I/usr/include/blkid -I/usr/include/uuid -flto
-fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -std=gnu99
-Wextra -Werror=undef -Wlogical-op -Wmissing-include-dirs
-Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal
-Wsuggest-attribute=noreturn -Werror=missing-prototypes
-Werror=implicit-function-declaration -Werror=missing-declarations
-Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2
-Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn
-Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2
-Wwrite-strings -Werror=overflow -Werror=shift-count-overflow
-Werror=shift-overflow=2 -Wdate-time -Wnested-externs -ffast-math
-fno-common -fdiagnostics-show-option -fno-strict-aliasing
-fvisibility=hidden -fstack-protector -fstack-protector-strong
--param=ssp-buffer-size=4 -fPIE -ffunction-sections -fdata-sections
-Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result
-Wno-format-signedness -Wno-error=nonnull -Werror=shadow -include
config.h -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -pthread
-fvisibility=default -MD -MQ
'src/shared/src at shared@@systemd-shared-239 at sta/acpi-fpdt.c.o' -MF
'src/shared/src at shared@@systemd-shared-239 at sta/acpi-fpdt.c.o.d' -o
'src/shared/src at shared@@systemd-shared-239 at sta/acpi-fpdt.c.o' -c
../src/shared/acpi-fpdt.c
The following is recorded for "-fPIC":
dave at mx3210:~/debian/systemd/systemd-239$ objdump -j .gnu.lto_.opts -s
./build-deb/src/shared/src at shared@@systemd-shared-239 at sta/acpi-fpdt.c.o
./build-deb/src/shared/src at shared@@systemd-shared-239 at sta/acpi-fpdt.c.o:
file format elf32-hppa-linux
Contents of section .gnu.lto_.opts:
0000 272d666e 6f2d6f70 656e6d70 2720272d '-fno-openmp' '-
0010 666e6f2d 6f70656e 61636327 20272d4f fno-openacc' '-O
0020 32272027 2d576572 726f723d 756e6465 2' '-Werror=unde
0030 66272027 2d576572 726f723d 6d697373 f' '-Werror=miss
0040 696e672d 70726f74 6f747970 65732720 ing-prototypes'
0050 272d5765 72726f72 3d696d70 6c696369 '-Werror=implici
0060 742d6675 6e637469 6f6e2d64 65636c61 t-function-decla
0070 72617469 6f6e2720 272d5765 72726f72 ration' '-Werror
0080 3d6d6973 73696e67 2d646563 6c617261 =missing-declara
0090 74696f6e 73272027 2d576572 726f723d tions' '-Werror=
00a0 72657475 726e2d74 79706527 20272d57 return-type' '-W
00b0 6572726f 723d696e 636f6d70 61746962 error=incompatib
00c0 6c652d70 6f696e74 65722d74 79706573 le-pointer-types
00d0 2720272d 57657272 6f723d66 6f726d61 ' '-Werror=forma
00e0 743d3227 20272d57 6572726f 723d6f76 t=2' '-Werror=ov
00f0 6572666c 6f772720 272d5765 72726f72 erflow' '-Werror
0100 3d736869 66742d63 6f756e74 2d6f7665 =shift-count-ove
0110 72666c6f 77272027 2d576572 726f723d rflow' '-Werror=
0120 73686966 742d6f76 6572666c 6f773d32 shift-overflow=2
0130 2720272d 576e6f2d 6572726f 723d6e6f ' '-Wno-error=no
0140 6e6e756c 6c272027 2d576572 726f723d nnull' '-Werror=
0150 73686164 6f772720 272d5765 72726f72 shadow' '-Werror
0160 3d666f72 6d61742d 73656375 72697479 =format-security
0170 2720272d 666c746f 2720272d 66666173 ' '-flto' '-ffas
0180 742d6d61 74682720 272d666e 6f2d636f t-math' '-fno-co
0190 6d6d6f6e 2720272d 66646961 676e6f73 mmon' '-fdiagnos
01a0 74696373 2d73686f 772d6f70 74696f6e tics-show-option
01b0 2720272d 666e6f2d 73747269 63742d61 ' '-fno-strict-a
01c0 6c696173 696e6727 20272d66 76697369 liasing' '-fvisi
01d0 62696c69 74793d68 69646465 6e272027 bility=hidden' '
01e0 2d667374 61636b2d 70726f74 6563746f -fstack-protecto
01f0 72272027 2d667374 61636b2d 70726f74 r' '-fstack-prot
0200 6563746f 722d7374 726f6e67 2720272d ector-strong' '-
0210 6666756e 6374696f 6e2d7365 6374696f ffunction-sectio
0220 6e732720 272d6664 6174612d 73656374 ns' '-fdata-sect
0230 696f6e73 2720272d 66646562 75672d70 ions' '-fdebug-p
0240 72656669 782d6d61 703d2f68 6f6d652f refix-map=/home/
0250 64617665 2f646562 69616e2f 73797374 dave/debian/syst
0260 656d642f 73797374 656d642d 3233393d emd/systemd-239=
0270 2e272027 2d665049 43272027 2d667669 .' '-fPIC' '-fvi
0280 73696269 6c697479 3d646566 61756c74 sibility=default
0290 2720272d 2d706172 616d2720 27737370 ' '--param' 'ssp
02a0 2d627566 6665722d 73697a65 3d342700 -buffer-size=4'.
-fPIE and -fPIC are very similar but the former is intended to be used
for code intended for position
independent executables and the latter for shared libraries. Only one
should be specified in any compilation.
For PIE executables, only -fPIE should be used. If -fPIE, -fpie, -fPIC,
-fpic are specified multiple times,
the last one is selected.
Dave
--
John David Anglin dave.anglin at bell.net
More information about the Pkg-systemd-maintainers
mailing list