#201 Backport recent fixes to f36
Merged 2 years ago by tstellar. Opened 2 years ago by tstellar.
rpms/ tstellar/redhat-rpm-config f36-backport  into  f36

file added
+1
@@ -0,0 +1,1 @@ 

+ 1

file modified
+7 -7
@@ -64,15 +64,17 @@ 

  # the corresponding variable names.

  %build_fflags %{optflags} -I%{_fmoddir}

  

+ # 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

+ 

  # 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.

- # 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.

- %build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_lto_cflags}" : "" ] %{_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}

  

  # Expands to shell code to set the compiler/linker environment

  # variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have
@@ -354,9 +356,7 @@ 

  # If they are needed then add "%define _legacy_common_support 1" to the spec file.

  %_legacy_options	%{?_legacy_common_support: -fcommon}

  

- %_clang_extra_flags --start-no-unused-arguments -fno-openmp-implicit-rpath --end-no-unused-arguments

- 

- %__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags} %{_annotation_cflags} %{_legacy_options} 	%[ "%{toolchain}" == "clang" ? "%{_clang_extra_flags}" : "%{nil}" ]

+ %__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags} %{_annotation_cflags} %{_legacy_options}

  

  # Automatically trim changelog entries after 2 years

  %_changelog_trimage	%{expr:2*365*24*60*60}

file modified
+8 -1
@@ -6,7 +6,7 @@ 

  

  Summary: Red Hat specific rpm configuration files

  Name: redhat-rpm-config

- Version: 219

+ Version: 220

  Release: 1%{?dist}

  # No version specified.

  License: GPL+
@@ -217,6 +217,13 @@ 

  %doc buildflags.md

  

  %changelog

+ * Fri May 27 2022 Tom Stellard <tstellar@redhat.com> - 220-1

+ - Move -fno-openmp-implicit-rpath option from CFLAGS to LDFLAGS

+ 

+ * Tue May 17 2022 Miro Hrončok <mhroncok@redhat.com> - 219-2

+ - Remove a tab character from the definition of %%__global_compiler_flags

+ - Fixes: rhbz#2083296

+ 

  * Wed May 18 2022 Jason L Tibbitts III <j@tib.bs> - 219-1

  - Add java_arches macro.

  

@@ -0,0 +1,11 @@ 

+ summary: >

+   Check the that the environment variables for build flags are automatically set

+   https://fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck

+ 

+ require:

+   - annobin-annocheck

+   - gcc

+   - gcc-c++

+   - make

+ 

+ test: ./runtest.sh

@@ -0,0 +1,16 @@ 

+ summary: Tests

+ discover:

+   - name: redhat-rpm-config-tests

+     how: fmf

+   - name: gcc-fedora-flags

+     how: fmf

+     url: https://src.fedoraproject.org/rpms/gcc.git

+     ref: rawhide

+     test: fedora-flags

+   - name: clang-fedora-flags

+     how: fmf

+     url: https://src.fedoraproject.org/rpms/clang.git

+     ref: rawhide

+     test: fedora-flags

+ execute:

+   how: tmt

@@ -0,0 +1,6 @@ 

+ summary: self-build test

+ 

+ require:

+   - dnf-plugins-core

+   - rpm-build

+ test: ./runtest.sh

@@ -0,0 +1,7 @@ 

+ #!/bin/bash

+ 

+ set -e

+ 

+ spec=$TMT_TREE/redhat-rpm-config.spec

+ dnf -y build-dep $spec

+ rpmbuild --define "_sourcedir $TMT_TREE" -ba $spec

@@ -0,0 +1,5 @@ 

+ summary: Test to ensure there aren't extraneous characters in build flags

+ require:

+   - redhat-rpm-config

+ test: ./runtest.sh

+ 

@@ -0,0 +1,7 @@ 

+ #!/bin/bash

+ 

+ set -ex

+ 

+ for f in %{build_cflags} %{build_cxxflags} %{build_fflags} %{build_ldflags}; do

+   rpm --eval "$f" | grep -vP '\t'

+ done

@@ -1,5 +0,0 @@ 

