Build flags: Add support for extension builders (#1543394)
This commit is contained in:
parent
98ffd5040d
commit
e80fa1344a
@ -332,3 +332,44 @@ linker flags:
|
|||||||
security exploits, redirecting execution). Therefore, it is
|
security exploits, redirecting execution). Therefore, it is
|
||||||
preferable to turn of lazy binding, although it increases startup
|
preferable to turn of lazy binding, although it increases startup
|
||||||
time.
|
time.
|
||||||
|
|
||||||
|
# Support for extension builders
|
||||||
|
|
||||||
|
Some packages include extension builders that allow users to build
|
||||||
|
extension modules (which are usually written in C and C++) under the
|
||||||
|
control of a special-purpose build system. This is a common
|
||||||
|
functionality provided by scripting languages such as Python and Perl.
|
||||||
|
Traditionally, such extension builders captured the Fedora build flags
|
||||||
|
when these extension were built. However, these compiler flags are
|
||||||
|
adjusted for a specific Fedora release and toolchain version and
|
||||||
|
therefore do not work with a custom toolchain (e.g., different C/C++
|
||||||
|
compilers), and users might want to build their own extension modules
|
||||||
|
with such toolchains.
|
||||||
|
|
||||||
|
The macros `%{extension_cflags}`, `%{extension_cxxflags}`,
|
||||||
|
`%{extension_fflags}`, `%{extension_ldflags}` contain a subset of
|
||||||
|
flags that have been adjusted for compatibility with alternative
|
||||||
|
toolchains, while still preserving some of the compile-time security
|
||||||
|
hardening that the standard Fedora build flags provide.
|
||||||
|
|
||||||
|
The current set of differences are:
|
||||||
|
|
||||||
|
* No GCC plugins (such as annobin) are activated.
|
||||||
|
* No GCC spec files (`-specs=` arguments) are used.
|
||||||
|
|
||||||
|
Additional flags may be removed in the future if they prove to be
|
||||||
|
incompatible with alternative toolchains.
|
||||||
|
|
||||||
|
Extension builders should detect whether they are performing a regular
|
||||||
|
RPM build (e.g., by looking for an `RPM_OPT_FLAGS` variable). In this
|
||||||
|
case, they should use the *current* set of Fedora build flags (that
|
||||||
|
is, the output from `rpm --eval '%{build_cflags}'` and related
|
||||||
|
commands). Otherwise, when not performing an RPM build, they can
|
||||||
|
either use hard-coded extension builder flags (thus avoiding a
|
||||||
|
run-time dependency on `redhat-rpm-config`), or use the current
|
||||||
|
extension builder flags (with a run-time dependency on
|
||||||
|
`redhat-rpm-config`).
|
||||||
|
|
||||||
|
As a result, extension modules built for Fedora will use the official
|
||||||
|
Fedora build flags, while users will still be able to build their own
|
||||||
|
extension modules with custom toolchains.
|
||||||
|
16
macros
16
macros
@ -57,6 +57,22 @@
|
|||||||
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
|
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
|
||||||
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS
|
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS
|
||||||
|
|
||||||
|
# Internal-only. Do not use. Expand a variable and strip the flags
|
||||||
|
# not suitable to extension builders.
|
||||||
|
%__extension_strip_flags() %{lua:
|
||||||
|
local name = rpm.expand("%{1}")
|
||||||
|
local value = " " .. rpm.expand("%{build_" .. name .. "}")
|
||||||
|
local result = string.gsub(value, "%s+-specs=[^%s]+", " ")
|
||||||
|
print(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Variants of CFLAGS, CXXFLAGS, FFLAGS, LDFLAGS for use within
|
||||||
|
# extension builders.
|
||||||
|
%extension_cflags %{__extension_strip_flags cflags}
|
||||||
|
%extension_cxxflags %{__extension_strip_flags cxxflags}
|
||||||
|
%extension_fflags %{__extension_strip_flags fflags}
|
||||||
|
%extension_ldflags %{__extension_strip_flags ldflags}
|
||||||
|
|
||||||
# Deprecated names. For backwards compatibility only.
|
# Deprecated names. For backwards compatibility only.
|
||||||
%__global_cflags %{build_cflags}
|
%__global_cflags %{build_cflags}
|
||||||
%__global_cxxflags %{build_cxxflags}
|
%__global_cxxflags %{build_cxxflags}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Summary: Red Hat specific rpm configuration files
|
Summary: Red Hat specific rpm configuration files
|
||||||
Name: redhat-rpm-config
|
Name: redhat-rpm-config
|
||||||
Version: 126
|
Version: 127
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
# No version specified.
|
# No version specified.
|
||||||
License: GPL+
|
License: GPL+
|
||||||
@ -199,6 +199,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
|
|||||||
%{_rpmconfigdir}/macros.d/macros.kmp
|
%{_rpmconfigdir}/macros.d/macros.kmp
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Dec 20 2018 Florian Weimer <fweimer@redhat.com> - 127-1
|
||||||
|
- Build flags: Add support for extension builders (#1543394)
|
||||||
|
|
||||||
* Mon Dec 17 2018 Panu Matilainen <pmatilai@redhat.com> - 126-1
|
* Mon Dec 17 2018 Panu Matilainen <pmatilai@redhat.com> - 126-1
|
||||||
- Silence the annoying warning from ldconfig brp-script (#1540971)
|
- Silence the annoying warning from ldconfig brp-script (#1540971)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user