Bug 236676 - lang/gcc8: Loader picks up wrong libstc++.so
Summary: lang/gcc8: Loader picks up wrong libstc++.so
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Gerald Pfeifer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-21 01:13 UTC by Peter C B Henderson
Modified: 2019-10-24 21:30 UTC (History)
0 users

See Also:


Attachments
Program where incorrect libstdc++ causes a failure. (351 bytes, text/plain)
2019-03-21 01:13 UTC, Peter C B Henderson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter C B Henderson 2019-03-21 01:13:06 UTC
Created attachment 203017 [details]
Program where incorrect libstdc++ causes a failure.

I'm not sure who's responsibility this is, but as it can effect any gcc8 user, I am reporting it here.

The loader is picking up /usr/local/lib/compat/libstdc++.so.6,rather than /usr/local/lib/gcc8/libstdc++.so.6.0.25.

"pkg which /usr/local/lib/compat/libstdc++.so.6" outputs:
/usr/local/lib/compat/libstdc++.so.6 was installed by package compat9x-amd64-9.3.903000.20170608

As a result, my test program "./gcc-ld-test" outputs:                                     
/usr/local/lib/compat/libstdc++.so.6: version GLIBCXX_3.4.11 required by /usr/home/peterh/ieee-754/test/gcc-ld-test not found

"ldd ./gcc-ld-test" outputs:
./gcc-ld-test:
        libstdc++.so.6 => /usr/local/lib/compat/libstdc++.so.6 (0x800837000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x800b3e000)
        libc.so.7 => /lib/libc.so.7 (0x800d4d000)
        libm.so.5 => /lib/libm.so.5 (0x801109000)

gcc-ld-test was compiled using:
gcc8 -D BAD_LD -lstdc++ -o gcc-ld-test gcc-ld-test.cpp

The -D BAD_LD turns on the failure.  I.e. without "-D BAD_LD" the program still need libstdc++ and still loads /usr/local/lib/compat/libstdc++.so.6, but runs without any problems.  The problem is triggered when I use boost format.

"pkg version" outputs:
gcc8-8.3.0                         =
compat9x-amd64-9.3.903000.20170608 ?
boost-libs-1.69.0_1                =

"uname -a" outputs:
FreeBSD 11.2-RELEASE-p9 #0 r343989: Mon Feb 11 17:52:41 AEDT 2019     root@hydrogen:/usr/obj/usr/src/sys/GENERIC  amd64

I was able to fix the problem, and hence run my program in one of two ways:

1) Use:
gcc8 -D BAD_LD -o gcc-ld-test gcc-ld-test.cpp /usr/local/lib/gcc8/libstdc++.a
The program then works and
"ldd ./gcc-ld-test" outputs:
./gcc-ld-test:
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x8008ef000)
        libc.so.7 => /lib/libc.so.7 (0x800afe000)

2) Use:
gcc8 -D BAD_LD -rpath=/usr/local/lib/gcc8 -lstdc++ -o gcc-ld-test gcc-ld-test
Again the program works and 
"ldd ./gcc-ld-test" outputs:
./gcc-ld-test:
        libstdc++.so.6 => /usr/local/lib/gcc8/libstdc++.so.6 (0x800822000)
        libc.so.7 => /lib/libc.so.7 (0x800bb7000)
        libm.so.5 => /lib/libm.so.5 (0x800f73000)
        libgcc_s.so.1 => /usr/local/lib/gcc8/libgcc_s.so.1 (0x8011a0000)
Comment 1 Gerald Pfeifer freebsd_committer 2019-03-23 15:49:08 UTC
Have you had a chance to look into 

  pkg info --pkg-message gcc8 

?  Does that address the issue you encountered?
Comment 2 Peter C B Henderson 2019-03-24 10:21:46 UTC
Re: "pkg info --pkg-message gcc8"
I didn't realize this option existed until now.

It does address the issue I encountered.

I apologize for putting you to this trouble.

Unfortunately, these messages tend to get lost in all the other output when doing portinstall's or portupgrade's, especially for ports such as gcc8 which are often installed during installation of other ports.
Comment 3 Gerald Pfeifer freebsd_committer 2019-10-24 21:30:55 UTC
Let's see that we can improve the usability aspect via addressing
bug #200171.

And no worries for missing the package note - we should be better
by not requiring one to begin with.