#92 Build a POWER10 multilib
Merged a month ago by codonell. Opened 2 months ago by fweimer.
rpms/ fweimer/glibc power10-rawhide  into  rawhide

file modified
+186 -126
@@ -61,6 +61,13 @@ 

  %endif

  %endif

  

+ # Build the POWER10 multilib.

+ %ifarch ppc64le

+ %define buildpower10 1

+ %else

+ %define buildpower10 0

+ %endif

+ 

  %if %{with bootstrap}

  # Disable benchtests, -Werror, docs, and valgrind if we're bootstrapping

  %undefine with_benchtests
@@ -69,16 +76,8 @@ 

  %undefine with_valgrind

  %endif

  

- # The annobin annotations cause binutils to produce broken ARM EABI

- # unwinding information.  Symptom is a hang/test failure for

- # malloc/tst-malloc-stats-cancellation.  See

- # <https://bugzilla.redhat.com/show_bug.cgi?id=1951492>.

- %ifarch armv7hl

- %undefine _annotated_build

- %endif

- 

  # We do our own build flags management.  In particular, see

- # rpm_inherit_flags below.

+ # glibc_shell_* below.

  %undefine _auto_set_build_flags

  

  ##############################################################################
@@ -238,6 +237,36 @@ 

  # Include in the source RPM for reference.

  Source12: ChangeLog.old

  

+ # ABI-specific program interpreter name.  Used for debuginfo

+ # extraction (wrap-find-debuginfo.sh) and smoke testing ($run_ldso below).

+ %ifarch %{ix86}

+ %global glibc_ldso /lib/ld-linux.so.2

+ %endif

+ %ifarch aarch64

+ %global glibc_ldso /lib/ld-linux-aarch64.so.1

+ %endif

+ %ifarch ppc

+ %global glibc_ldso /lib/ld.so.1

+ %endif

+ %ifarch ppc64

+ %global glibc_ldso /lib64/ld64.so.1

+ %endif

+ %ifarch ppc64le

+ %global glibc_ldso /lib64/ld64.so.2

+ %endif

+ %ifarch riscv64

+ %global glibc_ldso /lib/ld-linux-riscv64-lp64d.so.1

+ %endif

+ %ifarch s390

+ %global glibc_ldso /lib/ld.so.1

+ %endif

+ %ifarch s390x

+ %global glibc_ldso /lib/ld64.so.1

+ %endif

+ %ifarch x86_64 x86_64_v2 x86_64_v3 x86_64_v4

+ %global glibc_ldso /lib64/ld-linux-x86-64.so.2

+ %endif

+ 

  ######################################################################

  # Activate the wrapper script for debuginfo generation, by rewriting

  # the definition of __debug_install_post.
@@ -249,7 +278,7 @@ 

  -- Avoid embedded newlines that confuse the macro definition.

  original = original:match("^%s*(.-)%s*$"):gsub("\\\n", "")

  rpm.define("__debug_install_post bash " .. wrapper

-   .. " " .. sysroot .. " " .. original)

+   .. " " .. sysroot .. " %{glibc_ldso} " .. original)

  }

  

  # sysroot package support.  These contain arch-specific packages, so
@@ -350,10 +379,7 @@ 

  BuildRequires: gcc >= 7.2.1-6

  %global enablekernel 3.2

  Conflicts: kernel < %{enablekernel}

- %global target %{_target_cpu}-redhat-linux

- %ifarch %{arm}

- %global target %{_target_cpu}-redhat-linuxeabi

- %endif

+ %define target %{_target_cpu}-redhat-linux

  %ifarch ppc64le

  %global target ppc64le-redhat-linux

  %endif
@@ -1153,78 +1179,97 @@ 

  cat /proc/meminfo

  df

  

- # We build using the native system compilers.

- GCC=gcc

- GXX=g++

- 

- # Part of rpm_inherit_flags.  Is overridden below.

- rpm_append_flag ()

- {

-     BuildFlags="$BuildFlags $*"

- }

- 

- # Propagates the listed flags to rpm_append_flag if supplied by

- # redhat-rpm-config.

- BuildFlags="-O2 -g"

- rpm_inherit_flags ()

