diff --git a/buildflags.md b/buildflags.md index d20c918..db80dcd 100644 --- a/buildflags.md +++ b/buildflags.md @@ -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. diff --git a/config.guess b/config.guess index 1817bdc..354a8cc 100644 --- a/config.guess +++ b/config.guess @@ -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 GUESS=i586-unisys-sysv4 ;; diff --git a/config.sub b/config.sub index dba16e8..f6ede1d 100644 --- a/config.sub +++ b/config.sub @@ -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 ." 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 diff --git a/macros b/macros index edade66..1d571c5 100644 --- a/macros +++ b/macros @@ -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 @@ -375,12 +384,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 +402,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} diff --git a/macros.gap-srpm b/macros.gap-srpm new file mode 100644 index 0000000..2221073 --- /dev/null +++ b/macros.gap-srpm @@ -0,0 +1,2 @@ +# Arches that GAP runs on +%gap_arches aarch64 ppc64le s390x x86_64 diff --git a/macros.java-srpm b/macros.java-srpm index 4d35a9f..a32a7fd 100644 --- a/macros.java-srpm +++ b/macros.java-srpm @@ -1,2 +1,2 @@ # Arches that OpenJDK and dependent packages run on -%java_arches aarch64 ppc64le s390x x86_64 riscv64 +%java_arches aarch64 ppc64le s390x x86_64 diff --git a/macros.nodejs-srpm b/macros.nodejs-srpm index cb0f724..faf03a7 100644 --- a/macros.nodejs-srpm +++ b/macros.nodejs-srpm @@ -4,4 +4,4 @@ # those arches. Support for POWER and aarch64 arrived in nodejs v4. Support # for s390x arrived in nodejs v6 -%nodejs_arches %{ix86} x86_64 %{arm} aarch64 %{power64} s390x riscv64 +%nodejs_arches %{ix86} x86_64 %{arm} aarch64 %{power64} s390x diff --git a/redhat-hardened-cc1 b/redhat-hardened-cc1 index fc54bcb..a369517 100644 --- a/redhat-hardened-cc1 +++ b/redhat-hardened-cc1 @@ -1,2 +1,5 @@ *cc1_options: + %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}} + +*cpp_options: ++ %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}} diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index b671490..0ab5f91 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -4,12 +4,12 @@ # 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 Version: %{baserelease} -Release: 1.0.riscv64%{?dist} +Release: 1%{?dist} # No version specified. License: GPL+ URL: https://src.fedoraproject.org/rpms/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,60 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %doc buildflags.md %changelog -* Tue Jan 17 2023 David Abdurachmanov - 244-1.0.riscv64 -- Add riscv64 to nodejs and java arches +* Fri Jul 7 2023 Florian Weimer - 261-1 +- Fix warnings that appear during the build of the llvm package + +* Wed Jul 5 2023 Florian Weimer - 260-1 +- Implement the %%build_type_safety_c macro (#2218019) + +* Wed Jul 5 2023 Florian Weimer - 259-1 +- Filter out C, C++ build flags from Fortran build flags (#2177253) + +* Wed Jul 5 2023 Florian Weimer - 258-1 +- Enable PIC mode for assembler files (#2167430) + +* Wed Jul 05 2023 Frederic Berat - 257-1 +- update config.{guess,sub} to gnuconfig git HEAD + +* Sat Jun 17 2023 Tom Stellard - 256-1 +- Remove -fno-openmp-implicit-rpath from clang ldflags + +* Fri Jun 16 2023 Lumír Balhar - 255-1 +- Add qt6-srpm-macros + +* Thu Mar 9 2023 Florian Weimer - 254-1 +- Switch ELN to x86-64-v3 + +* Tue Feb 28 2023 Maxwell G - 253-1 +- Include RUSTFLAGS in %%set_build_flags +- Fixes: rhbz#2167183 + +* Tue Feb 28 2023 Tom Stellard - 252-1 +- Rename _pkg_extra_* macros to _distro_extra_* + +* Thu Feb 23 2023 Miro Hrončok - 251-1 +- Drop the requirement of orphaned nim-srpm-macros +- No Fedora package uses the %%nim_arches macro + +* Tue Feb 14 2023 Frederic Berat - 250-1 +- update config.{guess,sub} to gnuconfig git HEAD + +* Thu Feb 09 2023 Jerry James - 249-1 +- Add macros.gap-srpm + +* Tue Feb 07 2023 Tom Stellard - 248-1 +- Add %%pkg_extra_* macros + +* Mon Feb 06 2023 Nick Clifton - 247-1 +- Fix triggers for the installation and removal of gcc-plugin-annobin. + Fixes: rhbz#2124562 + +* Tue Jan 17 2023 Miro Hrončok - 246-1 +- Add pyproject-srpm-macros to the default buildroot + +* Tue Jan 17 2023 Davide Cavalca - 245-1 +- Do not include frame pointers on ppc64le for now + Fixes: rhbz#2161595 * Mon Jan 16 2023 Tom Stellard - 244-1 - Make -flto=thin the default lto flag for clang diff --git a/rpmrc b/rpmrc index 9ccea43..a12e122 100644 --- a/rpmrc +++ b/rpmrc @@ -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 diff --git a/tests/auto-set-build-flags/main.fmf b/tests/auto-set-build-flags/main.fmf index 6777d59..aeb1b86 100644 --- a/tests/auto-set-build-flags/main.fmf +++ b/tests/auto-set-build-flags/main.fmf @@ -4,6 +4,7 @@ summary: > require: - annobin-annocheck + - dnf5-plugins - gcc - gcc-c++ - make diff --git a/tests/auto-set-build-flags/runtest.sh b/tests/auto-set-build-flags/runtest.sh index 8d4a8ed..ca0279d 100755 --- a/tests/auto-set-build-flags/runtest.sh +++ b/tests/auto-set-build-flags/runtest.sh @@ -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 diff --git a/tests/brp-llvm-compile-lto-elf/main.fmf b/tests/brp-llvm-compile-lto-elf/main.fmf index ada5230..19e8d13 100644 --- a/tests/brp-llvm-compile-lto-elf/main.fmf +++ b/tests/brp-llvm-compile-lto-elf/main.fmf @@ -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 diff --git a/tests/brp-llvm-compile-lto-elf/runtest.sh b/tests/brp-llvm-compile-lto-elf/runtest.sh index 1690d65..d152bda 100755 --- a/tests/brp-llvm-compile-lto-elf/runtest.sh +++ b/tests/brp-llvm-compile-lto-elf/runtest.sh @@ -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 diff --git a/tests/build-self/main.fmf b/tests/build-self/main.fmf index 0d84895..12e1e5c 100644 --- a/tests/build-self/main.fmf +++ b/tests/build-self/main.fmf @@ -2,5 +2,6 @@ summary: self-build test require: - dnf-plugins-core + - dnf5-plugins - rpm-build test: ./runtest.sh diff --git a/tests/build-self/runtest.sh b/tests/build-self/runtest.sh index 68ab7cc..0b7ef72 100755 --- a/tests/build-self/runtest.sh +++ b/tests/build-self/runtest.sh @@ -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 diff --git a/tests/distro-extra-flags/main.fmf b/tests/distro-extra-flags/main.fmf new file mode 100644 index 0000000..496e8c7 --- /dev/null +++ b/tests/distro-extra-flags/main.fmf @@ -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 diff --git a/tests/distro-extra-flags/runtest.sh b/tests/distro-extra-flags/runtest.sh new file mode 100755 index 0000000..09105b0 --- /dev/null +++ b/tests/distro-extra-flags/runtest.sh @@ -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$' diff --git a/tests/include-frame-pointers/runtest.sh b/tests/include-frame-pointers/runtest.sh index c00b31a..bd5bf3a 100755 --- a/tests/include-frame-pointers/runtest.sh +++ b/tests/include-frame-pointers/runtest.sh @@ -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" diff --git a/tests/rustflags/main.fmf b/tests/rustflags/main.fmf new file mode 100644 index 0000000..02226e2 --- /dev/null +++ b/tests/rustflags/main.fmf @@ -0,0 +1,7 @@ +summary: Test that conditional support for RUSTFLAGS works + +require: + - redhat-rpm-config + - rpm + - rust-packaging +test: ./runtest.sh diff --git a/tests/rustflags/runtest.sh b/tests/rustflags/runtest.sh new file mode 100755 index 0000000..b6a3be0 --- /dev/null +++ b/tests/rustflags/runtest.sh @@ -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}" ] +)