[OpenPower-Firmware] sbe fails to build, parsAndCutElf.py should be objcopy?

Klaus Heinrich Kiwi klaus at linux.vnet.ibm.com
Wed Feb 3 04:51:39 AEDT 2021



On 1/24/2021 11:11 PM, Stewart Smith wrote:
> On Fedora 33 (x86-64) current op-build (and v2.6) fails to build in the SBE code as it errors out in src/build/parsAndCutElf.py
> 
> Even with the below "fix" I still end up getting errors as we hit the
>      if( (startSize == 0) or (endSize == 0)):
>          exit(-1)
> chunk later. So... I'm trying to work out what this script does that couldn't be achieved with objcopy.
> 
> Anyone have any ideas?

Apologies for not answering earlier. I was only able to look at this today..


> --- a/src/build/parsAndCutElf.py
> +++ b/src/build/parsAndCutElf.py
> @@ -44,7 +45,11 @@ def parserElf(argv):
>       cmd = "readelf -S "+SBE_OUT
>       firstSection = ".header"
>       cmd1 = "nm "+SBE_OUT+" | grep  _sbe_image_size"
> +    print("cmd = {}".format(cmd))
> +    print("cmd1 = {}".format(cmd1))
>       output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
> +    startSize = 0
> +    endSize = 0
>       i = 0;
>       for line in output.stdout:
>           line = str(line.strip())
> 
> 

Good news is that the issue above is caused because parsAndCutElf is calling readelf from the distro,
while also using a LD_LIBRARY_PATH to pass the buildroot host library dir.. NORMALLY those would be
similar, and that's why this was never a problem.. Until Fedora 33 decided to link readelf with
openssl and kerberos libraries for some reason (??) and now the distro readelf can't find those
libraries in the buildroot host dir, which breaks readelf, which breaks the python script.

So the patch below fixes it:

diff --git a/openpower/package/sbe/sbe.mk b/openpower/package/sbe/sbe.mk
index 2f6d5b4b..59d7dfe4 100644
--- a/openpower/package/sbe/sbe.mk
+++ b/openpower/package/sbe/sbe.mk
@@ -14,8 +14,7 @@ SBE_INSTALL_IMAGES = YES
  SBE_INSTALL_TARGET = NO

  define SBE_BUILD_CMDS
-       SBE_COMMIT_ID=$(SBE_VERSION) $(MAKE) -C $(@D) \
-               LD_LIBRARY_PATH=$(HOST_DIR)/usr/lib \
+       SBE_COMMIT_ID=$(SBE_VERSION) $(HOST_MAKE_ENV) $(MAKE) -C $(@D) \
                 CROSS_COMPILER_PATH=$(PPE42_GCC_BIN) \
                 all
  endef


Bad news is that SBE is (as you're well aware) an 'interesting' mix of using host and ppe-specific
toolchains, and to make things worse there's apparently no consistency on finding what toolchain
is needed for what. So fixing this so that we'd only ever use buildroot-provided tools instead of distro-provided, so we better insulate in the future against similar things, is a non-trivial task.

Re your question on objcopy, I don't see a reason why it couldn't be used (even if it would still be
subject to the LD_LIBRARY_PATH thing), but I'll add SBE folks on cc just in case.

Thanks,

  -Klaus


-- 
Klaus Heinrich Kiwi <klaus at linux.vnet.ibm.com>


More information about the OpenPower-Firmware mailing list