Fix passing of CFLAGS to brp-llvm-compile-lto-elf

This was accidentally broken by d9c7e4eef8.
This commit is contained in:
Tom Stellard 2022-05-23 16:46:48 -07:00
parent 9a1b602bdb
commit f77dcdec18
9 changed files with 104 additions and 3 deletions

View File

@ -12,6 +12,9 @@ check_convert_bitcode () {
local file_name=$(realpath ${1})
local file_type=$(file ${file_name})
shift
CLANG_FLAGS="$@"
if [[ "${file_type}" == *"LLVM IR bitcode"* ]]; then
# check for an indication that the bitcode was
# compiled with -flto
@ -29,7 +32,7 @@ check_convert_bitcode () {
pushd ${archive_stage}
ar x ${archive}
for archived_file in $(find -not -type d); do
check_convert_bitcode ${archived_file}
check_convert_bitcode ${archived_file} ${CLANG_FLAGS}
echo "Repacking ${archived_file} into ${archive}."
ar r ${archive} ${archived_file}
done
@ -40,4 +43,4 @@ check_convert_bitcode () {
echo "Checking for LLVM bitcode artifacts"
export -f check_convert_bitcode
find "$RPM_BUILD_ROOT" -type f -name "*.[ao]" -print0 | \
xargs -0 -n1 -P$NCPUS sh -c "check_convert_bitcode \$@" ARG0
xargs -0 -n1 -P$NCPUS sh -c "check_convert_bitcode \$@ $CLANG_FLAGS" ARG0

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 223
%global baserelease 224
Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config
@ -219,6 +219,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
%doc buildflags.md
%changelog
* Tue Jun 14 2022 Tom Stellard <tstellar@redhat.com> - 224-1
- Fix passing of CFLAGS to brp-llvm-compile-lto-elf
* Fri May 27 2022 Tom Stellard <tstellar@redhat.com> - 223-1
- Move -fno-openmp-implicit-rpath option from CFLAGS to LDFLAGS

View File

@ -0,0 +1,5 @@
#include <stdio.h>
void hello(void) {
printf("Hello, world!\n");
}

View File

@ -0,0 +1,34 @@
Name: brp-llvm-compile-lto-elf-test-lib
Version: 1
Release: 1
Summary: Library package for testing brp-llvm-compile-lto-elf
License: MIT
BuildRequires: clang binutils
Source0: %{name}.c
Source1: %{name}.h
# FIXME: I'm not sure why this doesn't work
%undefine _package_note_file
%global toolchain clang
%description
%{summary}
%build
clang ${CFLAGS} -c %{SOURCE0} -o lib.o
ar cr %{name}.a lib.o
ranlib %{name}.a
%install
mkdir -p %{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_includedir}
%{__install} -p -m 644 -t %{buildroot}%{_libdir} %{name}.a
%{__install} -p -m 644 -t %{buildroot}%{_includedir} %{SOURCE1}
%files
%{_libdir}/%{name}.a
%{_includedir}/%{name}.h

View File

@ -0,0 +1,6 @@
#include <brp-llvm-compile-lto-elf-test-lib.h>
int main(int argc, char **argv) {
hello();
return 0;
}

View File

@ -0,0 +1,24 @@
Name: brp-llvm-compile-lto-elf-test
Version: 1
Release: 1
Summary: Library package for testing brp-llvm-compile-lto-elf
License: MIT
BuildRequires: gcc
BuildRequires: brp-llvm-compile-lto-elf-test-lib
Source0: %{name}.c
# FIXME: I'm not sure why this doesn't work
%undefine _package_note_file
%description
%{summary}
%build
gcc ${CFLAGS} -c %{SOURCE0} -o %{name}.o
gcc ${LDFLAGS} %{name}.o %{_libdir}/%{name}-lib.a -o %{name}
%check
./%{name} | grep "Hello, world!"

View File

@ -0,0 +1,8 @@
Summary: Test that the brp-llvm-compile-lto-elf script is working correctly
require:
- dnf-plugins-core
- redhat-rpm-config
- rpm-build
test: ./runtest.sh

View File

@ -0,0 +1,17 @@
#!/bin/bash
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
rpmbuild --define "_sourcedir ." --define "_builddir ./$lib_dir" --define "_rpmdir ." -bb $lib_spec
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
rpmbuild --define "_sourcedir ." --define "_builddir ./$test_dir" -bi $test_spec