Description of problem: Since Fedora was switched to used hardened ld flags by default, autoconf/libtool is no longer able to detect working -static flag with gcc. This prevents libtool from creating statically linked binaries when asked to. A minimal config that can demonstrate this: $ cat configure.ac AC_INIT([demo],[0.1]) AC_CONFIG_SRCDIR([configure.ac]) AM_INIT_AUTOMAKE LT_INIT AC_OUTPUT $ autoreconf -i -f (ignore the automake error, its harmless for purpose of this demo) Run configure with no special flags and it'll detect working -static: $ ./configure | grep "static flag" checking if gcc static flag -static works... yes Run it with the LDFLAGS & CFLAGS that RPM now sets by default: $ LDFLAGS='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' strace -o c.log -f -ff -s 1000 ./configure | grep "static flag" checking if gcc static flag -static works... no And see it is now broken. The problem comes from "/usr/lib/rpm/redhat/redhat-hardened-ld" which is adding '-pie' flag to all compiler invocations. This can be confirmed by using strace c.log.18810:execve("/usr/lib64/ccache/gcc", ["gcc", "-o", "conftest", "-O2", "-g", "-pipe", "-Wall", "-Werror=format-security", "-Wp,-D_FORTIFY_SOURCE=2", "-fexceptions", "-fstack-protector-strong", "--param=ssp-buffer-size=4", "-grecord-gcc-switches", "-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1", "-m64", "-mtune=generic", "-Wl,-z,relro", "-specs=/usr/lib/rpm/redhat/redhat-hardened-ld", "-static", "conftest.c"], [/* 71 vars */]) = 0 this ultimately calls LD with execve("/usr/bin/ld", ["/usr/bin/ld", "-plugin", "/usr/libexec/gcc/x86_64-redhat-linux/5.3.1/liblto_plugin.so", "-plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/5.3.1/lto-wrapper", "-plugin-opt=-fresolution=/tmp/ccEZDac7.res", "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_eh", "-plugin-opt=-pass-through=-lc", "--build-id", "--no-add-needed", "--hash-style=gnu", "-m", "elf_x86_64", "-static", "-z", "now", "-pie", "-o", "conftest", "/usr/lib/gcc/x86_64-redhat-linux/5.3.1/../../../../lib64/Scrt1.o", "/usr/lib/gcc/x86_64-redhat-linux/5.3.1/../../../../lib64/crti.o", "/usr/lib/gcc/x86_64-redhat-linux/5.3.1/crtbeginT.o", "-L/usr/lib/gcc/x86_64-redhat-linux/5.3.1", "-L/usr/lib/gcc/x86_64-redhat-linux/5.3.1/../../../../lib64", "-L/lib/../lib64", "-L/usr/lib/../lib64", "-L/usr/lib/gcc/x86_64-redhat-linux/5.3.1/../../..", "-z", "relro", "/tmp/cczoe5fv.o", "--start-group", "-lgcc", "-lgcc_eh", "-lc", "--end-group", "/usr/lib/gcc/x86_64-redhat-linux/5.3.1/crtendS.o", "/usr/lib/gcc/x86_64-redhat-linux/5.3.1/../../../../lib64/crtn.o"], [/* 77 vars */]) = 0 see -static and -pie at the same time write(2, "/usr/lib/gcc/x86_64-redhat-linux/5.3.1/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC", 162) = 162 It is not permitted to use -pie and -static at the same time, so this addition causes gcc to report an error, which autoconf interprets as -static being broken. The hardened ld flags specs need to somehow be changed so that they do not add -pie when -static is being used Version-Release number of selected component (if applicable): redhat-rpm-config-36-1.fc23.1.noarch
Seems to be duplicate of 1287743?
I naively tried editting the redhat-hardened-ld file to contain + %{!shared:%{!static:%{!r:-pie}}} but this didn't appear to have any effect - it still passed -pie, even when '-static' was given to gcc. I guess I'm not understanding the specs file semantics correctly
(In reply to Daniel Berrange from comment #2) > I naively tried editting the redhat-hardened-ld file to contain > > + %{!shared:%{!static:%{!r:-pie}}} This works for me in redhat-hardened-ld: *self_spec: + %{!static:%{!shared:%{!r:-pie}}} It makes sense to add something similar to redhat-hardened-cc1, to avoid -fPIE if -static is specified (because PIC code has a slight overhead).
(In reply to Pavel Raiskup from comment #1) > Seems to be duplicate of 1287743? I agree it's a duplicate.
Hmm, yes, what Florian shows does in fact work for me - I must have typoed when I tried it previously.
*** Bug 1204162 has been marked as a duplicate of this bug. ***
@ajax: since you seem to have dealt with the hardened build flags previously, could you get the fix Florian describes applied to rawhide & stable branches
*** Bug 1287743 has been marked as a duplicate of this bug. ***
Fixed as per comment #3 in redhat-rpm-config-54-1.fc26 I suppose affected stable versions need this too but lets see what happens in rawhide first, I can't say I'm familiar with gcc specs so this is all just "well it doesn't seem to break anything so..."
This message is a reminder that Fedora 23 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 23. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '23'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 23 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
(In reply to Panu Matilainen from comment #9) > Fixed as per comment #3 in redhat-rpm-config-54-1.fc26 > > I suppose affected stable versions need this too but lets see what happens > in rawhide first, I can't say I'm familiar with gcc specs so this is all > just "well it doesn't seem to break anything so..." Moving to F25 to prevent auto-closing.
Could we please have this backported to Fedora 24 and Fedora 25? Or at least Fedora 25? This causes me issues with snapd builds as well.
This message is a reminder that Fedora 25 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 25. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '25'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 25 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.