- {

- 	local reference=" $* "

- 	local flag

- 	for flag in $RPM_OPT_FLAGS $RPM_LD_FLAGS ; do

- 		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" \

- 	"-fno-omit-frame-pointer" \

- 	"-funwind-tables" \

- 	"-m31" \

- 	"-m32" \

- 	"-m64" \

- 	"-march=armv8-a+lse" \

- 	"-march=armv8.1-a" \

- 	"-march=haswell" \

- 	"-march=i686" \

- 	"-march=x86-64" \

- 	"-march=x86-64-v2" \

- 	"-march=x86-64-v3" \

- 	"-march=x86-64-v4" \

- 	"-march=z13" \

- 	"-march=z14" \

- 	"-march=z15" \

- 	"-march=zEC12" \

- 	"-mbackchain" \

- 	"-mbranch-protection=standard" \

- 	"-mcpu=power10" \

- 	"-mcpu=power8" \

- 	"-mcpu=power9" \

- 	"-mfpmath=sse" \

- 	"-mno-omit-leaf-frame-pointer" \

- 	"-msse2" \

- 	"-mstackrealign" \

- 	"-mtune=generic" \

- 	"-mtune=power10" \

- 	"-mtune=power8" \

- 	"-mtune=power9" \

- 	"-mtune=z13" \

- 	"-mtune=z14" \

- 	"-mtune=z15" \

- 	"-mtune=zEC12" \

- 	"-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1" \

+ 

+ %{lua:

+ -- Split the string argument into keys of an associate array.

+ -- The values are set to true.

+ local function string_to_array(s)

+     local result = {}

+     for e in string.gmatch(s, "%S+") do

+         result[e] = true

+     end

+     return result

+ end

+ 

+ local inherit_flags = {}

+ 

+ -- These flags are put into the CC and CXX arguments to configure.

+ -- Alternate builds do not use the flags listed here, only the main build does.

+ inherit_flags.cc_main = string_to_array [[

+ -march=armv8-a+lse

+ -march=armv8.1-a

+ -march=haswell

+ -march=i686

+ -march=x86-64

+ -march=x86-64-v2

+ -march=x86-64-v3

+ -march=x86-64-v4

+ -march=z13

+ -march=z14

+ -march=z15

+ -march=zEC12

+ -mcpu=power10

+ -mcpu=power8

+ -mcpu=power9

+ -mtune=generic

+ -mtune=power10

+ -mtune=power8

+ -mtune=power9

+ -mtune=z13

+ -mtune=z14

+ -mtune=z15

+ -mtune=zEC12

+ ]]

+ 

+ -- Like inherit_flags_cc_main, but also used for alternate builds.

+ inherit_flags.cc = string_to_array [[

+ -m31

+ -m32

+ -m64

+ ]]

+ 

+ -- These flags are passed through CFLAGS and CXXFLAGS.

+ inherit_flags.cflags = string_to_array [[

+ -O2

+ -O3

+ -Wall

+ -Wp,-D_GLIBCXX_ASSERTIONS

+ -fasynchronous-unwind-tables

+ -fno-omit-frame-pointer

+ -fstack-clash-protection

+ -funwind-tables

+ -g

+ -mbackchain

+ -mbranch-protection=standard

+ -mfpmath=sse

+ -mno-omit-leaf-frame-pointer

+ -msse2

+ -mstackrealign

+ -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1

+ ]]

+ 

+ -- Iterate over the build_cflags RPM variable and emit a shell

+ -- variable that contains the inherited flags of the indicated variant.

+ local function shell_build_flags(variant)

+     local result = {}

+     local inherit = assert(inherit_flags[variant])

+     for f in string.gmatch(rpm.expand("%build_cflags"), "%S+") do

+         if inherit[f] then

+ 	    result[#result + 1] = f

+ 	end

+     end

+     print("glibc_flags_" .. variant .. "=\"" .. table.concat(result, " ")

+           .. "\"\n")

+ end

+ 

+ shell_build_flags('cc_main') -- Set $glibc_flags_cc_main.

+ shell_build_flags('cc') -- Set $glibc_flags_cc.

+ shell_build_flags('cflags') -- Set $glibc_flags_cflags.

+ }

  

  %if 0%{?_annotated_build} > 0

  # libc_nonshared.a cannot be built with the default hardening flags
@@ -1246,34 +1291,29 @@ 

  # %%build - Generic options.

  ##############################################################################

  EnableKernel="--enable-kernel=%{enablekernel}"

- # Save the used compiler and options into the file "Gcc" for use later

- # by %%install.

- echo "$GCC" > Gcc

  

  ##############################################################################

  # build()

- #	Build glibc in `build-%{target}$1', passing the rest of the arguments

- #	as CFLAGS to the build (not the same as configure CFLAGS). Several

+ #	Build glibc in the directory $1, passing the rest of the arguments

+ #	as additional configure arguments.  Several

  #	global values are used to determine build flags, kernel version,

  #	system tap support, etc.

  ##############################################################################

  build()

  {

- 	local builddir=build-%{target}${1:+-$1}

- 	${1+shift}

+ 	local builddir=$1

+ 	shift

  	rm -rf $builddir

  	mkdir $builddir

  	pushd $builddir

- 	../configure CC="$GCC" CXX="$GXX" CFLAGS="$BuildFlags $*" \

+ 	../configure "$@" \

  		--prefix=%{_prefix} \

  		--with-headers=%{_prefix}/include $EnableKernel \

  		--with-nonshared-cflags="$BuildFlagsNonshared" \

  		--enable-bind-now \

  		--build=%{target} \

- 		${configure_host} \

  		--enable-stack-protector=strong \

  		--enable-systemtap \

- 		${core_with_options} \

  %ifarch %{ix86}

  		--disable-multi-arch \

  %endif
@@ -1308,17 +1348,34 @@ 

  

  %ifarch x86_64

  # Build for the glibc32 package.

- GCC="$GCC -m32" GXX="$GXX -m32" BuildFlags="${BuildFlags/-m64/-m32}" configure_host="--host=i686-linux-gnu" build 32

+ build build-%{target}-32 \

+   CC="gcc -m32" \

+   CXX="g++ -m32" \

+   CFLAGS="${glibc_flags_cflags/-m64/-m32}" \

+   --host=i686-linux-gnu \

+ #

  %endif

  

- configure_host=""

- 

+ # Default set of compiler options.

+ build build-%{target} \

+   CC="gcc $glibc_flags_cc $glibc_flags_cc_main" \

+   CXX="g++ $glibc_flags_cc $glibc_flags_cc_main" \

+   CFLAGS="$glibc_flags_cflags" \

  %ifarch x86_64

- configure_host="--enable-cet"

+   --enable-cet \

+ %endif

+ #

+ 

+ # POWER10 build variant.

+ %if %{buildpower10}

+ build build-%{target}-power10 \

+   CC="gcc $glibc_flags_cc" \

+   CXX="g++ $glibc_flags_cc" \

+   CFLAGS="$glibc_flags_cflags" \

+   --with-cpu=power10 \

+ #

  %endif

  

- # Default set of compiler options.

- build

  

  ##############################################################################

  # Install glibc...
@@ -1334,9 +1391,6 @@ 

  # Remove existing file lists.

  find . -type f -name '*.filelist' -exec rm -rf {} \;

  

- # Reload compiler and build options that were used during %%build.

- GCC=`cat Gcc`

- 

  %ifarch riscv64

  # RISC-V ABI wants to install everything in /lib64/lp64d or /usr/lib64/lp64d.

  # Make these be symlinks to /lib64 or /usr/lib64 respectively.  See:
@@ -1401,23 +1455,28 @@ 

  	mkdir -p "$destdir"

  	mkdir -p "$libdestdir"

  	# Walk all of the libraries we installed...

- 	for lib in libc math/libm nptl/libpthread rt/librt nptl_db/libthread_db

+ 	for lib in libc math/libm

  	do

  		libbase=${lib#*/}

  		# Take care that `libbaseso' has a * that needs expanding so

  		# take care with quoting.

- 		libbaseso=$(basename %{glibc_sysroot}/%{_lib}/${libbase}-*.so)

+ 		libbaseso=$(basename %{glibc_sysroot}/%{_lib}/${libbase}.so.*)

  		# Only install if different from default build library.

  		if cmp -s ${lib}.so ../build-%{target}/${lib}.so; then

  			ln -sf "$subdir_up"/$libbaseso $libdestdir/$libbaseso

  		else

  			cp -a ${lib}.so $libdestdir/$libbaseso

  		fi

- 		dlib=$libdestdir/$(basename %{glibc_sysroot}/%{_lib}/${libbase}.so.*)

- 		ln -sf $libbaseso $dlib

  	done

  }

  

+ %if %{buildpower10}

+ pushd build-%{target}-power10

+ install_different "$RPM_BUILD_ROOT/%{_libdir}/glibc-hwcaps" power10 ..

+ popd

+ %endif

+ 

+ 

  ##############################################################################

  # Remove the files we don't want to distribute

  ##############################################################################
@@ -2149,6 +2208,16 @@ 

  run_tests

  popd

  

+ %if %{buildpower10}

+ # Run this test only if the server supports Power10 instructions.

+ if LD_SHOW_AUXV=1 /bin/true | grep -E "AT_HWCAP2:[^$]*arch_3_1" > /dev/null; then

+   echo ====================TESTING -mcpu=power10=============

+   pushd build-%{target}-power10

+   run_tests

+   popd

+ fi

+ %endif

+ 

  echo ====================TESTING END=====================

  PLTCMD='/^Relocation section .*\(\.rela\?\.plt\|\.rela\.IA_64\.pltoff\)/,/^$/p'

  echo ====================PLT RELOCS LD.SO================
@@ -2157,19 +2226,7 @@ 

  readelf -Wr %{glibc_sysroot}/%{_lib}/libc-*.so | sed -n -e "$PLTCMD"

  echo ====================PLT RELOCS END==================

  

- # Obtain a way to run the dynamic loader.  Avoid matching the symbolic

- # link and then pick the first loader (although there should be only

- # one).  Use -maxdepth 2 to avoid descending into the /sys-root/

- # sub-tree.  See wrap-find-debuginfo.sh.

- %ifarch x86_64

- # Hardcode the patch to avoid picking up the 32-bit dynamic linker from

- # glibc32; both 32-bit and 64-bit dynamic linkers will be present.

- ldso_path="%{glibc_sysroot}/lib64/ld-linux-x86-64.so.2"

- %else

- ldso_path="$(find %{glibc_sysroot}/ -maxdepth 2 -regextype posix-extended \

-   -regex '.*/ld(-.*|64|)\.so\.[0-9]+$' -type f | LC_ALL=C sort | head -n1)"

- %endif

- run_ldso="$ldso_path --library-path %{glibc_sysroot}/%{_lib}"

+ run_ldso="%{glibc_sysroot}/%{glibc_ldso} --library-path %{glibc_sysroot}/%{_lib}"

  

  # Show the auxiliary vector as seen by the new library

  # (even if we do not perform the valgrind test).
@@ -2200,13 +2257,11 @@ 

    error("FATAL: kernel too old", 0)

  end

  

- %post -p <lua>

- %glibc_post_funcs

  -- (1) Remove multilib libraries from previous installs.

  -- In order to support in-place upgrades, we must immediately remove

- -- obsolete platform directories after installing a new glibc

+ -- all platform directories before installing a new glibc

  -- version.  RPM only deletes files removed by updates near the end

- -- of the transaction.  If we did not remove the obsolete platform

+ -- of the transaction.  If we did not remove all platform

  -- directories here, they may be preferred by the dynamic linker

  -- during the execution of subsequent RPM scriptlets, likely

  -- resulting in process startup failures.
@@ -2279,7 +2334,9 @@ 

    end

  end

  

- -- (2) Update /etc/ld.so.conf

+ %post -p <lua>

+ %glibc_post_funcs

+ -- (1) Update /etc/ld.so.conf

  -- Next we update /etc/ld.so.conf to ensure that it starts with

  -- a literal "include ld.so.conf.d/*.conf".

  
@@ -2318,14 +2375,14 @@ 

    end

  end

  

- -- (3) Rebuild ld.so.cache early.

+ -- (2) Rebuild ld.so.cache early.

  -- If the format of the cache changes then we need to rebuild

  -- the cache early to avoid any problems running binaries with

  -- the new glibc.

  

  call_ldconfig()

  

- -- (4) Update gconv modules cache.

+ -- (3) Update gconv modules cache.

  -- If the /usr/lib/gconv/gconv-modules.cache exists, then update it

  -- with the latest set of modules that were just installed.

  -- We assume that the cache is in _libdir/gconv and called
@@ -2333,7 +2390,7 @@ 

  

  update_gconv_modules_cache()

  

- -- (5) On upgrades, restart systemd if installed.  "systemctl -q" does

+ -- (4) On upgrades, restart systemd if installed.  "systemctl -q" does

  -- not suppress the error message (which is common in chroots), so

  -- open-code rpm.execute with standard error suppressed.

  if tonumber(arg[2]) >= 2
@@ -2382,6 +2439,9 @@ 

  

  %files -f glibc.filelist

  %dir %{_prefix}/%{_lib}/audit

+ %if %{buildpower10}

+ %dir /%{_libdir}/glibc-hwcaps/power10

+ %endif

  %verify(not md5 size mtime) %config(noreplace) /etc/ld.so.conf

  %verify(not md5 size mtime) %config(noreplace) /etc/rpc

  %dir /etc/ld.so.conf.d

file modified
+50 -59
@@ -18,7 +18,13 @@ 

  workdir="$(mktemp -d -t find_debuginfo.XXXXXX)"

  

  ldso_tmp="$workdir/ld.so"

- libc_tmp="$workdir/libc.so"

+ libc_tmp_dir="$workdir/"

+ 

+ # Return the path where a libc should be saved temporarily. This path is

+ # based on its original path received in $1.

+ libc_tmp_path() {

+     echo "$libc_tmp_dir"`dirname "$1"`"/libc.so"

+ }

  

  # Prefer a separately installed debugedit over the RPM-integrated one.

  if command -v debugedit >/dev/null ; then
@@ -34,64 +40,65 @@ 

  

  sysroot_path="$1"

  shift

+ # Resolve symbolic link, so that the activities below only alter the

+ # file it points to.

+ ldso_path="$(readlink -f "$sysroot_path/$1")"

+ shift

  script_path="$1"

  shift

  

- # See ldso_path setting in glibc.spec.

- ldso_path=

- for ldso_candidate in `find "$sysroot_path" -maxdepth 2 \

-   -regextype posix-extended -regex '.*/ld(-.*|64|)\.so\.[0-9]+$' -type f` ; do

-     if test -z "$ldso_path" ; then

- 	ldso_path="$ldso_candidate"

-     elif [ -f "$sysroot_path/lib64/ld-linux-x86-64.so.2" ] && [ -f "$sysroot_path/lib/ld-linux.so.2" ]; then

- 	# x86_64 with 32-bit libc built for glibc32 as well.  Finding

- 	# multiple dynamic linkers is expected, not a bug; ensure the

- 	# 64-bit one is used.

- 	ldso_path="$sysroot_path/lib64/ld-linux-x86-64.so.2"

-     else

- 	echo "error: multiple ld.so candidates: $ldso_path, $ldso_candidate"

- 	exit 1

-     fi

- done

- 

  # libc.so.6 always uses this name, so it is simpler to locate.

- libc_path=

- for libc_candidate in `find "$sysroot_path" -maxdepth 2 -name libc.so.6`; do

-     if test -z "$libc_path" ; then

- 	libc_path="$libc_candidate"

-     elif [ -f "$sysroot_path/lib64/ld-linux-x86-64.so.2" ] && [ -f "$sysroot_path/lib/ld-linux.so.2" ]; then

- 	# x86_64 with 32-bit libc built for glibc32 as well.  The test

- 	# here uses ld.so paths, not libc paths, to ensure it doesn't

- 	# apply on any other architecture.

- 	libc_path="$sysroot_path/lib64/libc.so.6"

-     else

- 	echo "error: multiple libc.so.6 candidates: $libc_path, $libc_candidate"

- 	exit 1

-     fi

- done

+ # This can result in multiple paths, hence the loop below.

+ libc_path=`find "$sysroot_path" -name libc.so.6`

  

  

  # Preserve the original files.

  cp "$ldso_path" "$ldso_tmp"

- cp "$libc_path" "$libc_tmp"

+ for lib in $libc_path ; do

+     libtmp=`libc_tmp_path $lib`

+     mkdir -p `dirname "$libtmp"`

+     cp "$lib" "$libtmp"

+ done

  

  # Run the debuginfo extraction.

  "$script_path" "$@"

  

- # libc.so.6: Extract the .gnu_debuglink section

- objcopy -j.gnu_debuglink --set-section-flags .gnu_debuglink=alloc \

-   -O binary "$libc_path" "$libc_tmp.debuglink"

+ for lib in $libc_path ; do

+     libtmp=`libc_tmp_path "$lib"`

+     # libc.so.6: Extract the .gnu_debuglink section

+     objcopy -j.gnu_debuglink --set-section-flags .gnu_debuglink=alloc \

+         -O binary "$lib" "$libtmp.debuglink"

+     # Restore the original files.

+     cp "$libtmp" "$lib"

+ 

+     # Reduce the size of libc notes.  Primarily for annobin.

+     objcopy --merge-notes "$lib"

+ 

+     # libc.so.6: Restore the .gnu_debuglink section

+     objcopy --add-section .gnu_debuglink="$libtmp.debuglink" "$lib"

+ 

+     # libc.so.6: Reduce to valuable symbols.  Eliminate file symbols,

+     # annobin symbols, and symbols used by the glibc build to implement

+     # hidden aliases (__EI_*).  We would also like to remove __GI_*

+     # symbols, but even listing them explicitly (as in -K __GI_strlen)

+     # still causes strip to remove them, so there is no filtering of

+     # __GI_* here.  (Debuginfo is gone after this, so no need to optimize

+     # it.)

+     strip -w \

+           -K '*' \

+           -K '!*.c' \

+           -K '!*.os' \

+           -K '!.annobin_*' \

+           -K '!__EI_*' \

+           -K '!__PRETTY_FUNCTION__*' \

+           "$lib"

+ done

  

- # Restore the original files.

+ # Restore the original ld.so.

  cp "$ldso_tmp" "$ldso_path"

- cp "$libc_tmp" "$libc_path"

  

  # Reduce the size of notes.  Primarily for annobin.

  objcopy --merge-notes "$ldso_path"

- objcopy --merge-notes "$libc_path"

- 

- # libc.so.6: Restore the .gnu_debuglink section

- objcopy --add-section .gnu_debuglink="$libc_tmp.debuglink" "$libc_path"

  

  # ld.so does not have separated debuginfo and so the debuginfo file

  # generated by find-debuginfo is redundant.  Therefore, remove it.
@@ -108,22 +115,6 @@ 

  done

  rm -f "$ldso_debug"

  

- # libc.so.6: Reduce to valuable symbols.  Eliminate file symbols,

- # annobin symbols, and symbols used by the glibc build to implement

- # hidden aliases (__EI_*).  We would also like to remove __GI_*

- # symbols, but even listing them explicitly (as in -K __GI_strlen)

- # still causes strip to remove them, so there is no filtering of

- # __GI_* here.  (Debuginfo is gone after this, so no need to optimize

- # it.)

- strip -w \

-     -K '*' \

-     -K '!*.c' \

-     -K '!*.os' \

-     -K '!.annobin_*' \

-     -K '!__EI_*' \

-     -K '!__PRETTY_FUNCTION__*' \

-     "$libc_path"

- 

  # ld.so: Rewrite the source file paths to match the extracted

  # locations.  First compute the arguments for invoking debugedit.

  # See find-debuginfo.sh.
@@ -147,7 +138,7 @@ 

  debug_base_name=${last_arg:-$RPM_BUILD_ROOT}

  $debugedit -b "$debug_base_name" -d "$debug_dest_name" -n $ldso_path

  # Remove the .annobin* symbols (and only them).

- if nm --format=just-symbols "$ldso_path" \

+ if nm --format=posix "$ldso_path" | cut -d' ' -f1 \

  	| grep '^\.annobin' > "$ldso_tmp.annobin-symbols"; then

      objcopy --strip-symbols="$ldso_tmp.annobin-symbols" "$ldso_path"

  fi

This is mostly a forward-port of Tulio's POWER10 multilib changes that went into CentOS 9 Stream. The major changes are:

  • The flag inheritance is rewritten in Lua, and the build flags are split in three parts: CC arguments for the default build only, CC arguments for all builds, and CFLAGS for all builds. The way the flags are passed to the ./configure invocation is now much more explicit.
  • To deal with those multiple ld.so paths floating around, the paths are now hard-coded in glibc.spec, based on the RPM architecture. (Maybe this wasn't necessary.) The commit introducing that also contains the wrap-find-debuginfo.sh changes from Tulio that enable processing of multiple libc.so.6 files.
  • And then Tulio's changes to build the POWER10 multilib, adapted to the new way of invoking ./configure.

Presently, this fails to build with the POWER10 test suite enabled because of a crash in an iconv test. (It is possible that this is the first time POWER10 code is run outside the test harness.) I need to figure out what is going on once I have access to a POWER10 machine. Building on a POWER9 host works because the test suite does not run there.

s/instraction/extraction/g

The POWER10 multilib pieces are exactly as expected.
The cleanup looks great, and I think switching to explicit ld.so uses is robust.
Only noticed one spelling issue.

With the spelling issue fixed this LGTM.

Reviewed-by: Carlos O'Donell carlos@redhat.com

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/64c9dc1262f744bb896297d4ab22c575

rebased onto 7121e3e

2 months ago

Original failures:

The test suite found some real failures:

:: [ 20:18:51 ] :: [   PASS   ] :: Command './tst-getlogin_r' (Expected 0, got 0)
:: [ 20:18:51 ] :: [  BEGIN   ] :: Running 'gdb --batch --command=list.gdb ./tst-getlogin_r > gdb_log'
Function "__getlogin_r_loginuid" not defined.
list.gdb:7: Error in sourced command file:
The program is not being run.
:: [ 20:18:51 ] :: [   LOG    ] :: Output of 'gdb --batch --command=list.gdb ./tst-getlogin_r > gdb_log':
:: [ 20:18:52 ] :: [   LOG    ] :: --------------- OUTPUT START ---------------
:: [ 20:18:52 ] :: [   LOG    ] :: Function "__getlogin_r_loginuid" not defined.
:: [ 20:18:52 ] :: [   LOG    ] :: list.gdb:7: Error in sourced command file:
:: [ 20:18:52 ] :: [   LOG    ] :: The program is not being run.
:: [ 20:18:52 ] :: [   LOG    ] :: ---------------  OUTPUT END  ---------------
:: [ 20:18:52 ] :: [   FAIL   ] :: Command 'gdb --batch --command=list.gdb ./tst-getlogin_r > gdb_log' (Expected 0, got 1)
:: [ 20:18:52 ] :: [   FAIL   ] :: File 'gdb_log' should contain 'if (uid == (uid_t) -1)' 
egrep: warning: egrep is obsolescent; using grep -E
:: [ 20:18:52 ] :: [   INFO   ] :: Sending gdb_log as gdb_log
:: [ 20:31:42 ] :: [  BEGIN   ] :: Running 'file /sbin/ldconfig /sbin/iconvconfig /usr/bin/localedef /usr/lib64/ld-linux-x86-64.so.2 > output.log 2>&1'
:: [ 20:31:42 ] :: [   PASS   ] :: Command 'file /sbin/ldconfig /sbin/iconvconfig /usr/bin/localedef /usr/lib64/ld-linux-x86-64.so.2 > output.log 2>&1' (Expected 0, got 0)
:: [ 20:31:42 ] :: [   PASS   ] :: File 'output.log' should contain 'ldconfig.*, stripped' 
:: [ 20:31:42 ] :: [   PASS   ] :: File 'output.log' should contain 'iconvconfig.*, stripped' 
:: [ 20:31:42 ] :: [   PASS   ] :: File 'output.log' should contain 'localedef.*, stripped' 
:: [ 20:31:42 ] :: [   PASS   ] :: File 'output.log' should contain '/usr/lib64/ld-linux-x86-64.so.2.*, not stripped' 
:: [ 20:31:42 ] :: [   INFO   ] :: Content of output.log:
/sbin/ldconfig:                  ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), static-pie linked, BuildID[sha1]=2867bf2c754828f10275695a355a07c7c7c58cb2, for GNU/Linux 3.2.0, stripped
/sbin/iconvconfig:               ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2c3674ac0b4e7d7b949c576eab4c063b45ea7312, for GNU/Linux 3.2.0, stripped
/usr/bin/localedef:              ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=27744f5c00a309d7b2cbc59b31c37d35a712fe1b, for GNU/Linux 3.2.0, stripped
/usr/lib64/ld-linux-x86-64.so.2: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), static-pie linked, BuildID[sha1]=1b8019cb8ea47460094ed6d1114a1cbc4c202c84, with debug_info, not stripped
:: [ 20:31:42 ] :: [  BEGIN   ] :: Running 'gdb --batch -ex 'ptype struct pthread' /usr/bin/ld.so > gdb.log 2>&1'
:: [ 20:31:42 ] :: [   FAIL   ] :: Command 'gdb --batch -ex 'ptype struct pthread' /usr/bin/ld.so > gdb.log 2>&1' (Expected 0, got 1)
:: [ 20:31:42 ] :: [   FAIL   ] :: File 'gdb.log' should contain 'type = struct pthread' 
:: [ 20:31:42 ] :: [   FAIL   ] :: File 'gdb.log' should not contain 'No struct type named pthread' 

I believe this was due to a missing -g in CFLAGS. The updated test run (for commit faaaa5c) has this fixed. It also has a test fix for what I believe to be an upstream issue on POWER10:

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/675e596a0cfa4aed84fc78d3f45a9566

The valgrind smoke test fails when building for x86-64-v3:

+ /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64//lib64/ld-linux-x86-64.so.2 --library-path /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64/lib64 /usr/bin/valgrind --error-exitcode=1 /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64//lib64/ld-linux-x86-64.so.2 --library-path /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64/lib64 /usr/bin/true
==1488267== Memcheck, a memory error detector
==1488267== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==1488267== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==1488267== Command: /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64//lib64/ld-linux-x86-64.so.2 --library-path /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64/lib64 /usr/bin/true
==1488267== 
==1488267== Conditional jump or move depends on uninitialised value(s)
==1488267==    at 0x12D268: strcmp (strcmp-avx2.S:462)
==1488267==    by 0x112A99: _dl_name_match_p (dl-misc.c:69)
==1488267==    by 0x10FD6B: _dl_map_object (dl-load.c:1966)
==1488267==    by 0x124230: map_doit (rtld.c:646)
==1488267==    by 0x109522: _dl_catch_exception (dl-catch.c:241)
==1488267==    by 0x109678: _dl_catch_error (dl-catch.c:260)
==1488267==    by 0x12472C: do_preload (rtld.c:818)
==1488267==    by 0x12557E: handle_preload_list (rtld.c:894)
==1488267==    by 0x1282F0: dl_main (rtld.c:1844)
==1488267==    by 0x123AC5: _dl_sysdep_start (dl-sysdep.c:140)
==1488267==    by 0x125320: _dl_start_final (rtld.c:496)
==1488267==    by 0x125320: _dl_start (rtld.c:583)
==1488267==    by 0x1240C7: ??? (in /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64/lib64/ld-linux-x86-64.so.2)
==1488267== 
==1488267== Conditional jump or move depends on uninitialised value(s)
==1488267==    at 0x12D268: strcmp (strcmp-avx2.S:462)
==1488267==    by 0x112AC3: _dl_name_match_p (dl-misc.c:75)
==1488267==    by 0x10FD6B: _dl_map_object (dl-load.c:1966)
==1488267==    by 0x124230: map_doit (rtld.c:646)
==1488267==    by 0x109522: _dl_catch_exception (dl-catch.c:241)
==1488267==    by 0x109678: _dl_catch_error (dl-catch.c:260)
==1488267==    by 0x12472C: do_preload (rtld.c:818)
==1488267==    by 0x12557E: handle_preload_list (rtld.c:894)
==1488267==    by 0x1282F0: dl_main (rtld.c:1844)
==1488267==    by 0x123AC5: _dl_sysdep_start (dl-sysdep.c:140)
==1488267==    by 0x125320: _dl_start_final (rtld.c:496)
==1488267==    by 0x125320: _dl_start (rtld.c:583)
==1488267==    by 0x1240C7: ??? (in /builddir/build/BUILDROOT/glibc-2.39.9000-11.eln136.x86_64/lib64/ld-linux-x86-64.so.2)
==1488267== 
==1488267== 
==1488267== HEAP SUMMARY:
==1488267==     in use at exit: 0 bytes in 0 blocks
==1488267==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==1488267== 
==1488267== All heap blocks were freed -- no leaks are possible
==1488267== 
==1488267== Use --track-origins=yes to see where uninitialised values come from
==1488267== For lists of detected and suppressed errors, rerun with: -s
==1488267== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

It looks related to this upstream fix attempt:

commit a1735e0aa858f0c8b15e5ee9975bff4279423680
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Feb 25 16:03:26 2024 -0800

    x86_64: Suppress false positive valgrind error

    When strcmp-avx2.S is used as the default, elf/tst-valgrind-smoke fails
    with

    ==1272761== Conditional jump or move depends on uninitialised value(s)
    ==1272761==    at 0x4022C98: strcmp (strcmp-avx2.S:462)
    ==1272761==    by 0x400B05B: _dl_name_match_p (dl-misc.c:75)
    ==1272761==    by 0x40085F3: _dl_map_object (dl-load.c:1966)
    ==1272761==    by 0x401AEA4: map_doit (rtld.c:644)
    ==1272761==    by 0x4001488: _dl_catch_exception (dl-catch.c:237)
    ==1272761==    by 0x40015AE: _dl_catch_error (dl-catch.c:256)
    ==1272761==    by 0x401B38F: do_preload (rtld.c:816)
    ==1272761==    by 0x401C116: handle_preload_list (rtld.c:892)
    ==1272761==    by 0x401EDF5: dl_main (rtld.c:1842)
    ==1272761==    by 0x401A79E: _dl_sysdep_start (dl-sysdep.c:140)
    ==1272761==    by 0x401BEEE: _dl_start_final (rtld.c:494)
    ==1272761==    by 0x401BEEE: _dl_start (rtld.c:581)
    ==1272761==    by 0x401AD87: ??? (in */elf/ld.so)

    The assembly codes are:

       0x0000000004022c80 <+144>:   vmovdqu 0x20(%rdi),%ymm0
       0x0000000004022c85 <+149>:   vpcmpeqb 0x20(%rsi),%ymm0,%ymm1
       0x0000000004022c8a <+154>:   vpcmpeqb %ymm0,%ymm15,%ymm2
       0x0000000004022c8e <+158>:   vpandn %ymm1,%ymm2,%ymm1
       0x0000000004022c92 <+162>:   vpmovmskb %ymm1,%ecx
       0x0000000004022c96 <+166>:   inc    %ecx
    => 0x0000000004022c98 <+168>:   jne    0x4022c32 <strcmp+66>

    strcmp-avx2.S has 32-byte vector loads of strings which are shorter than
    32 bytes:

    (gdb) p (char *) ($rdi + 0x20)
    $6 = 0x1ffeffea20 "memcheck-amd64-linux.so"
    (gdb) p (char *) ($rsi + 0x20)
    $7 = 0x4832640 "core-amd64-linux.so"
    (gdb) call (int) strlen ((char *) ($rsi + 0x20))
    $8 = 19
    (gdb) call (int) strlen ((char *) ($rdi + 0x20))
    $9 = 23
    (gdb)

    It triggers the valgrind error.  The above code is safe since the loads
    don't cross the page boundary.  Update tst-valgrind-smoke.sh to accept
    an optional suppression file and pass a suppression file to valgrind when
    strcmp-avx2.S is the default implementation of strcmp.
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>

However, valgrind is supposed to have an interceptor for ld-linux-x86-64.so.2 that papers over this.

The x86-64-v3 error is caused by moving -march=x86-64-v3 from CFLAGS (not used for assembler files) to CC, I believe. Before, we (incorrectly) did not use the AVX2 strcmp in ld.so. Unfortunately, this is a must-fix bug because it does break valgrind.

The valgrind issue is now filed here (downstream only so far): https://issues.redhat.com/browse/RHEL-32735

rebased onto 114492e

2 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/f3a4ff6fef35462896e7ba9785c8b7ce

There were no changes here except to rebase tehe PR against the updated upstream tarball which contains the POWER10 fixes required for this build.

This still LGTM to I'm going to merge.

Pull-Request has been merged by codonell

a month ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/cbf94a212de248ec92e87a043fdb2f3a