Page MenuHomeFreeBSD

Add LIB_CXX so that c++ libraries will use CXX to link.
ClosedPublic

Authored by bdrewery on Mar 10 2015, 7:18 PM.
Tags
None
Referenced Files
F82675230: D2039.diff
Wed, May 1, 12:35 PM
Unknown Object (File)
Mar 22 2024, 8:56 PM
Unknown Object (File)
Mar 22 2024, 8:56 PM
Unknown Object (File)
Mar 22 2024, 8:56 PM
Unknown Object (File)
Mar 22 2024, 8:56 PM
Unknown Object (File)
Mar 8 2024, 12:34 PM
Unknown Object (File)
Jan 19 2024, 11:07 PM
Unknown Object (File)
Jan 5 2024, 4:53 PM
Subscribers

Details

Summary

This fixes c++ libraries not implicitly linking in libc++. This is
generally not an issue because the final linking with the compiled binary
will involve CXX via PROG_CXX or other means. It is however
inconsistent with libraries implicitly linking in libc and problematic
for trying to build libraries with '-z defs' to ensure all direct
dependencies are linked in.

libatf-c++ is currently the only consumer of this new feature. Its
before and after direct-linkage is shown below:

Before:
/usr/lib/private/libatf-c++.so.2:

libatf-c.so.1 => /usr/lib/private/libatf-c.so.1 (0x80161e000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x801835000)
libc.so.7 => /lib/libc.so.7 (0x800822000)

After:
/usr/lib/private/libatf-c++.so.2:

libatf-c.so.1 => /usr/lib/private/libatf-c.so.1 (0x80161e000)
libc++.so.1 => /usr/lib/libc++.so.1 (0x801835000)
libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x801af5000)
libm.so.5 => /lib/libm.so.5 (0x801d13000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x801f3d000)
libc.so.7 => /lib/libc.so.7 (0x800822000)

While here, unduplicate the linker line for handling of NM and unhide
the linker execution line.

Sponsored by: EMC / Isilon Storage Division

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

bdrewery retitled this revision from to Add LIB_CXX so that c++ libraries will use CXX to link..
bdrewery updated this object.
bdrewery edited the test plan for this revision. (Show Details)
bdrewery added reviewers: imp, bapt.

I used ldd -a for that example.

I find it strange libm is linked in there. I don't see any obvious reason for it to be. readelf -a libatf-c++.so.2|grep UND doesn't show any libm symbols that I can tell of, and the libatf consumers don't have -lm either.

In D2039#5, @bdrewery wrote:

I find it strange libm is linked in there. I don't see any obvious reason for it to be. readelf -a libatf-c++.so.2|grep UND doesn't show any libm symbols that I can tell of, and the libatf consumers don't have -lm either.

Found it. freebsd::Link::ConstructJob in contrib/llvm/tools/clang/lib/Driver/Tools.cpp forces -lm with c++(1).

share/mk/bsd.lib.mk
225 ↗(On Diff #4169)

This is an interesting construct. NM should always be defined, which makes this unnecessary. It is unrelated to the change at hand in any event. I'm not sure why the current code has this construct other than historical reasons. share/mk/sys.mk sets this unconditionally.

In D2039#7, @imp wrote:

This is an interesting construct. NM should always be defined, which makes this unnecessary. It is unrelated to the change at hand in any event. I'm not sure why the current code has this construct other than historical reasons. share/mk/sys.mk sets this unconditionally.

I made 2 unrelated changes. I normally make individual commits. I figured it would be simpler to bunch into 1 review for discussion.

Note I also made the linker line non-quiet to be consistent with compilation lines. I constantly wonder what the linker line is doing.

share/mk/bsd.lib.mk
225 ↗(On Diff #4169)

Ok, I'll remove this piece.

share/mk/bsd.lib.mk
225 ↗(On Diff #4169)

It isn't so much the unrelated part as the 'NM is always defined so we don't need to play games like this at all' bit I was hoping would be the take a way message :)

share/mk/bsd.lib.mk
225 ↗(On Diff #4169)

Yeah I understand. I'm just waking up and misread. How do you feel about the rest?

share/mk/bsd.lib.mk
225 ↗(On Diff #4169)

The rest is fine. A slightly unorthodox constrict, but nothing to be too worried about and better than many alternatives...

Fix build race and remove unneeded NM variable.

imp edited edge metadata.

I think this is golden now. Could be done as two separate commits or one.

This revision is now accepted and ready to land.Mar 16 2015, 11:20 PM
bdrewery updated this revision to Diff 4258.

Closed by commit rS280179 (authored by @bdrewery).