Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 693850

Summary: app-misc/mc-4.8.22 with sys-libs/musl - interface.c:(.text+0xbea): undefined reference to `libintl_gettext'
Product: Gentoo Linux Reporter: Michael 'veremitz' Everitt <gentoo>
Component: Current packagesAssignee: Sergei Trofimovich (RETIRED) <slyfox>
Status: RESOLVED UPSTREAM    
Severity: normal CC: desktop-misc, polynomial-c
Priority: Normal Keywords: Bug
Version: unspecified   
Hardware: All   
OS: Linux   
URL: https://midnight-commander.org/ticket/3629
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: emerge --info
config.log
build.log
portage_config.log

Description Michael 'veremitz' Everitt 2019-09-09 02:24:58 UTC
Created attachment 589490 [details]
emerge --info

app-misc/mc-4.8.22 fails to compile on musl libc.

Seems to be fine on:
- alpine -> https://git.alpinelinux.org/aports/tree/main/mc/APKBUILD
- sabotage -> https://github.com/sabotage-linux/sabotage/blob/master/pkg/mc
- void -> https://github.com/void-linux/void-packages/blob/master/srcpkgs/mc/template

emerge --info attached.

Build log using portage to follow.
config.log from source build also to follow.
Comment 1 Michael 'veremitz' Everitt 2019-09-09 02:29:00 UTC
Created attachment 589492 [details]
config.log

config.log from source build
Comment 2 Michael 'veremitz' Everitt 2019-09-09 02:31:01 UTC
Created attachment 589494 [details]
build.log
Comment 3 Michael 'veremitz' Everitt 2019-09-09 02:32:28 UTC
Created attachment 589496 [details]
portage_config.log
Comment 4 Michael 'veremitz' Everitt 2019-09-09 02:34:43 UTC
https://imgur.com/OpuJ7ER - working screenshot
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-09 06:44:56 UTC
The failure here is:

interface.c:(.text+0xbea): undefined reference to `libintl_gettext'
/usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-musl/bin/ld: interface.c:(.text+0xc5c): undefined reference to `libintl_gettext'
/usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-musl/bin/ld: interface.c:(.text+0xc83): undefined reference to `libintl_gettext'
/usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-musl/bin/ld: interface.c:(.text+0xc96): undefined reference to `libintl_gettext'
/usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-musl/bin/ld: ./.libs/libinternal.a(interface.o): in function `mc_tmpdir':

You can work it around by using USE=-nls:

    $ USE=-nls emerge -v1 app-misc/mc

It's an upstream bug as plain './configure && make' on a source tarball fails the same. I suggest to solve it upstream.
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2019-09-09 07:30:18 UTC
virtual/libintl seems to suggest this should work:

     !elibc_musl? ( dev-libs/libintl[...] )

