Page MenuHomeFreeBSD

installworld: handle ldd including preloaded objects
ClosedPublic

Authored by emaste on Apr 1 2022, 2:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 5, 6:29 PM
Unknown Object (File)
Fri, May 3, 8:07 AM
Unknown Object (File)
Thu, May 2, 3:21 AM
Unknown Object (File)
Thu, May 2, 3:21 AM
Unknown Object (File)
Sat, Apr 27, 1:10 PM
Unknown Object (File)
Fri, Apr 26, 11:56 PM
Unknown Object (File)
Fri, Apr 26, 3:04 AM
Unknown Object (File)
Thu, Apr 25, 6:14 PM

Details

Summary
The installworld target makes a temporary copy of binaries to be used
during the install.  Libraries that they depend on are also included,
found by using `ldd`.

After commit 0913953c9ed0 ldd started listing preloaded objects,
including [vdso], under a [preloaded] header.  Stop parsing ldd output
once we reach the preloaded section.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste requested review of this revision.Apr 1 2022, 2:04 PM
emaste created this revision.

Referenced commit 0913953c9ed0

cy added a subscriber: cy.

Works

This revision is now accepted and ready to land.Apr 1 2022, 2:13 PM

I missed the sort -u, [preloaded] is the first line of output

sort and unique library list after parsing

Still no good since we pass all $progs to one ldd invocation

just skip over [preloaded] and [vdso]

I see that.

Either:

1.multiple invocations of ldd (not preferred), or

  1. ignore everything between "[preloaded]" and the next line that contains /^\//, or
  2. simply ignore lines that begin with / or [ using awk

IMO options 1 & 2 are klunky. Option 3 is better but still inelegant, without overcomplicating it.

I can put printing of the preloaded objects under the option/env var, but I did not wanted to do that.

This revision is now accepted and ready to land.Apr 1 2022, 3:04 PM

Further to my previous comment, I'm thinking:

libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | \
    awk '$$1 !~ /:$$/ && $$1 !~ /^\[.*\]/ {print}' | sort -u | \
    while read line; do \
        set -- $$line; \
        if [ "$$2 $$3" != "not found" ]; then \
                echo $$2; \
        else \
                echo "Required library $$1 not found." >&2; \
                exit 1; \
        fi; \
    done); \

Or as a diff:

diff --git a/Makefile.inc1 b/Makefile.inc1
index 04c44d8e297b..2be0980e503d 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1366,7 +1366,8 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
                fi; \
            done); \
        if [ -z "${CROSSBUILD_HOST}" ] ; then \
-           libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
+         libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | \
+             awk '$$1 !~ /:$$/ && $$1 !~ /^\[.*\]/ {print}' | sort -u | \
                    while read line; do \
                        set -- $$line; \
                        if [ "$$2 $$3" != "not found" ]; then \
kevans added inline comments.
Makefile.inc1
1376

|| -> -o for test(1)

use a case statement to skip everything enclosed in square brackets

This revision now requires review to proceed.Apr 1 2022, 3:55 PM

The case construct is probably the most elegant solution.

This revision is now accepted and ready to land.Apr 1 2022, 4:01 PM

This vdso thing happens when building releng/12.3 as well. Edit: I suppose it will happen on any older builds but this branch is at least still supported.