I’d like to use Fedora OPTFLAGS and BUILD_LDFLAGS for a few of the unique rpm I create locally for my repository and use on different openSUSE installations. The following flags are included in my Fedora/RHEL/CentOS rpmmacros.

%optflags -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 -fcf-protection

%build_ldflags -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld

I plan to copy and adapt “/usr/lib/rpm/redhat/redhat-hardened-ld”, “/usr/lib/rpm/redhat/redhat-hardened-cc1”, “/usr/lib/rpm/redhat/redhat-annobin-cc1”, and “/usr/lib/rpm/redhat/redhat-hardened-ld” to my openSUSE rpmmacros.

Is that practical?

You can configure what you like on OBS via project config. Have you looked at a build log to see what the openSUSE defaults are?


1477 Optflags: * -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type %%{?_lto_cflags}


I got default optflags from

rpm --eval %{optflags}

I can’t find build_ldflags, going to read your link and get back with queries if any.

Thank you.

Line 1511

%build_ldflags %{?_lto_cflags}

Yes, missed it while glancing. I am setting up the environment right now. Thank you.