Is any special linking required with musl?
Comment 7 Michael 'veremitz' Everitt 2019-09-09 09:22:25 UTC
(In reply to Sergei Trofimovich from comment #5)
> The failure here is:
> 
> interface.c:(.text+0xbea): undefined reference to `libintl_gettext'
> /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> musl/bin/ld: interface.c:(.text+0xc5c): undefined reference to
> `libintl_gettext'
> /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> musl/bin/ld: interface.c:(.text+0xc83): undefined reference to
> `libintl_gettext'
> /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> musl/bin/ld: interface.c:(.text+0xc96): undefined reference to
> `libintl_gettext'
> /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> musl/bin/ld: ./.libs/libinternal.a(interface.o): in function `mc_tmpdir':
> 
> You can work it around by using USE=-nls:
> 
>     $ USE=-nls emerge -v1 app-misc/mc
> 
> It's an upstream bug as plain './configure && make' on a source tarball
> fails the same. I suggest to solve it upstream.

This seems correct for 4.8.22:-
https://github.com/sabotage-linux/sabotage/blob/07e6257f35a73878a7a11ca763b1614667928c48/pkg/mc#L23

but not necessarily for 4.8.23:-
https://github.com/void-linux/void-packages/blob/001833d4668685071d1b01fa8662edb00f8a6322/srcpkgs/mc/template#L6
and
https://git.alpinelinux.org/aports/tree/main/mc/APKBUILD#n20

so I can only assume it's fixed in 4.8.23.
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-09 18:46:10 UTC
(In reply to Michael 'veremitz' Everitt from comment #7)
> (In reply to Sergei Trofimovich from comment #5)
> > The failure here is:
> > 
> > interface.c:(.text+0xbea): undefined reference to `libintl_gettext'
> > /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> > musl/bin/ld: interface.c:(.text+0xc5c): undefined reference to
> > `libintl_gettext'
> > /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> > musl/bin/ld: interface.c:(.text+0xc83): undefined reference to
> > `libintl_gettext'
> > /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> > musl/bin/ld: interface.c:(.text+0xc96): undefined reference to
> > `libintl_gettext'
> > /usr/lib/gcc/x86_64-gentoo-linux-musl/8.2.0/../../../../x86_64-gentoo-linux-
> > musl/bin/ld: ./.libs/libinternal.a(interface.o): in function `mc_tmpdir':
> > 
> > You can work it around by using USE=-nls:
> > 
> >     $ USE=-nls emerge -v1 app-misc/mc
> > 
> > It's an upstream bug as plain './configure && make' on a source tarball
> > fails the same. I suggest to solve it upstream.
> 
> This seems correct for 4.8.22:-
> https://github.com/sabotage-linux/sabotage/blob/
> 07e6257f35a73878a7a11ca763b1614667928c48/pkg/mc#L23
> 
> but not necessarily for 4.8.23:-
> https://github.com/void-linux/void-packages/blob/
> 001833d4668685071d1b01fa8662edb00f8a6322/srcpkgs/mc/template#L6
> and
> https://git.alpinelinux.org/aports/tree/main/mc/APKBUILD#n20
> 
> so I can only assume it's fixed in 4.8.23.

Please provide a log from musl system where 4.8.23 works.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-09 21:46:33 UTC
Diffing build.log across glibc and musl systems we can see the delta that pulls in bundled gettext:

glibc-build.log:
  checking for GNU gettext in libc... yes
  checking whether to use NLS... yes
  checking where the gettext function comes from... libc
musl-build.log:
  checking for GNU gettext in libc... no
  checking for GNU gettext in libintl... no
  checking whether to use NLS... yes
  checking where the gettext function comes from... included intl directory

Relevant snippet from config.log:

glibc-config.log:
  configure:22364: checking for GNU gettext in libc
  configure:22384: x86_64-pc-linux-gnu-gcc -o conftest -march=sandybridge -mtune=sandybridge -maes --param=l1-cache-size=32 --param=l1-cache-line-size=64 --param=l2-cache-size=8192 -O2 -pipe -fdiagnostics-show-option -frecord-gcc-switches -Wall -Wextra -Wstack-protector -g    -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu conftest.c  >&5
  configure:22384: $? = 0
  configure:22393: result: yes

musl-config.log:
  configure:22364: checking for GNU gettext in libc
  configure:22384: x86_64-gentoo-linux-musl-gcc -o conftest -O2 -pipe -fdiagnostics-show-option -frecord-gcc-switches -g   -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu conftest.c  >&5
  /usr/lib/gcc/x86_64-gentoo-linux-musl/9.1.0/../../../../x86_64-gentoo-linux-musl/bin/ld: /dev/shm/portage/app-misc/mc-4.8.23-r1/temp/ccIBIbNB.o: warning: relocation against `_nl_domain_bindings' in read-only section `.text.startup'
  /usr/lib/gcc/x86_64-gentoo-linux-musl/9.1.0/../../../../x86_64-gentoo-linux-musl/bin/ld: /dev/shm/portage/app-misc/mc-4.8.23-r1/temp/ccIBIbNB.o: in function `main':
  /dev/shm/portage/app-misc/mc-4.8.23-r1/work/mc-4.8.23/conftest.c:165: undefined reference to `_nl_domain_bindings'
  /usr/lib/gcc/x86_64-gentoo-linux-musl/9.1.0/../../../../x86_64-gentoo-linux-musl/bin/ld: /dev/shm/portage/app-misc/mc-4.8.23-r1/work/mc-4.8.23/conftest.c:165: undefined reference to `_nl_msg_cat_cntr'
  /usr/lib/gcc/x86_64-gentoo-linux-musl/9.1.0/../../../../x86_64-gentoo-linux-musl/bin/ld: warning: creating a DT_TEXTREL in object
  collect2: error: ld returned 1 exit status
  configure:22384: $? = 1

  ...
  | #include <libintl.h>
  | 
  | extern int _nl_msg_cat_cntr;
  | extern int *_nl_domain_bindings;
  | int
  | main ()
  | {
  | bindtextdomain ("", "");
  | return * gettext ("") + * ngettext ("", "", 0) + _nl_msg_cat_cntr + *_nl_domain_bindings
  |   ;
  |   return 0;
  | }

  configure:22859: checking for GNU gettext in libintl
  configure:22887: x86_64-gentoo-linux-musl-gcc -o conftest -O2 -pipe -fdiagnostics-show-option -frecord-gcc-switches -g    -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu conftest.c  -lintl >&5
  /usr/lib/gcc/x86_64-gentoo-linux-musl/9.1.0/../../../../x86_64-gentoo-linux-musl/bin/ld: cannot find -lintl
  collect2: error: ld returned 1 exit status
  configure:22887: $? = 1

musl symbols (lack _nl_ symbols):
  # nm -D /usr/lib/libc.so | egrep 'gettext|ngettext|_nl_msg_cat_cntr|_nl_domain_bindings'
  00000000000207e0 T dcgettext
  0000000000020290 T dcngettext
  0000000000020800 T dgettext
  00000000000207f0 T dngettext
  00000000000256e0 T gettext
  00000000000256f0 T ngettext

glibc symbols:
  $ nm -D /lib64/libc.so.6 | egrep 'gettext|ngettext|_nl_msg_cat_cntr|_nl_domain_bindings'
  00000000000329c0 T __dcgettext
  0000000000032a00 T __dgettext
  00000000001d0268 B _nl_domain_bindings
  00000000001d0270 B _nl_msg_cat_cntr
  00000000000329c0 W dcgettext
  0000000000034380 W dcngettext
  0000000000032a00 W dgettext
  00000000000343c0 W dngettext
  0000000000032a40 W gettext
  0000000000034400 W ngettext

Thus included gettext does not work upstream and gettext detection does not trigger on musl.
Comment 10 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-09 22:05:38 UTC
Reliance on private symbols like
  extern int _nl_msg_cat_cntr;
  extern int *_nl_domain_bindings;
comes from m4/gettext.m4, which is
  # gettext.m4 serial 63 (gettext-0.18)
  dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
used by upstream source packaging machine.

The version is pinned by mc's configure.ac at:
  AM_GNU_GETTEXT([no-libtool], [need-ngettext])
  AM_GNU_GETTEXT_VERSION([0.18.1])

Upstream needs a port to gettext-0.19+.

The following workaround

  # git diff -U0 | cat
  --- a/Makefile.am
  +++ b/Makefile.am
  @@ -4 +4 @@ AUTOMAKE_OPTIONS = 1.5
  -SUBDIRS = intl po lib src doc contrib misc
  +SUBDIRS = po lib src doc contrib misc
  --- a/configure.ac
  +++ b/configure.ac
  @@ -275,2 +275,2 @@ dnl ############################################################################
  -AM_GNU_GETTEXT([no-libtool], [need-ngettext])
  -AM_GNU_GETTEXT_VERSION([0.18.1])
  +AM_GNU_GETTEXT([external], [need-ngettext])
  +AM_GNU_GETTEXT_VERSION([0.20])
  @@ -678 +677,0 @@ doc/hlp/sr/Makefile
  -intl/Makefile

makes ./configure to detect gettext but fails later at:

1. linking against libiconv fails (should use libc directly instead):

  CCLD     mc
/usr/lib/gcc/x86_64-gentoo-linux-musl/9.1.0/../../../../x86_64-gentoo-linux-musl/bin/ld: cannot find -liconv
collect2: error: ld returned 1 exit status

2. building locale files (probably some manual LINGUAS manipulation in the build file):

/usr/bin/gmsgfmt: error while opening "hr.1po" for reading: No such file or directory
make[3]: *** [Makefile:253: hr.gmo] Error 1
Comment 11 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-10 18:42:45 UTC
The following is enough to reproduce on glibc:
  $ ./configure --with-included-gettext && make

It's probably a https://midnight-commander.org/ticket/3629
Comment 12 Larry the Git Cow gentoo-dev 2019-09-11 21:44:20 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4939d79d562b3490794aac9d3875d1fdf9a60e92

commit 4939d79d562b3490794aac9d3875d1fdf9a60e92
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-09-11 21:41:15 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-09-11 21:44:13 +0000

    app-misc/mc: workaround linkage against internal gettext, bug #693850
    
    The underlying issue is lack of support of linking in static
    gettext into libmc.a due to a deficiency in m4/gettext.m4 (see
    upstream bug for more details).
    
    The workaround is to manually link bundled gettext into every
    final binary. It fixes default case for musl but does not fix
    the underlying issues. Let's leave fixing those to upstream.
    
    Reported-by: Michael 'veremitz' Everitt
    Bug: https://bugs.gentoo.org/693850
    Bug: https://midnight-commander.org/ticket/3629
    Package-Manager: Portage-2.3.75, Repoman-2.3.17
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 app-misc/mc/files/mc-4.8.23-gettext-test.patch | 54 +++++++++++++++++++++++++
 app-misc/mc/files/mc-4.8.23-gettext.patch      | 56 ++++++++++++++++++++++++++
 app-misc/mc/mc-4.8.23-r1.ebuild                |  2 +
 3 files changed, 112 insertions(+)