diff --git a/brp-mangle-shebangs b/brp-mangle-shebangs index 6d65a82..4fa8daa 100755 --- a/brp-mangle-shebangs +++ b/brp-mangle-shebangs @@ -121,6 +121,10 @@ while IFS= read -r -d $'\0' f; do # /whatsoever/env foo → /whatsoever/foo shebang=$(echo "$shebang" | sed -r -e 's@^(.+/)env (.+)$@\1\2@') + # If the shebang now starts with /bin, change it to /usr/bin + # https://bugzilla.redhat.com/show_bug.cgi?id=1581757 + shebang=$(echo "$shebang" | sed -r -e 's@^/bin/@/usr/bin/@') + # Replace ambiguous python with python2 py_shebang=$(echo "$shebang" | sed -r -e 's@/usr/bin/python(\s|$)@/usr/bin/python2\1@') diff --git a/buildflags.md b/buildflags.md index b279bbb..06b41e6 100644 --- a/buildflags.md +++ b/buildflags.md @@ -70,7 +70,7 @@ For other considerations involving shared objects, see: It is possible to set RPM macros to change some aspects of the compiler flags. Changing these flags should be used as a last -recourse if other workarunds are not available. +recourse if other workarounds are not available. ### Lazy binding @@ -276,10 +276,16 @@ tuning in the `gcc` package. These settings are: with other ARMv7-A implementations). `-mabi=aapcs-linux` switches to the AAPCS ABI for GNU/Linux. * **i686**: `-march=i686` is used to select a minmum support CPU level - of i686 (corresponding to the Pentium Pro). `-mtune=generic` activates - tuning for a current blend of CPUs (under the assumption that most - users of i686 packages obtain them through an x86_64 installation - on current hardware). + of i686 (corresponding to the Pentium Pro). SSE2 support is + enabled with `-msse2` (so only CPUs with SSE2 support can run the + compiled code; SSE2 was introduced first with the Pentium 4). + `-mtune=generic` activates tuning for a current blend of CPUs + (under the assumption that most users of i686 packages obtain them + through an x86_64 installation on current hardware). + `-mfpmath=sse` instructs GCC to use the SSE2 unit for floating + point math to avoid excess precision issues. `-mstackrealign` + avoids relying on the stack alignment guaranteed by the current + version of the i386 ABI. * **ppc64le**: `-mcpu=power8 -mtune=power8` selects a minimum supported CPU level of POWER8 (the first CPU with ppc64le support) and tunes for POWER8. diff --git a/find-provides.ksyms b/find-provides.ksyms index 4616710..0526cd7 100755 --- a/find-provides.ksyms +++ b/find-provides.ksyms @@ -1,9 +1,24 @@ -#! /bin/sh +#! /bin/bash IFS=$'\n' for module in $(grep -E '/lib/modules/.+\.ko$'); do - nm $module \ - | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):ksym(\2) = \1:p' -done \ -| sort -u + if [[ -n $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then + nm $module \ + | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ + | awk --non-decimal-data '{printf("ksym(%s) = 0x%08x\n", $2, $1)}' \ + | LC_ALL=C sort -u + else + ELFRODATA=$(readelf -R .rodata $module | awk '/0x/{printf $2$3$4$5}') + if [[ -n $(readelf -h $module | grep "little endian") ]]; then + RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g') + else + RODATA=$ELFRODATA + fi + for sym in $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do + echo $sym $RODATA + done \ + | awk --non-decimal-data '{printf("ksym(%s) = 0x%08s\n", $2, substr($3,($1*2)+1,8))}' \ + | LC_ALL=C sort -u + fi +done diff --git a/find-requires.ksyms b/find-requires.ksyms index 73525b7..b11c7bb 100755 --- a/find-requires.ksyms +++ b/find-requires.ksyms @@ -2,19 +2,47 @@ IFS=$'\n' +# Extract all of the symbols provided by this module. all_provides() { - nm "$@" \ - | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):\1\t\2:p' \ - | sort -k2 -u + if [[ -n $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then + nm "$@" \ + | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \ + | awk --non-decimal-data '{printf("0x%08x\t%s\n", $1, $2)}' \ + | LC_ALL=C sort -k2,2 -u + else + ELFRODATA=$(readelf -R .rodata "$@" | awk '/0x/{printf $2$3$4$5}') + if [[ -n $(readelf -h "$@" | grep "little endian") ]]; then + RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g') + else + RODATA=$ELFRODATA + fi + for sym in $(nm "$@" | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do + echo $sym $RODATA + done \ + | awk --non-decimal-data '{printf("0x%08s\t%s\n", substr($3,($1*2)+1,8), $2)}' \ + | LC_ALL=C sort -k2,2 -u + fi } +# Extract all of the requirements of this module. all_requires() { for module in "$@"; do set -- $(/sbin/modinfo -F vermagic "$module" | sed -e 's: .*::' -e q) /sbin/modprobe --dump-modversions "$module" \ - | sed -r -e 's:^0x0*::' -e 's:$:\t'"$1"':' + | awk --non-decimal-data ' + BEGIN { FS = "\t" ; OFS = "\t" } + {printf("0x%08x\t%s\n", $1, $2)}' \ + | sed -r -e 's:$:\t'"$1"':' done \ - | sort -k2 -u + | LC_ALL=C sort -k2,2 -u +} + +# Filter out requirements fulfilled by the module itself. +mod_requires() { + LC_ALL=C join -t $'\t' -j 2 -v 1 \ + <(all_requires "$@") \ + <(all_provides "$@") \ + | LC_ALL=C sort -k1,1 -u } if ! [ -e /sbin/modinfo -a -e /sbin/modprobe ]; then @@ -24,25 +52,23 @@ fi modules=($(grep -E '/lib/modules/.+\.ko$')) if [ ${#modules[@]} -gt 0 ]; then - symset_table=$(mktemp -t ${0##*/}.XXXXX) - /usr/lib/rpm/redhat/symset-table | sort > $symset_table + kernel=$(/sbin/modinfo -F vermagic "${modules[0]}" | sed -e 's: .*::' -e q) - join -t $'\t' -j 1 -a 2 $symset_table <( - # Filter out requirements that we fulfill ourself. - join -t $'\t' -j 2 -v 1 \ - <(all_requires "${modules[@]}") \ - <(all_provides "${modules[@]}") \ - | awk ' + # get all that kernel provides + symvers=$(mktemp -t ${0##*/}.XXXXX) + + cat /usr/src/kernels/$kernel/Module.symvers | awk ' BEGIN { FS = "\t" ; OFS = "\t" } - { print $3 "/" $2 "/" $1 } - ' \ - | sort -u) \ - | sort -u \ - | awk ' - { FS = "\t" ; OFS = "\t" } - NF == 3 { print "kernel(" $2 ") = " $3 - next } - { split($1, arr, "/") - print "ksym(" arr[3] ") = " arr[2] } - ' + { print $2 "\t" $1 } + ' \ + | sed -r -e 's:$:\t'"$kernel"':' \ + | LC_ALL=C sort -k1,1 -u > $symvers + + # Symbols matching with the kernel get a "kernel" dependency + LC_ALL=C join -t $'\t' -j 1 $symvers <(mod_requires "${modules[@]}") | LC_ALL=C sort -u \ + | awk '{ FS = "\t" ; OFS = "\t" } { print "kernel(" $1 ") = " $2 }' + + # Symbols from elsewhere get a "ksym" dependency + LC_ALL=C join -t $'\t' -j 1 -v 2 $symvers <(mod_requires "${modules[@]}") | LC_ALL=C sort -u \ + | awk '{ FS = "\t" ; OFS = "\t" } { print "ksym(" $1 ") = " $2 }' fi diff --git a/macros b/macros index b93bd9b..112f715 100644 --- a/macros +++ b/macros @@ -44,7 +44,7 @@ # 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_symbols_flags} %{_hardened_ldflags} +%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} # Expands to shell code to seot the compiler/linker environment # variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have @@ -141,7 +141,7 @@ %__brp_strip /usr/lib/rpm/brp-strip %{__strip} %__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump} %__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip} -%__brp_python_bytecompile /usr/lib/rpm/brp-python-bytecompile %{__python} %{?_python_bytecompile_errors_terminate_build} +%__brp_python_bytecompile /usr/lib/rpm/brp-python-bytecompile "%{__python}" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}" %__brp_python_hardlink /usr/lib/rpm/brp-python-hardlink # __brp_mangle_shebangs_exclude - shebangs to exclude # __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude @@ -183,6 +183,8 @@ # ## Should python bytecompilation errors terminate a build? %_python_bytecompile_errors_terminate_build 1 +## Should python bytecompilation compile outisde python specific directories? +%_python_bytecompile_extra 1 # Use SHA-256 for FILEDIGESTS instead of default MD5 %_source_filedigest_algorithm 8 @@ -212,12 +214,20 @@ # Fail linking if there are undefined symbols. Required for proper # ELF symbol versioning support. Disabled by default. -# Use "%define _strict_symbol_defs_build 1" to enable. -#%_strict_symbol_defs_build 1 -%_ld_symbols_flags %{?_strict_symbol_defs_build:-Wl,-z,defs} +# Use "%define _ld_strict_symbol_defs 1" to enable. +#%_ld_strict_symbol_defs 1 +%_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs} + +# https://fedoraproject.org/wiki/Changes/RemoveExcessiveLinking +# use "%define _ld_as_needed 1" to enable. +#%_ld_as_needed 1 +%_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed} %__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches %{_hardened_cflags} %{_annotated_cflags} +# Automatically trim changelog entries after 2 years +%_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)} + #============================================================================== # ---- Generic auto req/prov filtering macros # diff --git a/macros.ldc-srpm b/macros.ldc-srpm index 5718d0c..2ee111e 100644 --- a/macros.ldc-srpm +++ b/macros.ldc-srpm @@ -1,2 +1,2 @@ # arches that ldc builds on -%ldc_arches %{ix86} x86_64 %{arm} %{power64} +%ldc_arches %{ix86} x86_64 %{arm} diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 8b4b79e..9ac55d5 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,11 +6,10 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 111 -Release: 1.4.riscv64%{?dist} +Version: 117 +Release: 1.0.riscv64%{?dist} # No version specified. License: GPL+ -Group: Development/System URL: https://src.fedoraproject.org/rpms/redhat-rpm-config # Core rpm settings @@ -117,7 +116,7 @@ Provides: system-rpm-config = %{version}-%{release} Red Hat specific rpm configuration files. %package -n kernel-rpm-macros -Summary: Macros and scripts for building kernel module packages. +Summary: Macros and scripts for building kernel module packages Requires: redhat-rpm-config >= 13 %description -n kernel-rpm-macros @@ -184,26 +183,33 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.kmp %changelog -* Mon Jun 04 2018 David Abdurachmanov - 111-1.4.riscv64 -- Enable debug packages for RISC-V (riscv64) - -* Wed May 23 2018 David Abdurachmanov - 111-1.3.riscv64 +* Mon Jul 23 2018 David Abdurachmanov - 117-1.0.riscv64 - Disable perl_default_subpackage_tests (test suite subpackage for perl packages) - -* Sun May 06 2018 David Abdurachmanov - 111-1.2.riscv64 -- Enable annobin for riscv64 (finally built, but untested) - -* Sat May 05 2018 David Abdurachmanov - 111-1.1.riscv64 -- Remove Requires: (annobin if gcc) - -* Sat May 05 2018 David Abdurachmanov - 111-1.0.riscv64 - Disable %check for riscv64 -- Disable debug packages for riscv64 (still don't have GDB, which is needed - for debug packages) -- Disable annotated builds for riscv64 (untested) - Add -fasynchronous-unwind-tables -fstack-clash-protection to riscv64 (other arches seem to have them now) +* Mon Jul 16 2018 Miro Hrončok - 117-1 +- Mangle /bin shebnags to /usr/bin ones (#1581757) + +* Tue Jul 10 2018 Igor Gnatenko - 116-1 +- Add option to add -Wl,--as-needed into LDFLAGS + +* Mon Jul 09 2018 Kalev Lember - 115-1 +- Disable non-functional ppc64 support for ldc packages + +* Tue Jun 26 2018 Panu Matilainen - 114-1 +- Fix kernel ABI related strings (Peter Oros, #26) +- Automatically trim changelog to two years (Zbigniew Jędrzejewski-Szmek, #22) +- Cosmetics cleanups (Zbigniew Jędrzejewski-Szmek, #22) + +* Mon Jun 18 2018 Florian Weimer - 113-1 +- Build flags: Require SSE2 on i686 (#1592212) + +* Mon May 28 2018 Miro Hrončok - 112-1 +- Add a possibility to opt-out form automagic Python bytecompilation + https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation + * Wed May 02 2018 Peter Jones - 111-1 - brp-mangle-shebangs: add %%{__brp_mangle_shebangs_exclude_file} and %%{__brp_mangle_shebangs_exclude_from_file} to allow you to specify files diff --git a/rpmrc b/rpmrc index 6f8f80d..2e98e7a 100644 --- a/rpmrc +++ b/rpmrc @@ -3,7 +3,7 @@ include: /usr/lib/rpm/rpmrc optflags: i386 %{__global_compiler_flags} -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection optflags: i486 %{__global_compiler_flags} -m32 -march=i486 -fasynchronous-unwind-tables -fstack-clash-protection optflags: i586 %{__global_compiler_flags} -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -optflags: i686 %{__global_compiler_flags} -m32 -march=i686 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection +optflags: i686 %{__global_compiler_flags} -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection optflags: athlon %{__global_compiler_flags} -m32 -march=athlon -fasynchronous-unwind-tables -fstack-clash-protection optflags: ia64 %{__global_compiler_flags} optflags: x86_64 %{__global_compiler_flags} -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection