Bug 98316 - [11 regression] cc1plus doesn't link on Solaris 11.3
Summary: [11 regression] cc1plus doesn't link on Solaris 11.3
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P1 normal
Target Milestone: 11.0
Assignee: Rainer Orth
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: build
Depends on:
Blocks:
 
Reported: 2020-12-16 10:11 UTC by Rainer Orth
Modified: 2021-01-05 13:37 UTC (History)
3 users (show)

See Also:
Host:
Target: *-*-solaris2.11
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-12-16 00:00:00


Attachments
Initial patch (2.00 KB, patch)
2020-12-16 13:19 UTC, Rainer Orth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2020-12-16 10:11:47 UTC
Even with PR c++/98315 hacked around, Solaris 11.3 (only) bootstrap is still
broken:

Undefined			first referenced
 symbol  			    in file
__xnet_connect                      ../libcody/libcody.a(netclient.o)
__xnet_socket                       ../libcody/libcody.a(netclient.o)
__xnet_getaddrinfo                  ../libcody/libcody.a(netclient.o)
freeaddrinfo                        ../libcody/libcody.a(netclient.o)
gai_strerror                        ../libcody/libcody.a(netclient.o)
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[3]: *** [/vol/gcc/src/hg/master/local/gcc/cp/Make-lang.in:136: cc1plus] Error 1

Before Solaris 11.4 folded libsocket and libnsl into libc, one needed to link
with both for the socket functions.  The same issue exists with the other use
of $(LIBCODY) in c++tools/Makefile.in.

We already have 4 instances of the libsocket/libnsl check in the tree:

  gotools/configure.ac
  libcc1/configure.ac
  libgo/configure.ac
  libphobos/m4/druntime/libraries.m4

Instead of adding yet two others, we could make use of the autoconf-archive's
m4/ax_lib_socket_nsl.m4 (AX_LIB_SOCKET_NSL).
Comment 1 ro@CeBiTec.Uni-Bielefeld.DE 2020-12-16 10:19:17 UTC
Besides, currently libcody.a (and, once this PR is fixed, libsocket and
libnsl) are linked into every backend instead of just into cc1plus.  I
believe this should change, just like f951 is the only user of $(ZLIB)
(and $(ZLIBINC)).
Comment 2 Rainer Orth 2020-12-16 13:19:11 UTC
Created attachment 49778 [details]
Initial patch

The attach has only been lightly tested so far: it allowed cc1plus to link on
Solaris 11.3, bootstrap still running.
Comment 3 Nathan Sidwell 2020-12-16 14:24:40 UTC
Looks good, and separating out cc1plus' libraries from other executables is goodness.

do you want to take this bug?
Comment 4 Rainer Orth 2020-12-16 14:32:12 UTC
That's easiest, I guess.  With one minor addition (gcc/objcp/Make-lang.in needs
the same treatment), the Solaris 11.3 build completed successfully; make check
still running.

I'll try the patch on Solaris 11.4 and Linux/x86_64 tonight, then post it.
Comment 5 Rainer Orth 2020-12-17 12:23:27 UTC
Final patch posted.
Comment 6 GCC Commits 2021-01-05 10:32:51 UTC
The master branch has been updated by Rainer Orth <ro@gcc.gnu.org>:

https://gcc.gnu.org/g:a20893cf6b95f60f5319b2196621acc65180125c

commit r11-6457-ga20893cf6b95f60f5319b2196621acc65180125c
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue Jan 5 11:32:31 2021 +0100

    build: libcody: Link with -lsocket -lnsl if necessary [PR98316]
    
    With the introduction of C++20 modules and libcody, cc1plus and
    cc1objplus gained a dependency on the socket functions.  Before those
    were merged into libc in Solaris 11.4, one needed to link with -lsocket -lnsl
    on Solaris, so that merge broke the Solaris 11.3 build.
    
    While we already have 4 different checks for those libraries in the
    tree, I decided to import autoconf-archive's AX_LIB_SOCKET_NSL macro
    instead.  At the same time, the patch only links libcody and the
    networking libs where needed (cc1plus, cc1objplus).
    
    Bootstrapped without regressions on i386-pc-solaris2.11 (Solaris 11.3
    and 11.4), sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.
    
    2020-12-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
    
            c++tools:
            PR c++/98316
            * configure.ac: Include ../config/ax_lib_socket_nsl.m4.
            (NETLIBS): Determine using AX_LIB_SOCKET_NSL.
            * configure: Regenerate.
            * Makefile.in (NETLIBS): Define.
            (g++-mapper-server$(exeext)): Add $(NETLIBS).
    
            gcc/objcp:
            PR c++/98316
            * Make-lang.in (cc1objplus$(exeext)): Add $(CODYLIB), $(NETLIBS).
    
            gcc/cp:
            PR c++/98316
            * Make-lang.in (cc1plus$(exeext)): Add $(CODYLIB), $(NETLIBS).
    
            gcc:
            PR c++/98316
            * configure.ac (NETLIBS): Determine using AX_LIB_SOCKET_NSL.
            * aclocal.m4, configure: Regenerate.
            * Makefile.in (NETLIBS): Define.
            (BACKEND): Remove $(CODYLIB).
    
            config:
            PR c++/98316
            * ax_lib_socket_nsl.m4: Import from autoconf-archive.
Comment 7 Rainer Orth 2021-01-05 10:33:30 UTC
Fixed for GCC 11.
Comment 8 Nathan Sidwell 2021-01-05 13:37:03 UTC
thanks Rainer!