Compare commits

...

26 Commits

Author SHA1 Message Date
David Abdurachmanov a22a7f7f09
Add riscv64 changes
Signed-off-by: David Abdurachmanov <davidlt@rivosinc.com>
2023-07-27 17:06:31 +03:00
David Abdurachmanov 965b2d4f0f
Merge remote-tracking branch 'up/main' into main-riscv64
Signed-off-by: David Abdurachmanov <davidlt@rivosinc.com>
2023-07-27 16:58:50 +03:00
Florian Weimer f447520e2d Fix warnings that appear during the build of the llvm package
The package redefines %optflags on i686 and s390x, so the
%__build_for_lang_* macros are no longer expanded, triggering
a warning from RPM (“%__build_for_lang_any defined but not
used within scope”).  Clang warns about -Wno-complain-wrong-lang
with -Wall, so the warning option is suppressed for
"%toolchain" != "gcc".

Reported-by: Tulio Magno Quites Machado Filho <tuliom@ascii.art.br>
2023-07-07 13:58:33 +02:00
Florian Weimer d9c3154737 Drop armv7hl from frame pointer tests
Fixes commit 24244c4ac2 ("Remove armv7hl from optflags").
2023-07-05 17:26:54 +02:00
Florian Weimer 246107d5f6 Implement the %build_type_safety_c macro (#2218019)
The default remains at 0 (no change) until the corresponding Fedora
change proposal is accepted:

  <https://fedoraproject.org/wiki/Changes/GNUToolchainF39>
2023-07-05 14:28:21 +02:00
Florian Weimer 7692bbaf45 Filter out C, C++ build flags from Fortran build flags (#2177253)
And pave the way for future front-end-specific compiler flags.
2023-07-05 13:04:12 +02:00
Florian Weimer 24244c4ac2 Remove armv7hl from optflags
Fedora 36 is gone.
2023-07-05 13:03:34 +02:00
Florian Weimer 77c5fc5b62 Fix typo in comment 2023-07-05 13:03:34 +02:00
Florian Weimer 0f50409ae6 Enable PIC mode for assembler files (#2167430) 2023-07-05 13:03:33 +02:00
Frédéric Bérat c4c1f3b8d4 gnuconfig: sync with upstream git 2023-07-05 10:08:56 +02:00
Tom Stellard 76bd9dd983 Remove -fno-openmp-implicit-rpath from clang ldflags
This option was dropped from upstream.
2023-06-30 23:43:40 +00:00
Tom Stellard dff3d6a440 Update tests to work with dnf5 2023-06-30 23:06:10 +00:00
Lumir Balhar 2f741f9841 Add qt6-srpm-macros 2023-06-16 13:17:04 +02:00
Florian Weimer ee3d1273d6 Switch ELN to x86-64-v3
Fixes: https://github.com/fedora-eln/eln/issues/83
Co-Authored-By: Stephen Gallagher <sgallagh@redhat.com>
2023-03-09 14:19:20 +01:00
Maxwell G 16122a6127
%set_build_flags: unconditionally set RUSTFLAGS 2023-02-28 18:29:18 -06:00
Maxwell G 4d945d4291
Test RUSTFLAGS addition 2023-02-28 18:29:18 -06:00
Maxwell G 9fb7ec9c17 Include RUSTFLAGS in %set_build_flags
Resolves: https://bugzilla.redhat.com/2167183
2023-02-28 17:31:25 -06:00
Tom Stellard e0e0971163 Rename _pkg_extra_* macros to _distro_extra_* macros
The two intended uses cases for the _pkg_extra_* macros were to
make it easier for packagers to add new compile flags for use
with their package and also to make it easier to do distro wide
experiments with new flags.

However, it was pointed out on the mailing list[1] that you
can't satisfy both of these uses cases at the same time with
just one set of macros.  For example, if a packager uses
_pkg_extra_* macros to add flags specific to their own
package, then someone using _pkg_extra_* macros to
apply a new flag distro wide would override the package
specific flag.

I feel like the distro-wide use case is much more important,
so rather than create two sets of new flags, one for each use
case, I think it's best to rename the _pkg_extra_* macros
to _distro_extra_* and document that they are only meant
to be used for adding distro-wide flags and packagers should
not use this macro.

[1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/TOG5RHWPS3VYMM52HFGZOUJVRCGZ7VXB/
2023-02-28 15:26:26 +00:00
Miro Hrončok e64c3b8273 Drop the requirement of orphaned nim-srpm-macros
No Fedora package uses the %nim_arches macro.

This reverts commit ebb7ec32a4.
2023-02-23 01:31:27 +01:00
Frédéric Bérat 99fec12998 gnuconfig: sync with upstream git 2023-02-14 13:23:48 +01:00
Jerry James d9236d19eb Add macros.gap-srpm with supported GAP arches 2023-02-10 11:47:17 +01:00
Miro Hrončok c82a365885 Fix a typo in %changelog 2023-02-10 11:45:22 +01:00
Tom Stellard 1988722cbb Add %pkg_extra_* macros
https://fedoraproject.org/wiki/Changes/RPMMacrosForBuildFlags
2023-02-07 14:31:38 +00:00
Nick Clifton ab1e005d6a Fix triggers for the installation and removal of gcc-plugin-annobin.
Fixes: rhbz#2124562
2023-02-06 12:27:22 +00:00
Miro Hrončok 29a0bd8be0 Add pyproject-srpm-macros to the default buildroot 2023-01-18 14:56:38 +01:00
Davide Cavalca 26c1ceaece Do not include frame pointers on ppc64le for now 2023-01-17 13:40:35 -08:00
19 changed files with 308 additions and 59 deletions

View File

@ -36,9 +36,7 @@ Individual build flags are also available through RPM macros:
* `%{build_cxx}` for the command name of the C++ compiler.
* `%{build_cpp}` for the command name of the C-compatible preprocessor.
* `%{build_cflags}` for the C compiler flags (also known as the
`CFLAGS` variable). Also historically available as `%{optflags}`.
Furthermore, at the start of the `%build` section, the environment
variable `RPM_OPT_FLAGS` is set to this value.
`CFLAGS` variable).
* `%{build_cxxflags}` for the C++ compiler flags (usually assigned to
the `CXXFLAGS` shell variable).
* `%{build_fflags}` for `FFLAGS` (the Fortran compiler flags, also
@ -50,6 +48,13 @@ Individual build flags are also available through RPM macros:
driver. At the start of the `%build` section, the environment
variable `RPM_LD_FLAGS` is set to this value.
The C and C++ compiler flags are historically available as the
`%{optflags}` macro. These flags may not contain flags that work with
certain languagues or compiler front ends, so the language-specific
`%build_*` are more precise. At the start of the `%build` section,
the environment variable `RPM_OPT_FLAGS` is set to the `%{optflags}`
value; similar limitations apply.
The variable `LT_SYS_LIBRARY_PATH` is defined here to prevent the `libtool`
script (v2.4.6+) from hardcoding `%_libdir` into the binaries' `RPATH`.
@ -109,6 +114,55 @@ or:
BuildRequires: clang compiler-rt
%endif
### Controlling Type Safety
The macro `%build_type_safety_c` can be set to change the C type
safety level. By default (value 0), all C constructs that GCC accepts
for backwards compatibility with obsolete language standards are
accepted during package builds. Packages can set
`%build_type_safety_c` to higher values to adopt future
distribution-wide type-safety increases early.
When changing the `%build_type_safety_c` level to increase it, spec
file should use a construct like this to avoid *lowering* a future
default:
```
%if %build_type_safety_c < 2
%global %build_type_safety_c 2
%endif
```
At level 1, the following additional error categories are enabled:
* `-Werror=implicit-int`: Reject declarations and definitions that
omit a type name where one is required. Examples are:
`extern int_variable;`, `extern int_returning_function (void);`,
and missing separate parameter type declarations in old-style
function definitions.
* `-Werror=implicit-function-declaration`: Reject calls to functions
to undeclared functions such as `function_not_defined_anywhere ()`.
Previously, such expressions where we compiled as if a declaration
`extern int function_not_defined_anywhere ();` (a prototype-less
function declaration) were in scope.
At level 2, the following error category is enabled in addition:
* `-Werror=int-conversion`: Reject the use of integer expressions
where a pointer type expected, and pointer expressions where an
integer type is expected. Without this option, GCC may produce an
executable, but often, there are failures at run time because not
the full 64 bits of pointers are preserved.
The additional level 3 error category is:
* `-Werror=incompatible-pointer-types`: An expression of one pointer
type is used where different pointer type is expected. (This does
not cover signed/unsigned mismatches in the pointer target type.)
Clang errors out on more obsolete and invalid C constructs than C, so
the type safety is higher by default than with the GCC toolchain.
### Disable autotools compatibility patching
By default, the invocation of the `%configure` macro replaces
@ -402,12 +456,16 @@ The general (architecture-independent) build flags are:
compilation performance. (This does not affect code generation.)
* `-Wall`: Turn on various GCC warnings.
See the [GCC manual](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall).
* `-Wno-complain-wrong-lang`: Do not warn about front end mismatches
(e.g, using `-Werror=format-security` with Fortran). Only included
in `%optflags`, and not the front-end-specific `%build_*` macros.
* `-Werror=format-security`: Turn on format string warnings and treat
them as errors.
See the [GCC manual](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wformat-security).
This can occasionally result in compilation errors. In that case,
the best option is to rewrite the source code so that only constant
format strings (string literals) are used.
* Other `-Werror=` options. See **Controlling C Type Safety**.
* `-U_FORTIFY_SOURCE, -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3`:
See the Source Fortification section above and the `%_fortify_level`
override.

28
config.guess vendored
View File

@ -1,10 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2022 Free Software Foundation, Inc.
# Copyright 1992-2023 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2022-05-25'
timestamp='2023-06-23'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -47,7 +47,7 @@ me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Output the configuration name of the system '$me' is run on.
Options:
-h, --help print this help, then exit
@ -60,13 +60,13 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2022 Free Software Foundation, Inc.
Copyright 1992-2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
Try '$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
@ -102,8 +102,8 @@ GUESS=
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
# use 'HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
@ -459,7 +459,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
# Japanese Language versions have a version number like '4.1.3-JL'.
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
GUESS=sparc-sun-sunos$SUN_REL
;;
@ -966,6 +966,12 @@ EOF
GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
;;
x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
;;
*:[Mm]anagarm:*:*)
GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
;;
*:Minix:*:*)
GUESS=$UNAME_MACHINE-unknown-minix
;;
@ -1036,7 +1042,7 @@ EOF
k1om:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
loongarch32:Linux:*:* | loongarch64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
m32r*:Linux:*:*)
@ -1191,7 +1197,7 @@ EOF
GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# If we were able to find 'uname', then EMX Unix compatibility
# is probably installed.
GUESS=$UNAME_MACHINE-pc-os2-emx
;;
@ -1332,7 +1338,7 @@ EOF
GUESS=ns32k-sni-sysv
fi
;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
GUESS=i586-unisys-sysv4
;;

49
config.sub vendored
View File

@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2022 Free Software Foundation, Inc.
# Copyright 1992-2023 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2022-01-03'
timestamp='2023-06-23'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -76,13 +76,13 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright 1992-2022 Free Software Foundation, Inc.
Copyright 1992-2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
Try '$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
@ -130,7 +130,7 @@ IFS=$saved_IFS
# Separate into logical components for further validation
case $1 in
*-*-*-*-*)
echo Invalid configuration \`"$1"\': more than four components >&2
echo "Invalid configuration '$1': more than four components" >&2
exit 1
;;
*-*-*-*)
@ -145,7 +145,7 @@ case $1 in
nto-qnx* | linux-* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
| storm-chaos* | os2-emx* | rtmk-nova*)
| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
basic_machine=$field1
basic_os=$maybe_os
;;
@ -943,7 +943,7 @@ $basic_machine
EOF
IFS=$saved_IFS
;;
# We use `pc' rather than `unknown'
# We use 'pc' rather than 'unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
@ -1075,7 +1075,7 @@ case $cpu-$vendor in
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
cpu=i586
;;
pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
cpu=i686
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
@ -1207,7 +1207,7 @@ case $cpu-$vendor in
| k1om \
| le32 | le64 \
| lm32 \
| loongarch32 | loongarch64 | loongarchx32 \
| loongarch32 | loongarch64 \
| m32c | m32r | m32rle \
| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
@ -1285,7 +1285,7 @@ case $cpu-$vendor in
;;
*)
echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
exit 1
;;
esac
@ -1341,6 +1341,10 @@ EOF
kernel=linux
os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
;;
managarm*)
kernel=managarm
os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
;;
*)
kernel=
os=$basic_os
@ -1754,7 +1758,7 @@ case $os in
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
| fiwix* )
| fiwix* | mlibc* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
@ -1762,8 +1766,11 @@ case $os in
;;
none)
;;
kernel* )
# Restricted further below
;;
*)
echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
exit 1
;;
esac
@ -1772,14 +1779,24 @@ esac
# (given a valid OS), if there is a kernel.
case $kernel-$os in
linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
| linux-musl* | linux-relibc* | linux-uclibc* )
| linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
;;
uclinux-uclibc* )
;;
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
managarm-mlibc* | managarm-kernel* )
;;
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
# These are just libc implementations, not actual OSes, and thus
# require a kernel.
echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
exit 1
;;
-kernel* )
echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
exit 1
;;
*-kernel* )
echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
exit 1
;;
kfreebsd*-gnu* | kopensolaris*-gnu*)
@ -1796,7 +1813,7 @@ case $kernel-$os in
# Blank kernel with real OS is always fine.
;;
*-*)
echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
exit 1
;;
esac

