Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros, build: override find-debuginfo location #210

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented Oct 2, 2024

Issue number:
N/A

Description of changes:
This fixes a regression where find-debuginfo now prefers objcopy in /usr/bin rather than the target-specific symlink placed ahead of it in $PATH. That happens because find-debuginfo now adds its own parent directory to $PATH in front of everything else.

Work around this by adding a find-debuginfo symlink to the debug helper directory, and override the macro so that find-debuginfo is called from that directory.

Also add a readelf symlink, since find-debuginfo calls it too.

Testing done:
Before, the output logs would show errors like this when building on x86_64 for aarch64:

  #14 133.7 find-debuginfo: starting
  #14 133.8 Extracting debug info from 9 files
  #14 134.9 objcopy: Unable to recognise the format of the input file `/home/builder/rpmbuild/BUILDROOT/bottlerocket-settings-plugins-0.0-0.1727497932.29b947  0bc.br1.x86_64/aarch64-bottlerocket-linux-gnu/sys-root/usr/lib/settings-plugins/aws-dev/libsettings.so'

After, the errors go away since the target-specific objcopy is being used.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

This fixes a regression where `find-debuginfo` now prefers `objcopy`
in `/usr/bin` rather than the target-specific symlink placed ahead of
it in $PATH. That happens because `find-debuginfo` now adds its own
parent directory to $PATH in front of everything else.

Work around this by adding a `find-debuginfo` symlink to the debug
helper directory, and override the macro so that `find-debuginfo` is
called from that directory.

Also add a `readelf` symlink, since `find-debuginfo` calls it too.

Signed-off-by: Ben Cressey <[email protected]>
@bcressey
Copy link
Contributor Author

bcressey commented Oct 2, 2024

This is what feels like the millionth time I've had to fix debuginfo extraction in our cross-compilation setup.

That said, we will now run find-debuginfo from a specially-prepared, target-specific directory with controlled symlinks that point to the correct binutils programs to use. So this change should be just about as self-contained and focused on the precise use case - debuginfo extraction - as is possible, without the negative side effects of cluttering $PATH during the build.

See bottlerocket-os/bottlerocket-core-kit#174 for a related fix that this helped to catch, after the cleanup in bottlerocket-os/twoliter#383.

@bcressey bcressey merged commit 84cfb19 into bottlerocket-os:develop Oct 2, 2024
@bcressey bcressey deleted the fix-debuginfo branch October 2, 2024 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants