Rewrite flags inheritance in Lua
And simplify the invocation of the build shell function. (cherry picked from commit 114492e2a8a0447f90fe19cf4631d58d8ce80b49)
This commit is contained in:
parent
94914be52f
commit
b3da3b4101
195
glibc.spec
195
glibc.spec
@ -78,7 +78,7 @@
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
# We do our own build flags management. In particular, see
|
# We do our own build flags management. In particular, see
|
||||||
# rpm_inherit_flags below.
|
# glibc_shell_* below.
|
||||||
%undefine _auto_set_build_flags
|
%undefine _auto_set_build_flags
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@ -1192,78 +1192,97 @@ cat /proc/sysinfo 2>/dev/null || true
|
|||||||
cat /proc/meminfo
|
cat /proc/meminfo
|
||||||
df
|
df
|
||||||
|
|
||||||
# We build using the native system compilers.
|
|
||||||
GCC=gcc
|
|
||||||
GXX=g++
|
|
||||||
|
|
||||||
# Part of rpm_inherit_flags. Is overridden below.
|
|
||||||
rpm_append_flag ()
|
|
||||||
{
|
|
||||||
BuildFlags="$BuildFlags $*"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Propagates the listed flags to rpm_append_flag if supplied by
|
|
||||||
# redhat-rpm-config.
|
|
||||||
BuildFlags="-O2 -g"
|
|
||||||
rpm_inherit_flags ()
|
|
||||||
{
|
|
||||||
local reference=" $* "
|
|
||||||
local flag
|
|
||||||
for flag in $RPM_OPT_FLAGS $RPM_LD_FLAGS ; do
|
|
||||||
if echo "$reference" | grep -q -F " $flag " ; then
|
|
||||||
rpm_append_flag "$flag"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Propgate select compiler flags from redhat-rpm-config. These flags
|
# Propgate select compiler flags from redhat-rpm-config. These flags
|
||||||
# are target-dependent, so we use only those which are specified in
|
# are target-dependent, so we use only those which are specified in
|
||||||
# redhat-rpm-config. We keep the -m32/-m32/-m64 flags to support
|
# redhat-rpm-config. We keep the -m32/-m32/-m64 flags to support
|
||||||
# multilib builds.
|
# multilib builds.
|
||||||
#
|
|
||||||
# Note: For building alternative run-times, care is required to avoid
|
|
||||||
# overriding the architecture flags which go into CC/CXX. The flags
|
|
||||||
# below are passed in CFLAGS.
|
|
||||||
|
|
||||||
rpm_inherit_flags \
|
%{lua:
|
||||||
"-Wp,-D_GLIBCXX_ASSERTIONS" \
|
-- Split the string argument into keys of an associate array.
|
||||||
"-fasynchronous-unwind-tables" \
|
-- The values are set to true.
|
||||||
"-fstack-clash-protection" \
|
local function string_to_array(s)
|
||||||
"-fno-omit-frame-pointer" \
|
local result = {}
|
||||||
"-funwind-tables" \
|
for e in string.gmatch(s, "%S+") do
|
||||||
"-m31" \
|
result[e] = true
|
||||||
"-m32" \
|
end
|
||||||
"-m64" \
|
return result
|
||||||
"-march=armv8-a+lse" \
|
end
|
||||||
"-march=armv8.1-a" \
|
|
||||||
"-march=haswell" \
|
local inherit_flags = {}
|
||||||
"-march=i686" \
|
|
||||||
"-march=x86-64" \
|
-- These flags are put into the CC and CXX arguments to configure.
|
||||||
"-march=x86-64-v2" \
|
-- Alternate builds do not use the flags listed here, only the main build does.
|
||||||
"-march=x86-64-v3" \
|
inherit_flags.cc_main = string_to_array [[
|
||||||
"-march=x86-64-v4" \
|
-march=armv8-a+lse
|
||||||
"-march=z13" \
|
-march=armv8.1-a
|
||||||
"-march=z14" \
|
-march=haswell
|
||||||
"-march=z15" \
|
-march=i686
|
||||||
"-march=zEC12" \
|
-march=x86-64
|
||||||
"-mbackchain" \
|
-march=x86-64-v2
|
||||||
"-mbranch-protection=standard" \
|
-march=x86-64-v3
|
||||||
"-mcpu=power10" \
|
-march=x86-64-v4
|
||||||
"-mcpu=power8" \
|
-march=z13
|
||||||
"-mcpu=power9" \
|
-march=z14
|
||||||
"-mfpmath=sse" \
|
-march=z15
|
||||||
"-mno-omit-leaf-frame-pointer" \
|
-march=zEC12
|
||||||
"-msse2" \
|
-mcpu=power10
|
||||||
"-mstackrealign" \
|
-mcpu=power8
|
||||||
"-mtune=generic" \
|
-mcpu=power9
|
||||||
"-mtune=power10" \
|
-mtune=generic
|
||||||
"-mtune=power8" \
|
-mtune=power10
|
||||||
"-mtune=power9" \
|
-mtune=power8
|
||||||
"-mtune=z13" \
|
-mtune=power9
|
||||||
"-mtune=z14" \
|
-mtune=z13
|
||||||
"-mtune=z15" \
|
-mtune=z14
|
||||||
"-mtune=zEC12" \
|
-mtune=z15
|
||||||
"-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1" \
|
-mtune=zEC12
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Like inherit_flags_cc_main, but also used for alternate builds.
|
||||||
|
inherit_flags.cc = string_to_array [[
|
||||||
|
-m31
|
||||||
|
-m32
|
||||||
|
-m64
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- These flags are passed through CFLAGS and CXXFLAGS.
|
||||||
|
inherit_flags.cflags = string_to_array [[
|
||||||
|
-O2
|
||||||
|
-O3
|
||||||
|
-Wall
|
||||||
|
-Wp,-D_GLIBCXX_ASSERTIONS
|
||||||
|
-fasynchronous-unwind-tables
|
||||||
|
-fno-omit-frame-pointer
|
||||||
|
-fstack-clash-protection
|
||||||
|
-funwind-tables
|
||||||
|
-g
|
||||||
|
-mbackchain
|
||||||
|
-mbranch-protection=standard
|
||||||
|
-mfpmath=sse
|
||||||
|
-mno-omit-leaf-frame-pointer
|
||||||
|
-msse2
|
||||||
|
-mstackrealign
|
||||||
|
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Iterate over the build_cflags RPM variable and emit a shell
|
||||||
|
-- variable that contains the inherited flags of the indicated variant.
|
||||||
|
local function shell_build_flags(variant)
|
||||||
|
local result = {}
|
||||||
|
local inherit = assert(inherit_flags[variant])
|
||||||
|
for f in string.gmatch(rpm.expand("%build_cflags"), "%S+") do
|
||||||
|
if inherit[f] then
|
||||||
|
result[#result + 1] = f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print("glibc_flags_" .. variant .. "=\"" .. table.concat(result, " ")
|
||||||
|
.. "\"\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
shell_build_flags('cc_main') -- Set $glibc_flags_cc_main.
|
||||||
|
shell_build_flags('cc') -- Set $glibc_flags_cc.
|
||||||
|
shell_build_flags('cflags') -- Set $glibc_flags_cflags.
|
||||||
|
}
|
||||||
|
|
||||||
%if 0%{?_annotated_build} > 0
|
%if 0%{?_annotated_build} > 0
|
||||||
# libc_nonshared.a cannot be built with the default hardening flags
|
# libc_nonshared.a cannot be built with the default hardening flags
|
||||||
@ -1285,34 +1304,29 @@ BuildFlagsNonshared="-fplugin=annobin -fplugin-arg-annobin-disable -Wa,--generat
|
|||||||
# %%build - Generic options.
|
# %%build - Generic options.
|
||||||
##############################################################################
|
##############################################################################
|
||||||
EnableKernel="--enable-kernel=%{enablekernel}"
|
EnableKernel="--enable-kernel=%{enablekernel}"
|
||||||
# Save the used compiler and options into the file "Gcc" for use later
|
|
||||||
# by %%install.
|
|
||||||
echo "$GCC" > Gcc
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# build()
|
# build()
|
||||||
# Build glibc in `build-%{target}$1', passing the rest of the arguments
|
# Build glibc in the directory $1, passing the rest of the arguments
|
||||||
# as CFLAGS to the build (not the same as configure CFLAGS). Several
|
# as additional configure arguments. Several
|
||||||
# global values are used to determine build flags, kernel version,
|
# global values are used to determine build flags, kernel version,
|
||||||
# system tap support, etc.
|
# system tap support, etc.
|
||||||
##############################################################################
|
##############################################################################
|
||||||
build()
|
build()
|
||||||
{
|
{
|
||||||
local builddir=build-%{target}${1:+-$1}
|
local builddir=$1
|
||||||
${1+shift}
|
shift
|
||||||
rm -rf $builddir
|
rm -rf $builddir
|
||||||
mkdir $builddir
|
mkdir $builddir
|
||||||
pushd $builddir
|
pushd $builddir
|
||||||
../configure CC="$GCC" CXX="$GXX" CFLAGS="$BuildFlags $*" \
|
../configure "$@" \
|
||||||
--prefix=%{_prefix} \
|
--prefix=%{_prefix} \
|
||||||
--with-headers=%{_prefix}/include $EnableKernel \
|
--with-headers=%{_prefix}/include $EnableKernel \
|
||||||
--with-nonshared-cflags="$BuildFlagsNonshared" \
|
--with-nonshared-cflags="$BuildFlagsNonshared" \
|
||||||
--enable-bind-now \
|
--enable-bind-now \
|
||||||
--build=%{target} \
|
--build=%{target} \
|
||||||
${configure_host} \
|
|
||||||
--enable-stack-protector=strong \
|
--enable-stack-protector=strong \
|
||||||
--enable-systemtap \
|
--enable-systemtap \
|
||||||
${core_with_options} \
|
|
||||||
%ifarch %{ix86}
|
%ifarch %{ix86}
|
||||||
--disable-multi-arch \
|
--disable-multi-arch \
|
||||||
%endif
|
%endif
|
||||||
@ -1347,17 +1361,23 @@ build()
|
|||||||
|
|
||||||
%ifarch x86_64
|
%ifarch x86_64
|
||||||
# Build for the glibc32 package.
|
# Build for the glibc32 package.
|
||||||
GCC="$GCC -m32" GXX="$GXX -m32" BuildFlags="${BuildFlags/-m64/-m32}" configure_host="--host=i686-linux-gnu" build 32
|
build build-%{target}-32 \
|
||||||
%endif
|
CC="gcc -m32" \
|
||||||
|
CXX="g++ -m32" \
|
||||||
configure_host=""
|
CFLAGS="${glibc_flags_cflags/-m64/-m32}" \
|
||||||
|
--host=i686-linux-gnu \
|
||||||
%ifarch x86_64
|
#
|
||||||
configure_host="--enable-cet"
|
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# Default set of compiler options.
|
# Default set of compiler options.
|
||||||
build
|
build build-%{target} \
|
||||||
|
CC="gcc $glibc_flags_cc $glibc_flags_cc_main" \
|
||||||
|
CXX="gcc $glibc_flags_cc $glibc_flags_cc_main" \
|
||||||
|
CFLAGS="$glibc_flags_cflags" \
|
||||||
|
%ifarch x86_64
|
||||||
|
--enable-cet \
|
||||||
|
%endif
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Install glibc...
|
# Install glibc...
|
||||||
@ -1373,9 +1393,6 @@ build
|
|||||||
# Remove existing file lists.
|
# Remove existing file lists.
|
||||||
find . -type f -name '*.filelist' -exec rm -rf {} \;
|
find . -type f -name '*.filelist' -exec rm -rf {} \;
|
||||||
|
|
||||||
# Reload compiler and build options that were used during %%build.
|
|
||||||
GCC=`cat Gcc`
|
|
||||||
|
|
||||||
%ifarch riscv64
|
%ifarch riscv64
|
||||||
# RISC-V ABI wants to install everything in /lib64/lp64d or /usr/lib64/lp64d.
|
# RISC-V ABI wants to install everything in /lib64/lp64d or /usr/lib64/lp64d.
|
||||||
# Make these be symlinks to /lib64 or /usr/lib64 respectively. See:
|
# Make these be symlinks to /lib64 or /usr/lib64 respectively. See:
|
||||||
|
Loading…
Reference in New Issue
Block a user