Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 725304 - multilib.eclass: READELF override: meson refers to unprefixed 'readelf': No such file or directory: 'readelf': 'readelf'
Summary: multilib.eclass: READELF override: meson refers to unprefixed 'readelf': No s...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: https://archives.gentoo.org/gentoo-de...
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2020-05-25 11:21 UTC by Sergei Trofimovich (RETIRED)
Modified: 2020-05-25 20:47 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
net-libs:gssdp-1.2.2:20200525-111636.log (net-libs:gssdp-1.2.2:20200525-111636.log,41.37 KB, text/x-log)
2020-05-25 11:21 UTC, Sergei Trofimovich (RETIRED)
Details
emerge --info (emerge--info,19.50 KB, text/plain)
2020-05-25 11:22 UTC, Sergei Trofimovich (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-25 11:21:03 UTC
Failures are visible on a system with USE=-native-symlinks : https://wiki.gentoo.org/wiki/Project:Toolchain/use_native_symlinks

Example build failure is gssdp package:

FAILED: libgssdp/b06cb9c@@gssdp-1.2@sha/libgssdp-1.2.so.0.0.0.symbols
/usr/lib/python-exec/python3.7/meson --internal symbolextractor libgssdp/libgssdp-1.2.so.0.0.0 'libgssdp/b06cb9c@@gssdp-1.2@sha/libgssdp-1.2.so.0.0.0.symbols'
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.7/meson", line 11, in <module>
    load_entry_point('meson==0.52.1', 'console_scripts', 'meson')()
  File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 226, in main
    return run(sys.argv[1:], launcher)
  File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 215, in run
    return run_script_command(args[1], args[2:])
  File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 163, in run_script_command
    return module.run(script_args)
  File "/usr/lib/python3.7/site-packages/mesonbuild/scripts/symbolextractor.py", line 118, in run
    gen_symbols(libfile, outfile, options.cross_host)
  File "/usr/lib/python3.7/site-packages/mesonbuild/scripts/symbolextractor.py", line 105, in gen_symbols
    linux_syms(libfilename, outfilename)
  File "/usr/lib/python3.7/site-packages/mesonbuild/scripts/symbolextractor.py", line 61, in linux_syms
    pe, output = Popen_safe([readelfbin, '-d', libfilename])[0:2]
  File "/usr/lib/python3.7/site-packages/mesonbuild/mesonlib.py", line 1063, in Popen_safe
    stdout=stdout, stderr=stderr, **kwargs)
  File "/usr/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'readelf': 'readelf'
ninja: build stopped: subcommand failed.
 * ERROR: net-libs/gssdp-1.2.2::gentoo failed (compile phase):
 *   ninja -v -j4 -l0 -C /tmp/portage/net-libs/gssdp-1.2.2/work/gssdp-1.2.2-abi_x86_32.x86 failed
 *
 * Call stack:
 *     ebuild.sh, line  125:  Called src_compile
 *   environment, line 2915:  Called multilib-minimal_src_compile
 *   environment, line 1824:  Called multilib_foreach_abi 'multilib-minimal_abi_src_compile'
 *   environment, line 2074:  Called multibuild_foreach_variant '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_compile'
 *   environment, line 1759:  Called _multibuild_run '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_compile'
 *   environment, line 1757:  Called _multilib_multibuild_wrapper 'multilib-minimal_abi_src_compile'
 *   environment, line  563:  Called multilib-minimal_abi_src_compile
 *   environment, line 1818:  Called multilib_src_compile
 *   environment, line 2294:  Called meson_src_compile
 *   environment, line 1636:  Called eninja '-C' '/tmp/portage/net-libs/gssdp-1.2.2/work/gssdp-1.2.2-abi_x86_32.x86'
 *   environment, line 1177:  Called die
 * The specific snippet of code:
 *       "$@" || die "${nonfatal_args[@]}" "${*} failed"
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-25 11:21:46 UTC
Created attachment 641706 [details]
net-libs:gssdp-1.2.2:20200525-111636.log
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-25 11:22:16 UTC
Created attachment 641708 [details]
emerge --info
Comment 3 Mike Gilbert gentoo-dev 2020-05-25 12:36:15 UTC
meson supports overriding the readelf binary.

https://github.com/mesonbuild/meson/commit/4d3cce1532ccd6cbd5cdb6a3d12b076effedd6bd

And we export READELF in meson.eclass.

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2d332b15f52b5aadcdc85a6d84d1bcbd99db44f

The problem is that CHOST is set to i686-pc-linux-gnu when performing an x86 multilib build. The READELF variable would need to be set before meson_src_configure gets called.
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-25 12:45:54 UTC
'tc-getPROG READELF readelf >/dev/null' that statement looks like a no-op for me.  

