Here is an excerpt from a binutils-2.40 rpmbuild log, where I have defined: $ rpmbuild --define '_prefix /usr/local' ... -ba SPECS/binutils.spec ... : + grep '^#define BFD_ARCH_SIZE 64$' /home/adm-jason/rpmbuild/BUILDROOT/binutils-2.40-7.el8.x86_64/usr/include/bfd.h grep: /home/adm-jason/rpmbuild/BUILDROOT/binutils-2.40-7.el8.x86_64/usr/include/bfd.h: No such file or directory error: Bad exit status from /var/tmp/rpm-tmp.G6bnwz (%install) Somehow the test scripts are not picking up redefined $PREFIX . Also, (separate issue), all 'slice' tests fail on the platform I am building on: Rocky RHEL 8. Reproducible: Always Steps to Reproduce: 1. Try to build rawhide binutils with different '%_prefix' definition. Actual Results: Build fails with above error. Expected Results: Build should succeed.
This is @ line 986 of .spec file : # Sanity check --enable-64-bit-bfd really works. grep '^#define BFD_ARCH_SIZE 64$' $local_incdir/bfd.h # Fix multilib conflicts of generated values by __WORDSIZE-based expressions. why isn't $local_incdir being set correctly ? : @ line 898: %install # install_binutils() # Install the binutils. # $1 is the target architecture # $2 is 1 if this is a native build # $3 is 1 if shared libraries should be built # install_binutils() { local target="$1" local native="$2" local shared="$3" local local_root=%{buildroot}/usr ^-- Oops! should be %{buildroot}/%{_prefix} !
With the above change, the build succeeds. How I am building: $ export RPM_OPT_FLAGS=`rpm --eval '%{echo: %{_native_opt_flags_x86_64_}}'` $ rpm --eval '%{echo: %{_native_opt_flags_x86_64_}}' -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -march=x86-64 -mtune=native -O3 -g $ which gcc /opt/rh/gcc-toolset-12/root/usr/bin/gcc $ rpmbuild --define 'optflags '"$RPM_OPT_FLAGS" --define '_prefix /usr/local' -bi --noclean --noprep --nocheck --short-circuit SPECS/binutils.spec 2>&1 | tee LOGS/binutils-2.40.el8.bi.log (my ~/.rpmmacros contains: $ cat ~/.rpmmacros # There is no way to redefine 'optflags' to this without infinite recursion, insided same rpm instance ! : %_native_opt_flags_x86_64_ %(echo %{optflags x86_64} | sed -r 's/[[:space:]]?-m(tune|arch)=[^[:space:]]+/ /;s/[[:space:]]?-O[0-5]?[[:space:]]/ /g;s/[[:space:]]?-g[0-5]?[[:space:]]/ /g') -march=x86-64 -mtune=native -O3 -g I have built glibc and cross-gcc(12) and cross-binutils(2.38) with these flags, all tests pass, glibc performs about 20% faster with these flags. ). (short circuit must be added to redo install with edited .spec file) - this now works, as does producing the RPMs if '-bb' is substituted for '-bi' . adm-jason@devbox01:~/rpmbuild] [966314] 19:13:40 [#:475!:13201]{0} $ declare -p declare -- BASH="/usr/bin/bash" declare -r BASHOPTS="cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:histappend:hostcomplete:interactive_comments:lithist:progcomp:promptvars:sourcepath" declare -ir BASHPID declare -A BASH_ALIASES=() declare -a BASH_ARGC=() declare -a BASH_ARGV=() declare -A BASH_CMDS=() declare -- BASH_COMMAND declare -a BASH_LINENO=() declare -a BASH_SOURCE=() declare -- BASH_SUBSHELL declare -ar BASH_VERSINFO=([0]="4" [1]="4" [2]="20" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu") declare -- BASH_VERSION="4.4.20(1)-release" declare -x CC="gcc" declare -x CFLAGS="-std=gnu17 -march=x86-64 -mtune=native -O3 -g -fPIC -DPIC -pipe" declare -x CLANG="clang" declare -- COLUMNS="159" declare -- COMP_WORDBREAKS declare -x CXX="g++" declare -x CXXFLAGS="-std=gnu++17 -march=x86-64 -mtune=native -O3 -g -fPIC -DPIC -pipe" declare -a DIRSTACK=() declare -x DISPLAY=":6" declare -x EDITOR="emacs -nw -l ~adm-jason/emacs-text-mode.el" declare -ir EUID="1003" declare -a FUNCNAME declare -a GROUPS=() declare -i HISTCMD declare -- HISTFILE="/home/adm-jason/.bash_history" declare -- HISTFILESIZE="1000000000" declare -x HISTSIZE="1000000000" declare -x HOME="/home/adm-jason" declare -x HOST="" declare -- HOSTNAME="devbox01" declare -- HOSTTYPE="x86_64" declare -- IFS=" " declare -x LDFLAGS="-O3 -g -flto -fpic -L/opt/rh/gcc-toolset-12/root/usr/lib64 -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12 -B/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12 -Wl,-rpath,/opt/rh/gcc-toolset-12/root/usr/lib64:/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12" declare -i LINENO declare -- LINES="55" declare -- MACHTYPE="x86_64-redhat-linux-gnu" declare -i MAILCHECK="60" declare -x OLDPWD="/home/adm-jason/rpmbuild/SRPMS" declare -- OPTERR="1" declare -i OPTIND="1" declare -- OSTYPE="linux-gnu" declare -x PAGER="less -Xr" declare -x PATH="/opt/rh/gcc-toolset-12/root/usr/bin:/usr/bin:/usr/sbin" declare -a PIPESTATUS=([0]="0") declare -ir PPID="10484" declare -x PROMPT_COMMAND="printf \"\\033]0;%s@%s:%s\\007\" \"\${USER}\" \"\${HOSTNAME}\" \"\${PWD/#\$HOME/~} [\$\$]\"" declare -x PS1="\${_fc_}[\${USER}@\${HOSTNAME}\${_fn_}:\${_fg_}\\w] [\$\$] \\t [#:\\#!:\\!]{\$?}\${_tab_}\${_fcy_}\$(__git_ps1)\${_fn_} \$ " declare -- PS2="> " declare -- PS4="+ " declare -x PWD="/home/adm-jason/rpmbuild" declare -i RANDOM declare -x RPM_OPT_FLAGS=" -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -march=x86-64 -mtune=native -O3 -g" declare -- SECONDS declare -- SHELL="/bin/bash" declare -r SHELLOPTS="braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor" declare -x SHLVL="1" declare -x TERM="xterm-256color" declare -ir UID="1003" declare -x USER="adm-jason" declare -x V="1" declare -x VERBOSE="255" declare -i WITH_GIT_PS1="0" declare -x XDG_RUNTIME_DIR="/run/user/1003" declare -- _="%{echo: %{_native_opt_flags_x86_64_}}" declare -x _fc_="" declare -x _fcy_="" declare -x _fg_="" declare -x _fn_="" declare -x _fpnk_="" declare -x _tab_=" " declare -- fn="" [adm-jason@devbox01:~/rpmbuild] [966314] 19:13:52 [#:476!:13202]{0} $ ^C [adm-jason@devbox01:~/rpmbuild] [966314] 19:14:41 [#:476!:13202]{130} $
Oh, and I had to create the symlink: $ ls -l /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/plugin/ total 1376 -rw-r--r-- 1 root root 24 Oct 2 2022 annobin-plugin-version-info lrwxrwxrwx 1 root root 16 Oct 2 2022 annobin.so -> annobin.so.0.0.0 lrwxrwxrwx 1 root root 16 Oct 2 2022 annobin.so.0 -> annobin.so.0.0.0 -rwxr-xr-x 1 root root 49376 Oct 2 2022 annobin.so.0.0.0 lrwxrwxrwx 1 root root 16 Apr 29 00:13 gcc-annobin.so -> annobin.so.0.0.0 ^-- this symlink must exist, and didn't ! -rw-r--r-- 1 root root 1330361 Jan 12 11:20 gtype.state drwxr-xr-x 9 root root 16384 Mar 21 01:23 include
a bit off topic : Changes necessary to glibc.spec to compile with : -march=native -mtune=intel (GCC-12+ / Fedora) or -march=x86-64 -mtune=native (GCC-8+ / RHEL 8) : # Propagates the listed flags to rpm_append_flag if supplied by # redhat-rpm-config. BuildFlags="-O2 -g" rpm_inherit_flags () { local reference=" $* " local flag local seen_mtune=0; local seen_march=0; for flag in $CFLAGS $RPM_OPT_FLAGS $RPM_LD_FLAGS ; do case "$flag" in (-mtune*) if (( $seen_mtune == 1 )); then continue; fi seen_mtune=1; ;; (-march*) if (( $seen_march == 1 )); then continue; fi seen_march=1; ;; esac if echo "$reference" | grep -q -F " $flag " ; then rpm_append_flag "$flag" fi done } # Propgate select compiler flags from redhat-rpm-config. These flags # are target-dependent, so we use only those which are specified in # redhat-rpm-config. We keep the -m32/-m32/-m64 flags to support # multilib builds. # # Note: For building alternative run-times, care is required to avoid # overriding the architecture flags which go into CC/CXX. The flags # below are passed in CFLAGS. rpm_inherit_flags \ "-Wp,-D_GLIBCXX_ASSERTIONS" \ "-fasynchronous-unwind-tables" \ "-fstack-clash-protection" \ "-funwind-tables" \ "-m31" \ "-m32" \ "-m64" \ "-march=native" \ "-march=i686" \ "-march=x86-64" \ "-march=x86-64-v2" \ "-march=x86-64-v4" \ "-march=z13" \ "-march=z14" \ "-march=zEC12" \ "-mfpmath=sse" \ "-msse2" \ "-mstackrealign" \ "-mtune=intel" \ "-mtune=native" \ "-mtune=generic" \ "-mtune=z13" \ "-mtune=z14" \ "-mtune=zEC12" \ "-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1" \ Building and installing glibc with these flags on Fedora 36 and RHEL8 works and passes test suite during build, and results in a MUCH faster glibc. It would be great if RedHat would provide a global 'RPM_INSTALL_NATIVE_RPMS' option that would result in best optimized glibc for native processor / platform being installed.
Fixed in binutils-2.40-8.fc39 and binutils-2.39-12.fc38
FEDORA-2023-fb366d5ed5 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-fb366d5ed5
FEDORA-2023-14607e274c has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-14607e274c
FEDORA-2023-eafe3fad16 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2023-eafe3fad16
FEDORA-2023-fb366d5ed5 has been pushed to the Fedora 38 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-fb366d5ed5` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-fb366d5ed5 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2023-eafe3fad16 has been pushed to the Fedora 36 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-eafe3fad16` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-eafe3fad16 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2023-14607e274c has been pushed to the Fedora 37 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-14607e274c` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-14607e274c See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2023-14607e274c has been pushed to the Fedora 37 stable repository. If problem still persists, please make note of it in this bug report.