Does anybody understand waf's linking libraries?

Hal Murray hmurray at megapathdsl.net
Wed Sep 4 01:14:42 UTC 2019


Context is issue #615

The system is NetBSD 7.2, old but still supported.

It has a newer OpenSSL installed in /usr/pkg/
/usr/include/openssl/opensslv.h:# define OPENSSL_VERSION_NUMBER  0x1000115fL
/usr/pkg/include/openssl/opensslv.h:# define OPENSSL_VERSION_NUMBER  
0x1000210fL
The old version doesn't support ALPN.

The symptom is that build is finding the new includes but linking with the old 
libraries.

linking ntpd:
ntpd/nts_server.c.1.o: In function `nts_server_init':
/home/murray/ntpsec/raw/bob2/main/../../ntpd/nts_server.c:107: undefined 
reference to `SSL_CTX_set_alpn_select_cb'
(and several others)

wscript contains:
    elif ctx.env.DEST_OS == "netbsd":
        ctx.env.PLATFORM_INCLUDES = ["/usr/pkg/include"]
        ctx.env.PLATFORM_LIBPATH = ["/usr/lib", "/usr/pkg/lib"]

from ./waf build -v
[79/98] Linking bob2/main/ntpd/ntpd
17:51:03 runner ['/usr/bin/gcc', '-pie', 'ntpd/ntp_config.c.5.o', 
'ntpd/ntp_io.c.5.o', 'ntpd/ntp_loopfilter.c.5.o', 'ntpd/ntp_packetstamp.c.5.o',
 'ntpd/ntp_peer.c.5.o', 'ntpd/ntp_proto.c.5.o', 'ntpd/ntp_sandbox.c.5.o', 
'ntpd/ntp_scanner.c.5.o', 'ntpd/ntp_signd.c.5.o', 'ntpd/ntp_timer.c.5.o', 
'ntpd/ntp_dns.c.5.o', 'ntpd/ntpd.c.5.o', 'bob2/host/ntpd/ntp_parser.tab.c.5.o',
 'ntpd/ntp_control.c.1.o', 'ntpd/ntp_filegen.c.1.o', 'ntpd/ntp_leapsec.c.1.o', 
'ntpd/ntp_monitor.c.1.o', 'ntpd/ntp_recvbuff.c.1.o', 
'ntpd/ntp_restrict.c.1.o', 'ntpd/ntp_util.c.1.o', 'ntpd/nts.c.1.o', 
'ntpd/nts_server.c.1.o', 'ntpd/nts_client.c.1.o', 'ntpd/nts_cookie.c.1.o', 
'ntpd/nts_extens.c.1.o', 'ntpd/ntp_refclock.c.3.o', 'ntpd/ntp_wrapdate.c.3.o', 
'ntpd/refclock_conf.c.3.o', 'ntpd/refclock_nmea.c.4.o', '-o', 
'/home/murray/ntpsec/raw/bob2/main/ntpd/ntpd', '-Wl,-Bstatic', '-Llibaes_siv', 
'-Llibntp', '-laes_siv', '-lntp', '-Wl,-Bdynamic', '-lcrypto', '-lssl', '-lm', 
'-lrt', '-lpthread', '-ldns_sd', '-Wl,-z,now', '-Wl,-z,relro']

There is no -L/usr/pkg/lib in there.

If I comment out the INCLUDES line is wscript ntpd builds.  ldd shows it using 
the old crypto.so
bob2/main/ntpd/ntpd:
        -lcrypto.8 => /usr/lib/libcrypto.so.8
...

But now ntpd.so is broken:
  File "/home/murray/ntpsec/raw/wafhelpers/bin_test.py", line 11, in <module>
    import ntp.util
  File "/home/murray/ntpsec/raw/bob2/main/tests/pylib/ntp/util.py", line 16, 
in <module>
    import ntp.ntpc
ImportError: Shared object "libcrypto.so.1.0.0" not found

./bob2/main/pylib/ntpc.so:
        -lpython2.7.1.0 => /usr/lib/libpython2.7.so.1.0
        -lutil.7 => /usr/lib/libutil.so.7
        -lgcc_s.1 => /usr/lib/libgcc_s.so.1
        -lc.12 => /usr/lib/libc.so.12
        -lm.0 => /usr/lib/libm.so.0
        -lpthread.1 => /usr/lib/libpthread.so.1
        -lrt.1 => /usr/lib/librt.so.1
        -lcrypto.1.0.0 => not found

This time, it does have -L/usr/pkg/lib

[61/98] Linking bob2/main/pylib/ntpc.so
18:02:23 runner ['/usr/bin/gcc', '-shared', '-pthread', '-pthread', 
'-Wl,--export-dynamic', 'libntp/pymodule.c.2.o', 'libntp/assert.c.2.o', 
'libntp/clockwork.c.2.o', 'libntp/emalloc.c.2.o', 'libntp/hextolfp.c.2.o', 
'libntp/lib_strbuf.c.2.o', 'libntp/msyslog.c.2.o', 
'libntp/ntp_calendar.c.2.o', 'libntp/ntp_random.c.2.o', 
'libntp/prettydate.c.2.o', 'libntp/statestr.c.2.o', 'libntp/systime.c.2.o', 
'libntp/timespecops.c.2.o', '-o', '/home/murray/ntpsec/raw/bob2/main/pylib/ntpc
.so', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-L/usr/pkg/lib', '-lpython2.7', 
'-lutil', '-lm', '-lpython2.7', '-lutil', '-lm', '-lm', '-lrt', '-lcrypto', 
'-Wl,-z,now', '-Wl,-z,relro']

If I change the LIBPATH line to:
        ctx.env.PLATFORM_LIBPATH = ["/usr/lib"]
and rebuild, I get the same error.

The -L/usr/pkg/lib is still in the load command.

Anybody know where it is coming from?  I can't find the string /usr/pkg/lib 
anyplace else in our code.  I assume waf is doing some magic.

I'll be happy with either old or new version.


-- 
These are my opinions.  I hate spam.





More information about the devel mailing list