It's probably a multilib.eclass issue then.
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-25 12:48:35 UTC
(In reply to Sergei Trofimovich from comment #4)
> 'tc-getPROG READELF readelf >/dev/null' that statement looks like a no-op
> for me.  
Oh, TIL it actually reefports the variable.

Let's assume it's a multilib.eclass problem.
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-25 12:56:12 UTC
Below seems to be enough to make gssdp build and pass tests:

$ git diff
diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
index b79718bb193..ed54568aa2d 100644
--- a/eclass/multilib.eclass
+++ b/eclass/multilib.eclass
@@ -468,6 +468,7 @@ multilib_toolchain_setup() {
 		NM
 		OBJDUMP
 		RANLIB
+		READELF
 		STRIP
 		PKG_CONFIG_LIBDIR
 		PKG_CONFIG_PATH
@@ -510,6 +511,7 @@ multilib_toolchain_setup() {
 		export NM="$(tc-getNM)" # Avoid 'nm', use '${CHOST}-nm'
 		export OBJDUMP="$(tc-getOBJDUMP)" # Avoid 'objdump', use '${CHOST}-objdump'
 		export RANLIB="$(tc-getRANLIB)" # Avoid 'ranlib', use '${CHOST}-ranlib'
+		export READELF="$(tc-getREADELF)" # Avoid 'readelf', use '${CHOST}-readelf'
 		export STRIP="$(tc-getSTRIP)" # Avoid 'strip', use '${CHOST}-strip'
 		export CHOST=$(get_abi_CHOST $1)
 		export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 1bc6cbbc108..b7a3c7a84af 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -85,6 +85,10 @@ tc-getNM() { tc-getPROG NM nm "$@"; }
 # @USAGE: [toolchain prefix]
 # @RETURN: name of the archiver indexer
 tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; }
+# @FUNCTION: tc-getREADELF
+# @USAGE: [toolchain prefix]
+# @RETURN: name of the archiver indexer
+tc-getREADELF() { tc-getPROG READELF readelf "$@"; }
 # @FUNCTION: tc-getOBJCOPY
 # @USAGE: [toolchain prefix]
 # @RETURN: name of the object copier
@@ -158,6 +162,10 @@ tc-getBUILD_NM() { tc-getBUILD_PROG NM nm "$@"; }
 # @USAGE: [toolchain prefix]
 # @RETURN: name of the archiver indexer for building binaries to run on the build machine
 tc-getBUILD_RANLIB() { tc-getBUILD_PROG RANLIB ranlib "$@"; }
+# @FUNCTION: tc-getBUILD_READELF
+# @USAGE: [toolchain prefix]
+# @RETURN: name of the archiver indexer for building binaries to run on the build machine
+tc-getBUILD_READELF() { tc-getBUILD_PROG READELF readelf "$@"; }
 # @FUNCTION: tc-getBUILD_OBJCOPY
 # @USAGE: [toolchain prefix]
 # @RETURN: name of the object copier for building binaries to run on the build machine
@@ -376,6 +384,7 @@ tc-env_build() {
 	NM=$(tc-getBUILD_NM) \
 	PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \
 	RANLIB=$(tc-getBUILD_RANLIB) \
+	READELF=$(tc-getBUILD_READELF) \
 	"$@"
 }

Will send for review later today.
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-25 13:13:40 UTC
Sent https://archives.gentoo.org/gentoo-dev/message/3304560f3b8d8f8259a2bfa83090c38f for review
Comment 8 Larry the Git Cow gentoo-dev 2020-05-25 20:47:13 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7bd13f6d55a51f2a1f4da69a41df7973fa7503cc

commit 7bd13f6d55a51f2a1f4da69a41df7973fa7503cc
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-05-25 12:59:54 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-05-25 20:47:07 +0000

    multilib.eclass: populate READELF
    
    For both multilib and non-multilib profiles binutils provides
    tools with native CHOST prefix only. For example on amd64 there
    is only 'x86_64-pc-linux-gnu-readelf' and 'readelf'.
    
    meson build system uses 'readelf' or $READELF binaries
    and relies on meson.eclass to populate READELF.
    
    The change overrides READELF and friends to 'x86_64-pc-linux-gnu-readelf'
    for multilib setup similar to other environment variables.
    
    Tested on net-libs/gssdp package.
    
    Closes: https://bugs.gentoo.org/725304
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 eclass/multilib.eclass | 2 ++
 1 file changed, 2 insertions(+)

Additionally, it has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ccdea417c4a259a03a745e3a977ac56827be5ae4

commit ccdea417c4a259a03a745e3a977ac56827be5ae4
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-05-25 12:58:50 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-05-25 20:47:07 +0000

    toolchain-funcs.eclass: export tc-get*READELF helpers
    
    Bug: https://bugs.gentoo.org/725304
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 eclass/toolchain-funcs.eclass | 9 +++++++++
 1 file changed, 9 insertions(+)