48
macros
View File

@ -57,14 +57,14 @@
# C compiler flags. This is traditionally called CFLAGS in makefiles.
# Historically also available as %%{optflags}, and %%build sets the
# environment variable RPM_OPT_FLAGS to this value.
%build_cflags %{optflags}
%build_cflags %{__build_flags_lang_c} %{?_distro_extra_cflags}
# C++ compiler flags. This is traditionally called CXXFLAGS in makefiles.
%build_cxxflags %{optflags}
%build_cxxflags %{__build_flags_lang_cxx} %{?_distro_extra_cxxflags}
# Fortran compiler flags. Makefiles use both FFLAGS and FCFLAGS as
# the corresponding variable names.
%build_fflags %{optflags} -I%{_fmoddir}
%build_fflags %{__build_flags_common} -I%{_fmoddir} %{?_distro_extra_fflags}
# Vala compiler flags. This is used to set VALAFLAGS.
%build_valaflags -g
@ -72,14 +72,14 @@
# When clang is used as a linker driver, it does not auto-detect the LTO
# bytecode and neither does bfd, so we need to explicitly pass the -flto
# flag when linking.
%_clang_extra_ldflags %{?_lto_cflags} -fno-openmp-implicit-rpath
%_clang_extra_ldflags %{?_lto_cflags}
# Link editor flags. This is usually called LDFLAGS in makefiles.
# (Some makefiles use LFLAGS instead.) The default value assumes that
# the flags, while intended for ld, are still passed through the gcc
# compiler driver. At the beginning of %%build, the environment
# variable RPM_LD_FLAGS to this value.
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags}
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags} %{?_distro_extra_ldflags}
# Expands to shell code to set the compiler/linker environment
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they
@ -92,6 +92,7 @@
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ; \
RUSTFLAGS="${RUSTFLAGS:-%{build_rustflags}}" ; export RUSTFLAGS ; \
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \
LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH ; \
CC="${CC:-%{__cc}}" ; export CC ; \
@ -137,7 +138,9 @@ print(result)
# Architecture-specific support. Internal. Do not use directly.
%__cflags_arch_x86_64 %[0%{?rhel} >= 9 ? "-march=x86-64-v2" : ""]
%__cflags_arch_x86_64_v2 %[0%{?rhel} == 9 ? "-march=x86-64-v2" : ""]
%__cflags_arch_x86_64_v3 %[0%{?rhel} > 9 ? "-march=x86-64-v3" : ""]
%__cflags_arch_x86_64 %{__cflags_arch_x86_64_v2} %{__cflags_arch_x86_64_v3}
# Also used for s390.
%__cflags_arch_s390x %[0%{?rhel} >= 9 ? "-march=z14 -mtune=z15" : "-march=z13 -mtune=z14"]
@ -305,6 +308,12 @@ print(result)
# Use Zstandard compression for binary payloads
%_binary_payload w19.zstdio
#==============================================================================
# --- Compiler flags control.
#
# Please consult buildflags.md for parts that can be configured
# from RPM spec files.
%_hardening_gcc_cflags -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
%_hardening_clang_cflags --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg
%_hardening_cflags %{expand:%%{_hardening_%{toolchain}_cflags}} -fstack-protector-strong
@ -363,7 +372,8 @@ print(result)
# way we can detect installing an unusable .o/.a file. This is on the TODO
# list for F34.
%_gcc_lto_cflags -flto=auto -ffat-lto-objects
%_clang_lto_cflags -flto=thin
# riscv64 does not have ld.gold support needed for LTO with Clang.
%_clang_lto_cflags %{nil}
%_lto_cflags %{expand:%%{_%{toolchain}_lto_cflags}}
# Default fortification level.
@ -375,12 +385,16 @@ print(result)
%_fortify_level 3
%_fortify_level_flags %[ 0%{?_fortify_level} > 0 ? "-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=%{_fortify_level}" : "" ]
# Some linkers default to a build-id algoritim that is not supported by rpmbuild,
# This can be set to a positive integer to obtain increasing type
# safety levels for C. See buildflags.md.
%build_type_safety_c 0
# Some linkers default to a build-id algorithm that is not supported by rpmbuild,
# so we need to specify the right algorithm to use.
%_build_id_flags -Wl,--build-id=sha1
%_general_options -O2 %{?_lto_cflags} -fexceptions -g -grecord-gcc-switches -pipe
%_warning_options -Wall -Werror=format-security
%_warning_options -Wall%[%__build_for_lang_any && "%toolchain" == "gcc" ? " -Wno-complain-wrong-lang" : ""]%[%__build_for_lang_c + %__build_for_lang_cxx ? " -Werror=format-security" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 1) ? " -Werror=implicit-function-declaration -Werror=implicit-int" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 2) ? " -Werror=int-conversion" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 3) ? " -Werror=incompatible-pointer-types" : ""]
%_preprocessor_defines %{_fortify_level_flags} -Wp,-D_GLIBCXX_ASSERTIONS
# Common variables are no longer generated by default by gcc and clang
@ -389,6 +403,22 @@ print(result)
%__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags} %{_annotation_cflags} %{_legacy_options}
# Internal macros. Do not use directly. These variables can be rebound
# to suppress certain frontend-specific compiler flags (or in the case
# of __build_for_lang_any, frontend-agnostic flags). Dynamic scoping
# and shadowing redefinitions are used for the __build_for_* variables
# to remain largely compatible with existing spec files that have
# hard-coded assumptions which macros assume which other macros.
# The __build_flags_no_macro_warning construct suppresses a warning
# about unused RPM macros.
%__build_for_lang_c 1
%__build_for_lang_cxx 1
%__build_for_lang_any 1
%__build_flags_no_macro_warning %[%__build_for_lang_c + %__build_for_lang_cxx + %__build_for_lang_any ? "" : ""]
%__build_flags_common() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
%__build_flags_lang_c() %{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
%__build_flags_lang_cxx() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
# Automatically trim changelog entries after 2 years
%_changelog_trimage %{expr:2*365*24*60*60}

2
macros.gap-srpm Normal file
View File

@ -0,0 +1,2 @@
# Arches that GAP runs on
%gap_arches aarch64 ppc64le s390x x86_64 riscv64

View File

@ -1,2 +1,5 @@
*cc1_options:
+ %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}
*cpp_options:
+ %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}

