Bug 1279966 - pkgconfig/-specs=/usr/lib/rpm/redhat/redhat-hardened-ld doesn't work on clang
Summary: pkgconfig/-specs=/usr/lib/rpm/redhat/redhat-hardened-ld doesn't work on clang
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: libssh2
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Paul Howarth
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-10 15:38 UTC by Dr. David Alan Gilbert
Modified: 2015-12-15 10:43 UTC (History)
3 users (show)

Fixed In Version: libssh2-1.6.0-3.fc23
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-15 00:23:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Dr. David Alan Gilbert 2015-11-10 15:38:03 UTC
Description of problem:
I tried building upstream QEMU using clang:
/home/dgilbert/git/qemu-world3/configure' '--cc=clang' '--prefix=/home/dgilbert/try2'

 and it failed with the error:

ERROR: configure test passed without -Werror but failed with -Werror.

digging a bit deeper I find in the config.log:

clang -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -Wno-string-plus-int -Wno-initializer-overrides -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -fstack-protector-strong -I/usr/include/p11-kit-1 -I/usr/include/libpng16 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g -lssh2 -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
clang: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
clang -Werror -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -Wno-string-plus-int -Wno-initializer-overrides -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -fstack-protector-strong -I/usr/include/p11-kit-1 -I/usr/include/libpng16 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g -lssh2 -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
clang: error: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-ld'

as far as I can see, the -specs line comes from a call to

[dgilbert@dgilbert-t530 ~]$ pkg-config libssh2 --libs
-lssh2 -specs=/usr/lib/rpm/redhat/redhat-hardened-ld 

which I guess is gcc/ld specific.

Version-Release number of selected component (if applicable):
libssh2-devel-1.6.0-2.fc23.x86_64
ccache-3.2.4-1.fc23.x86_64

How reproducible:
100%

Steps to Reproduce:
1. download upstream qemu source
2. configure as above ensuring you have libssh2-devel installed

Actual results:
see above

Expected results:
a happy build

Additional info:

Comment 1 Kamil Dudka 2015-11-10 16:11:32 UTC
Related Fesco ticket (the cause of this bug):
https://fedorahosted.org/fesco/ticket/1384

Comment 2 Paul Howarth 2015-11-10 16:22:37 UTC
I think it's safe to patch the libssh2.spec.in file to remove the libdir and LDFLAGS references as the libdir reference is to a standard library directory in Fedora (/usr/lib{64)), and the LDFLAGS bit pulls in flags for the libssh2 build (-specs=...) itself that aren't necessarily wanted by downstream users of the library, which can decide for themselves whether to be hardened or not (see also Bug #1204646).

Any comments Kamil?

Comment 3 Kamil Dudka 2015-11-10 21:17:35 UTC
Indeed.  Dropping @LDFLAGS@ from libssh2.pc.in sounds like a good idea!  I am not sure about -L${libdir} though.  Output of the following command tells me it is pretty common among other packages in Fedora:

grep libdir /usr/lib64/pkgconfig/*.pc

Comment 4 Paul Howarth 2015-11-11 08:41:07 UTC
I think -L${libdir} is common because it's useful from an upstream perspective where users might want to install the library in a non-system path, and hence it gets generated by default in most projects. However, in Fedora, where we're installing into the system library path, it's just (harmless) noise.

Comment 5 Kamil Dudka 2015-11-11 11:28:28 UTC
Yes, it will have no effect in most of the cases.  The question is whether there is any reason to diverge from upstream in this.  @LDFLAGS@ could be removed from libssh2.pc.in also in upstream libssh2.  I see a similar commit in libcurl six years ago:

https://github.com/bagder/curl/commit/4c8adc8f

Comment 6 Fedora Update System 2015-11-11 12:57:05 UTC
libssh2-1.6.0-3.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-5c08769475

Comment 7 Fedora Update System 2015-11-12 03:57:59 UTC
libssh2-1.6.0-3.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update libssh2'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-5c08769475

Comment 8 Fedora Update System 2015-11-15 00:22:57 UTC
libssh2-1.6.0-3.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Kamil Dudka 2015-11-16 08:09:18 UTC
Paul, are you going to send the patch upstream?  I believe it would be useful for upstream libssh2, too.

Comment 10 Paul Howarth 2015-12-04 09:44:14 UTC
(In reply to Kamil Dudka from comment #9)
> Paul, are you going to send the patch upstream?  I believe it would be
> useful for upstream libssh2, too.

I was going to do this but it slipped my mind. Thanks for following up.

Comment 11 Kamil Dudka 2015-12-15 10:43:00 UTC
No problem.  Thank you for getting it fixed!

Upstream commit:
https://github.com/libssh2/libssh2/commit/9bf32da6


Note You need to log in before you can comment on or make changes to this bug.