Revert "Add llvm-lto-elf-check script" to avoid a dependency on Python

This reverts commit ac2ca1dbba.
This commit is contained in:
Miro Hrončok 2021-11-16 22:28:14 +01:00
parent f895eeaa56
commit 2f1ae3aa01
4 changed files with 7 additions and 52 deletions

View File

@ -1,10 +1,5 @@
#!/usr/bin/bash -eu #!/usr/bin/bash -eu
# first argument is the path to llvm-lto-elf-check
MATCH_LTO_SCRIPT=$1
shift
# remaining args are cflags
CLANG_FLAGS=$@ CLANG_FLAGS=$@
if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then
@ -20,7 +15,7 @@ check_convert_bitcode () {
if [[ "${file_type}" == *"LLVM IR bitcode"* ]]; then if [[ "${file_type}" == *"LLVM IR bitcode"* ]]; then
# check for an indication that the bitcode was # check for an indication that the bitcode was
# compiled with -flto # compiled with -flto
llvm-bcanalyzer -dump ${file_name} | ${MATCH_LTO_SCRIPT} 2>&1 > /dev/null llvm-bcanalyzer -dump ${file_name} | grep -xP '.*\-flto((?!-fno-lto).)*' 2>&1 > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Compiling LLVM bitcode file ${file_name}." echo "Compiling LLVM bitcode file ${file_name}."
# create path to file in temp dir # create path to file in temp dir

View File

@ -1,39 +0,0 @@
#!/usr/bin/python3
# Check an llvm bcanalyzer dump for -flto
# This script implements the following command in python
# to avoid PCRE backtrace limits in grep.
# grep -xP '.*\-flto((?!-fno-lto).)*' <input file>
import re
import sys
def open_input_file():
if len(sys.argv) > 1:
f = open(sys.argv[1], "r")
else:
f = sys.stdin
if not f:
raise Exception("Could not open input file")
return f
def match_lto(input_lines):
match_found = False
for line in input_lines:
match = re.match(r"^.*\-flto((?!-fno-lto).)*$", line)
if match:
match_found = True
print(f"{match.group(0)}")
return match_found
def main():
input_file = open_input_file()
input_lines = input_file.readlines()
if input_file != sys.stdin:
input_file.close()
if match_lto(input_lines):
sys.exit(0)
sys.exit(1)
main()

3
macros
View File

@ -234,8 +234,7 @@ print(result)
# __brp_mangle_shebangs_exclude_from_file - file from which to get files to ignore # __brp_mangle_shebangs_exclude_from_file - file from which to get files to ignore
%__brp_mangle_shebangs /usr/lib/rpm/redhat/brp-mangle-shebangs %{?__brp_mangle_shebangs_exclude:--shebangs "%{?__brp_mangle_shebangs_exclude}"} %{?__brp_mangle_shebangs_exclude_file:--shebangs-from "%{__brp_mangle_shebangs_exclude_file}"} %{?__brp_mangle_shebangs_exclude_from:--files "%{?__brp_mangle_shebangs_exclude_from}"} %{?__brp_mangle_shebangs_exclude_from_file:--files-from "%{__brp_mangle_shebangs_exclude_from_file}"} %__brp_mangle_shebangs /usr/lib/rpm/redhat/brp-mangle-shebangs %{?__brp_mangle_shebangs_exclude:--shebangs "%{?__brp_mangle_shebangs_exclude}"} %{?__brp_mangle_shebangs_exclude_file:--shebangs-from "%{__brp_mangle_shebangs_exclude_file}"} %{?__brp_mangle_shebangs_exclude_from:--files "%{?__brp_mangle_shebangs_exclude_from}"} %{?__brp_mangle_shebangs_exclude_from_file:--files-from "%{__brp_mangle_shebangs_exclude_from_file}"}
%__llvm_lto_elf_check /usr/lib/rpm/redhat/llvm-lto-elf-check %__brp_llvm_compile_lto_elf /usr/lib/rpm/redhat/brp-llvm-compile-lto-elf %{build_cflags} %{build_ldflags}
%__brp_llvm_compile_lto_elf /usr/lib/rpm/redhat/brp-llvm-compile-lto-elf %{__llvm_lto_elf_check} %{build_cflags} %{build_ldflags}
# note: %%__os_install_post_python is defined in python-srpm-macros and contains several policies # note: %%__os_install_post_python is defined in python-srpm-macros and contains several policies
# redhat-rpm-config maintainers, don't remove it from %%__os_install_post unless coordinating the change with Python maintainers # redhat-rpm-config maintainers, don't remove it from %%__os_install_post unless coordinating the change with Python maintainers

View File

@ -6,7 +6,7 @@
Summary: Red Hat specific rpm configuration files Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config Name: redhat-rpm-config
Version: 203 Version: 204
Release: 1%{?dist} Release: 1%{?dist}
# No version specified. # No version specified.
License: GPL+ License: GPL+
@ -67,7 +67,6 @@ Source401: rpmsort
Source402: symset-table Source402: symset-table
Source403: kmodtool Source403: kmodtool
Source404: gpgverify Source404: gpgverify
Source405: llvm-lto-elf-check
# 2016-10-02 snapshots from http://git.savannah.gnu.org/gitweb/?p=config.git # 2016-10-02 snapshots from http://git.savannah.gnu.org/gitweb/?p=config.git
Source500: config.guess Source500: config.guess
@ -177,8 +176,6 @@ mkdir -p %{buildroot}%{_rpmluadir}/fedora/{rpm,srpm}
install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua
install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
install -p -m 755 -t %{buildroot}%{rrcdir} llvm-lto-elf-check
%files %files
%dir %{rrcdir} %dir %{rrcdir}
%{rrcdir}/macros %{rrcdir}/macros
@ -192,7 +189,6 @@ install -p -m 755 -t %{buildroot}%{rrcdir} llvm-lto-elf-check
%{rrcdir}/find-provides %{rrcdir}/find-provides
%{rrcdir}/find-requires %{rrcdir}/find-requires
%{rrcdir}/brp-ldconfig %{rrcdir}/brp-ldconfig
%{rrcdir}/llvm-lto-elf-check
%{_fileattrsdir}/*.attr %{_fileattrsdir}/*.attr
%{_rpmconfigdir}/macros.d/macros.*-srpm %{_rpmconfigdir}/macros.d/macros.*-srpm
%{_rpmconfigdir}/macros.d/macros.build-constraints %{_rpmconfigdir}/macros.d/macros.build-constraints
@ -221,6 +217,10 @@ install -p -m 755 -t %{buildroot}%{rrcdir} llvm-lto-elf-check
%{_rpmconfigdir}/macros.d/macros.kmp %{_rpmconfigdir}/macros.d/macros.kmp
%changelog %changelog
* Tue Nov 16 2021 Miro Hrončok <mhroncok@redhat.com> - 204-1
- Don't pull in Python to all buildroots
- Remove llvm-lto-elf-check script
* Tue Nov 09 2021 Michal Domonkos <mdomonko@redhat.com> - 203-1 * Tue Nov 09 2021 Michal Domonkos <mdomonko@redhat.com> - 203-1
- Drop {fpc,gnat,nim}-srpm-macros dependencies on RHEL - Drop {fpc,gnat,nim}-srpm-macros dependencies on RHEL