- #include <stdio.h>

- 

- void hello() {

-   printf("Hello World\n");

- }

@@ -1,5 +0,0 @@ 

- #include <iostream>

- 

- void hello() {

-   std::cout << "Hello World\n";

- }

@@ -1,6 +0,0 @@ 

- void hello();

- 

- int main(int argc, char **argv) {

-   hello();

-   return 0;

- }

@@ -1,6 +0,0 @@ 

- void hello();

- 

- int main(int argc, char **argv) {

-   hello();

-   return 0;

- }

@@ -1,29 +0,0 @@ 

- #!/bin/bash

- 

- set -ex

- 

- default_cflags=$(rpm -E '%{build_cflags}')

- default_cxxflags=$(rpm -E '%{build_cxxflags}')

- default_ldflags=$(rpm -E '%{build_ldflags}')

- 

- cflags=$(rpm -D '%toolchain gcc' -E '%{build_cflags}')

- cxxflags=$(rpm -D '%toolchain gcc' -E '%{build_cxxflags}')

- ldflags=$(rpm -D '%toolchain gcc' -E '%{build_ldflags}')

- 

- test "$default_cflags" = "$cflags"

- test "$default_cxxflags" = "$cxxflags"

- test "$default_ldflags" = "$ldflags"

- 

- gcc $cflags -o hello.o -c hello.c

- annocheck hello.o

- gcc $cflags -o main.o -c main.c

- gcc $ldflags -o hello main.o hello.o

- annocheck hello

- ./hello | grep "Hello World"

- 

- g++ $cxxflags -o hello-cpp.o -c hello.cpp

- annocheck hello-cpp.o

- g++ $cxxflags -o main-cpp.o -c main.cpp

- g++ $ldflags -o hello-cpp main-cpp.o hello-cpp.o

- annocheck hello-cpp

- ./hello-cpp | grep "Hello World"

@@ -0,0 +1,8 @@ 

+ summary: Test that we don't accidently introduce any new dependencies.

+ 

+ require:

+   - diffutils

+   - grep

+   - redhat-rpm-config

+   - rpm

+ test: ./runtest.sh

file removed
-52
@@ -1,52 +0,0 @@ 

- ---

- - hosts: localhost

-   tags:

-     - classic

-   tasks:

-     - dnf:

-         name: "*"

-         state: latest

- 

- - hosts: localhost

-   tags:

-   - classic

-   pre_tasks:

-   - import_role:

-       name: standard-test-source

-     vars:

-       fetch_only: True

- 

-   roles:

-   - role: standard-test-basic

-     tags:

-       - classic

-     required_packages:

-       - rpm

-       # build-self

-       - dnf

-       - rpm-build

-       # clang/fedora-flags

-       - clang

-       #gcc-fedora-flags

-       - gcc

-       - gcc-c++

-       - annobin-annocheck

-       #auto-set-build-flags

-       - gcc

-       - gcc-c++

-       - annobin-annocheck

-       - make

-       # no-new-dependency

-       - diffutils

-       - grep

-     repositories:

-       - repo: https://src.fedoraproject.org/tests/clang.git

-         dest: clang

-     tests:

-       - build-self:

-           dir: .

-           run: "dnf -y build-dep {{ tenv_workdir }}/redhat-rpm-config.spec && rpmbuild --define '_sourcedir {{ tenv_workdir }}' -ba {{ tenv_workdir }}/redhat-rpm-config.spec"

-       - clang/fedora-flags

-       - gcc-fedora-flags

-       - no-new-dependency

-       - auto-set-build-flags

This backports fixes and a test for https://bugzilla.redhat.com/show_bug.cgi?id=2083296 as well as a fix for how we pass the clang option -fno-openmp-implicit-rpath.

Build succeeded.

My commit Remove a tab character from the definition of %__global_compiler_flags bumped the release instead of version by mistake. Maybe we should bump the version here instead?

Disregard my previous comment. The version is bumped later, so everything is OK.

I guess this looks good, feel free to ship it.

Pull-Request has been merged by tstellar

2 years ago