Bug 1770 - circular dependencies prevent building on platforms without strlcpy, vasprintf
Summary: circular dependencies prevent building on platforms without strlcpy, vasprintf
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: 5.5p1
Hardware: All All
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_6
  Show dependency treegraph
 
Reported: 2010-05-12 10:53 AEST by Tom Lane
Modified: 2011-01-24 12:34 AEDT (History)
1 user (show)

See Also:


Attachments
openssh-pkcs11-helper-link.patch (903 bytes, text/plain)
2010-05-12 12:38 AEST, Darren Tucker
no flags Details
openssh-bug1770.patch (1.13 KB, text/plain)
2010-06-22 15:23 AEST, Darren Tucker
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Lane 2010-05-12 10:53:00 AEST
Building 5.5p1 on HPUX 10.20 (yeah, it's pretty ancient) fails here:

gcc -o ssh-pkcs11-helper ssh-pkcs11-helper.o ssh-pkcs11.o -L. -Lopenbsd-compat/ -L/usr/local/ssl-0.9.8n/lib  -lssh -lopenbsd-compat -lssh -lcrypto -lz -lxnet  -lsec
/usr/ccs/bin/ld: Unsatisfied symbols:
   strlcpy (code)
   vasprintf (code)
collect2: ld returned 1 exit status

The problem here seems to be circular dependencies between libssh and libopenbsd-compat
(because the latter depends on xstrdup which is defined in the former).  The link succeeds if I add another instance of -lopenbsd-compat at the end of the command.  That's a pretty crocky workaround though.  Maybe xstrdup ought to be moved to libopenbsd-compat?

FWIW, openssh 4.6p1 built successfully on this platform, so the problem's been introduced since then.  Another possibly useful datapoint is that ssh-pkcs11-helper is the only executable that exhibits a problem.
Comment 1 Darren Tucker 2010-05-12 12:38:58 AEST
Created attachment 1847 [details]
openssh-pkcs11-helper-link.patch

Only link libssh in once.
Comment 2 Darren Tucker 2010-05-12 12:46:18 AEST
Looks like the problem is that libssh is linked twice:

$(LD) -o $@ ssh-pkcs11-helper.o ssh-pkcs11.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
Comment 3 Darren Tucker 2010-05-12 16:50:54 AEST
Nope, I'm wrong.

After discussing it we've decided that fixing it properly is a lot of work and since it only impacts old or odd platforms (eg embedded) we're going to take the easy way out.

This has been committed and will be in the next release.  Thanks.
Comment 4 Tom Lane 2010-05-13 00:14:42 AEST
Sorry, that proposed patch does *not* fix it.  When I do that I get

/usr/ccs/bin/ld: Unsatisfied symbols:
   xstrdup (code)

You really do have a circular dependency here, and the only way to make it work with just rejiggering the link line is to mention both libraries twice.
Comment 5 Darren Tucker 2010-06-22 15:23:15 AEST
Created attachment 1882 [details]
openssh-bug1770.patch

Link against libraries twice (this is what was committed).
Comment 6 Darren Tucker 2010-06-22 15:27:23 AEST
Sorry, it wasn't clear from the bug history but that's exactly what we ended up doing (list both libraries twice).  I have attached the patch that was committed.

If it's still broken in the current snapshots (http://mindrot.org/openssh_snap/) then please reopen.
Comment 7 Damien Miller 2011-01-24 12:34:01 AEDT
Move resolved bugs to CLOSED after 5.7 release