Bug 1548673

Summary: sanlock: Does not use Fedora build flags
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: sanlockAssignee: David Teigland <teigland>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: cfeist, fsimonce, teigland
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sanlock-3.6.0-3.fc29 sanlock-3.6.0-3.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-04 02:22:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1539083    

Description Florian Weimer 2018-02-24 10:43:57 UTC
/usr/lib64/libsanlock.so.1.0, /usr/lib64/libsanlock_client.so.1.0, /usr/lib64/libwdmd.so.1.0 in sanlock-lib-3.6.0-2.fc28.x86_64 have not been linked with the standard Fedora linker flags (LDFLAGS) from redhat-rpm-config.

The existing flags are rather inconsistent:

cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -D_GNU_SOURCE -g -O2 -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option -fPIE -DPIE -DVERSION=\"3.6.0\" -Wl,-z,relro -pie -shared -fPIC -o libwdmd.so.1.0 -Wl,-soname=libwdmd.so.1 client.c wdmd_sock.c

-pie and -shared together does not make sense.

See https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/buildflags.md for information on RPM macros and environment variables provided by the build environment.

Comment 1 David Teigland 2018-03-14 16:12:06 UTC
rebuilt with set_build_flags here
https://koji.fedoraproject.org/koji/taskinfo?taskID=25699461

I don't know why -pie and -shared don't make sense, if it's a problem please tell me which to drop or direct me to a document, thanks.

Comment 2 Florian Weimer 2018-03-14 16:22:45 UTC
(In reply to David Teigland from comment #1)
> rebuilt with set_build_flags here
> https://koji.fedoraproject.org/koji/taskinfo?taskID=25699461

This looks to me like LDFLAGS injection is still not working:

cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -D_GNU_SOURCE -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare -Wno-strict-overflow -fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option -O2 -Wp,-D_FORTIFY_SOURCE=2  -DVERSION=\"3.6.0\" -lpthread -lrt -laio -lblkid -L../wdmd -lwdmd -Wl,-z,relro -pie -shared -fPIC -o libsanlock.so.1.0 -Wl,-soname=libsanlock.so.1 client.c sanlock_sock.c crc32c.c diskio.c ondisk.c delta_lease.c paxos_lease.c direct.c task.c timeouts.c direct_lib.c monotime.c

I think the makefile completely ignores LDFLAGS, so %{set_build_flags} doesn't have the desired effect.

> I don't know why -pie and -shared don't make sense, if it's a problem please
> tell me which to drop or direct me to a document, thanks.

Please drop -pie when linking shared objects, and only use -shared.  Shared objects cannot use PIE relocations.  They need to use PIC relocations (which are position-independent as well).  The upstream makefile gets this wrong.

Comment 3 David Teigland 2018-03-14 17:19:21 UTC
Thanks, I made some flags change in the makefiles, please take a look at this latest build, https://koji.fedoraproject.org/koji/taskinfo?taskID=25700979


cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -D_GNU_SOURCE -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare -Wno-strict-overflow -fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option -O2 -Wp,-D_FORTIFY_SOURCE=2  -DVERSION=\"3.6.0\" -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -shared -fPIC -o libsanlock.so.1.0 -Wl,-soname=libsanlock.so.1 client.c sanlock_sock.c crc32c.c diskio.c ondisk.c delta_lease.c paxos_lease.c direct.c task.c timeouts.c direct_lib.c monotime.c -lpthread -lrt -laio -lblkid -L../wdmd -lwdmd
ln -sf libsanlock.so.1.0 libsanlock.so

Comment 4 Florian Weimer 2018-03-15 08:53:42 UTC
(In reply to David Teigland from comment #3)
> Thanks, I made some flags change in the makefiles, please take a look at
> this latest build,
> https://koji.fedoraproject.org/koji/taskinfo?taskID=25700979

There's some flag duplication now (LDFLAGS is included multiple times), but the end result looks good.  Would you put this into Fedora 28 as well, please?

Comment 5 Fedora Update System 2018-03-15 14:22:35 UTC
sanlock-3.6.0-3.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-7ed557a04e

Comment 7 Fedora Update System 2018-03-16 14:44:40 UTC
sanlock-3.6.0-3.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-7ed557a04e

Comment 8 Jan Kurik 2018-08-14 11:23:15 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 29 development cycle.
Changing version to '29'.

Comment 9 Fedora Update System 2018-12-04 02:22:19 UTC
sanlock-3.6.0-3.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.