View File

@ -4,7 +4,7 @@
# 2) When making changes, increment the version (in baserelease) by 1.
# rpmdev-bumpspec and other tools update the macro below, which is used
# in Version: to get the desired effect.
%global baserelease 244
%global baserelease 261
Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config
@ -40,6 +40,7 @@ Source103: macros.nodejs-srpm
Source104: macros.ldc-srpm
Source105: macros.valgrind-srpm
Source106: macros.java-srpm
Source107: macros.gap-srpm
# Other misc macros
Source150: macros.build-constraints
@ -102,14 +103,16 @@ Requires: perl-srpm-macros
# ↓ Has Python BRPs originaly present in redhat-rpm-config
Requires: python-srpm-macros >= 3.11-7
Requires: qt5-srpm-macros
Requires: rust-srpm-macros
Requires: qt6-srpm-macros
# rust-srpm-macros v24 contains %%build_rustflags defintion
Requires: rust-srpm-macros >= 24
Requires: rpmautospec-rpm-macros
Requires: package-notes-srpm-macros
Requires: pyproject-srpm-macros
%if ! 0%{?rhel}
Requires: fpc-srpm-macros
Requires: gnat-srpm-macros
Requires: nim-srpm-macros
Requires: ansible-srpm-macros
%endif
@ -172,16 +175,46 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
# This trigger is used to decide which version of the annobin plugin for gcc
# should be used. See comments in the script for full details.
#
# Note - whilst "gcc-plugin-annobin" requires "gcc" and hence in theory we
# do not need to trigger on "gcc", the redhat-annobin-plugin-select.sh
# script invokes gcc to determine the version of the gcc plugin, and this
# can be significant.
#
# For example, suppose that version N of gcc is installed and that annobin
# version A (built by gcc version N) is also installed. Then a new version
# of gcc is released. If the rpms are updated in this order:
# gcc-plugin-annobin
# gcc
# then when the trigger for gcc-plugin-annobin is run, the script will see
# (the not yet updated) gcc is currently version N, which matches the current
# annobin plugin A, so no changes are necessary. Then gcc is updated and,
# if the trigger below did not include "gcc", the script would not run again
# and so now you would have an out of date version of the annobin plugin.
#
# Alternatively imagine installing gcc and annobin for the first time.
# If the installation order is:
# gcc
# annobin-plugin-gcc
# gcc-plugin-annobin
# then the installation of gcc will not cause the gcc-plugin-annobin to be
# selected, since it does not exist yet. Then annobin-plugin-gcc is installed
# and since it is the only plugin, it will be selected. Then
# gcc-plugin-annobin is installed, and if the trigger below was not set to
# run on gcc-plugin-annobin, it would pass unnoticed.
#
# Hence it is necessary to trigger on both gcc and gcc-plugin-annobin.
%triggerin -- annobin-plugin-gcc gcc
%triggerin -- annobin-plugin-gcc gcc-plugin-annobin gcc
%{rrcdir}/redhat-annobin-plugin-select.sh
%end
# We also trigger when annobin is uninstalled. This allows us to switch
# over to the gcc generated version of the plugin. It does not matter if
# gcc is uninstalled, since if that happens the plugin cannot be used.
# We also trigger when an annobin plugin is uninstalled. This allows us to
# switch over to the other version of the plugin. Note - we do not bother
# triggering on the uninstallation of "gcc", since if that is removed, the
# plugins are rendered useless.
%triggerpostun -- annobin-plugin-gcc
%triggerpostun -- annobin-plugin-gcc gcc-plugin-annobin
%{rrcdir}/redhat-annobin-plugin-select.sh
%end
@ -221,8 +254,65 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
%doc buildflags.md
%changelog
* Tue Jan 17 2023 David Abdurachmanov <davidlt@rivosinc.com> - 244-1.0.riscv64
- Add riscv64 to nodejs and java arches
* Thu Jul 27 2023 David Abdurachmanov <davidlt@rivosinc.com> - 261-1.0.riscv64
- Add riscv64 to %%gap_arches, %%java_arches, and %%nodejs_arches
- Set %%_clang_lto_cflags to %%nil as ld.gold is not implemented for riscv64
and thus LTO with Clang doesn't work.
* Fri Jul 7 2023 Florian Weimer <fweimer@redhat.com> - 261-1
- Fix warnings that appear during the build of the llvm package
* Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 260-1
- Implement the %%build_type_safety_c macro (#2218019)
* Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 259-1
- Filter out C, C++ build flags from Fortran build flags (#2177253)
* Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 258-1
- Enable PIC mode for assembler files (#2167430)
* Wed Jul 05 2023 Frederic Berat <fberat@redhat.com> - 257-1
- update config.{guess,sub} to gnuconfig git HEAD
* Sat Jun 17 2023 Tom Stellard <tstellar@redhat.com> - 256-1
- Remove -fno-openmp-implicit-rpath from clang ldflags
* Fri Jun 16 2023 Lumír Balhar <lbalhar@redhat.com> - 255-1
- Add qt6-srpm-macros
* Thu Mar 9 2023 Florian Weimer <fweimer@redhat.com> - 254-1
- Switch ELN to x86-64-v3
* Tue Feb 28 2023 Maxwell G <gotmax@e.email> - 253-1
- Include RUSTFLAGS in %%set_build_flags
- Fixes: rhbz#2167183
* Tue Feb 28 2023 Tom Stellard <tstellar@redhat.com> - 252-1
- Rename _pkg_extra_* macros to _distro_extra_*
* Thu Feb 23 2023 Miro Hrončok <mhroncok@redhat.com> - 251-1
- Drop the requirement of orphaned nim-srpm-macros
- No Fedora package uses the %%nim_arches macro
* Tue Feb 14 2023 Frederic Berat <fberat@redhat.com> - 250-1
- update config.{guess,sub} to gnuconfig git HEAD
* Thu Feb 09 2023 Jerry James <loganjerry@gmail.com> - 249-1
- Add macros.gap-srpm
* Tue Feb 07 2023 Tom Stellard <tstellar@redhat.com> - 248-1
- Add %%pkg_extra_* macros
* Mon Feb 06 2023 Nick Clifton <nickc@redhat.com> - 247-1
- Fix triggers for the installation and removal of gcc-plugin-annobin.
Fixes: rhbz#2124562
* Tue Jan 17 2023 Miro Hrončok <mhroncok@redhat.com> - 246-1
- Add pyproject-srpm-macros to the default buildroot
* Tue Jan 17 2023 Davide Cavalca <dcavalca@fedoraproject.org> - 245-1
- Do not include frame pointers on ppc64le for now
Fixes: rhbz#2161595
* Mon Jan 16 2023 Tom Stellard <tstellar@redhat.com> - 244-1
- Make -flto=thin the default lto flag for clang

5
rpmrc
View File

@ -7,10 +7,7 @@ optflags: i686 %{__global_compiler_flags} -m32 -march=i686 -mtune=generic -msse2
optflags: athlon %{__global_compiler_flags} -m32 -march=athlon -fasynchronous-unwind-tables -fstack-clash-protection
optflags: x86_64 %{__global_compiler_flags} -m64 %{__cflags_arch_x86_64} -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection %{_frame_pointers_cflags} %{_frame_pointers_cflags_x86_64}
optflags: ppc64le %{__global_compiler_flags} -m64 %{__cflags_arch_ppc64le} -fasynchronous-unwind-tables -fstack-clash-protection %{_frame_pointers_cflags}
# TODO: Remove armv7hl once f36 goes EOL.
optflags: armv7hl %{__global_compiler_flags} -march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard %{_frame_pointers_cflags}
optflags: ppc64le %{__global_compiler_flags} -m64 %{__cflags_arch_ppc64le} -fasynchronous-unwind-tables -fstack-clash-protection
optflags: s390x %{__global_compiler_flags} -m64 %{__cflags_arch_s390x} -fasynchronous-unwind-tables -fstack-clash-protection

View File

@ -4,6 +4,7 @@ summary: >
require:
- annobin-annocheck
- dnf5-plugins
- gcc
- gcc-c++
- make

View File

@ -2,6 +2,6 @@
set -ex
dnf -y build-dep test.spec
dnf -y builddep test.spec
rpmbuild --define '_sourcedir .' --define '_builddir .' -bi test.spec
rpmbuild --without auto_set_build_flags --define '_sourcedir .' --define '_builddir .' -bi test.spec

View File

@ -2,6 +2,7 @@ Summary: Test that the brp-llvm-compile-lto-elf script is working correctly
require:
- dnf-plugins-core
- dnf5-plugins
- redhat-rpm-config
- rpm-build

View File

@ -5,7 +5,7 @@ set -ex
lib_dir=brp-llvm-compile-lto-elf-test-lib
lib_spec=$lib_dir/brp-llvm-compile-lto-elf-test-lib.spec
dnf -y build-dep $lib_spec
dnf -y builddep $lib_spec
rpmbuild --define "_sourcedir ." --define "_builddir ./$lib_dir" --define "_rpmdir ." -bb $lib_spec
dnf -y install ./`rpm --eval '%{_arch}'`/*.rpm
@ -13,5 +13,5 @@ dnf -y install ./`rpm --eval '%{_arch}'`/*.rpm
test_dir=brp-llvm-compile-lto-elf-test
test_spec=$test_dir/brp-llvm-compile-lto-elf-test.spec
dnf -y build-dep $test_spec
dnf -y builddep $test_spec
rpmbuild --define "_sourcedir ." --define "_builddir ./$test_dir" -bi $test_spec

View File

@ -2,5 +2,6 @@ summary: self-build test
require:
- dnf-plugins-core
- dnf5-plugins
- rpm-build
test: ./runtest.sh

View File

@ -3,5 +3,5 @@
set -e
spec=$TMT_TREE/redhat-rpm-config.spec
dnf -y build-dep $spec
dnf -y builddep $spec
rpmbuild --define "_sourcedir $TMT_TREE" -ba $spec

View File

@ -0,0 +1,8 @@
summary: >
Check that the %_distro_extra_* macros allow users to append new flags to the
list of default flags.
require:
- rpm
test: ./runtest.sh

View File

@ -0,0 +1,6 @@
set -ex
rpm -D '%_distro_extra_cflags -Wall' -E %{build_cflags} | grep -e '\-Wall$'
rpm -D '%_distro_extra_cxxflags -Wall' -E %{build_cxxflags} | grep -e '\-Wall$'
rpm -D '%_distro_extra_ldflags -Wall' -E %{build_ldflags} | grep -e '\-Wall$'
rpm -D '%_distro_extra_fflags -Wall' -E %{build_fflags} | grep -e '\-Wall$'

View File

@ -23,7 +23,7 @@ validate() {
fi
}
for arch in aarch64 armv7hl x86_64 ppc64le riscv64; do
for arch in aarch64 x86_64 riscv64; do
case "$arch" in
x86_64|aarch64)
flags='-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer'
@ -47,7 +47,7 @@ for arch in aarch64 armv7hl x86_64 ppc64le riscv64; do
done
flags='-fno-omit-frame-pointer'
for arch in i386 i486 i586 i686 athlon s390x; do
for arch in i386 i486 i586 i686 athlon ppc64le s390x; do
rpmeval --target="${arch}-linux" --define='_include_frame_pointers 1' | grep -qv -- "$flags"
validate "[${arch}] Test that the flags are not included if the macro is defined"

7
tests/rustflags/main.fmf Normal file
View File

@ -0,0 +1,7 @@
summary: Test that conditional support for RUSTFLAGS works
require:
- redhat-rpm-config
- rpm
- rust-packaging
test: ./runtest.sh

22
tests/rustflags/runtest.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/bash
set -e -u -o pipefail
# Allow for local testing
rargs=()
if [ -n "${MACROS_PATH:-}" ]; then
default_macros_path="$(rpm --showrc | grep 'Macro path' | awk -F ': ' '{print $2}')"
rargs+=("--macros" "${default_macros_path}:${MACROS_PATH}")
fi
build_rustflags="$(rpm -E '%{build_rustflags}')"
# For good measure
[ "${build_rustflags}" != "%{build_rustflags}" ]
#
flags="$(rpm "${rargs[@]}" -E '%set_build_flags')"
echo 'Check that RUSTFLAGS is set after evaluating %set_build_flags'
(
eval "${flags}"
# set -u will make this fail if $RUSTFLAGS isn't defined
[ "${RUSTFLAGS}" = "${build_rustflags}" ]
)