Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Dec 2019 16:15:08 +0000
From:      bugzilla-noreply@freebsd.org
To:        toolchain@FreeBSD.org
Subject:   [Bug 220103] devel/glib20: ld-elf.so.1: /usr/local/lib/libglib-2.0.so.0: Undefined symbol "environ" (WITH_LLD_IS_LD)
Message-ID:  <bug-220103-29464-0OEWwLciBl@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-220103-29464@https.bugs.freebsd.org/bugzilla/>
References:  <bug-220103-29464@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D220103

Fr=C3=A9d=C3=A9ric Fauberteau <triaxx@NetBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |triaxx@NetBSD.org

--- Comment #46 from Fr=C3=A9d=C3=A9ric Fauberteau <triaxx@NetBSD.org> ---
Hi,

I am not sure if the bug is really related but I think I have the same
symptoms. I am using the pkgsrc framework (from NetBSD) to build glib-2.62.=
3 on
FreeBSD 12.0-RELEASE-p12. I configured pkgsrc to use the basesystem Clang
compiler:
$ /usr/bin/clang --version
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM
6.0.1)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin

The meson configuration process completes without error. But the build proc=
ess
produces the followings:
[93/1124] Linking target glib/libglib-2.0.so.0.6200.3.
FAILED: glib/libglib-2.0.so.0.6200.3=20
clang  -o glib/libglib-2.0.so.0.6200.3
'glib/4430778@@glib-2.0@sha/deprecated_gallocator.c.o'
[...]
 'glib/libcharset/6e4c96c@@charset@sta/localcharset.c.o' -I/usr/pkg/include
-I/usr/include -I/usr/pkg/include/python3.8 -L/usr/pkg/lib -L/usr/lib
-Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group
-Wl,-soname,libglib-2.0.so.0 -O2 -liconv -Wl,-R/usr/pkg/lib -Wl,-R/usr/lib
-Wl,-z,nodelete -Wl,-Bsymbolic-functions -Wl,-R/usr/pkg/lib
/usr/pkg/lib/libpcre.so -pthread -lintl -Wl,--end-group
/usr/bin/ld: error: undefined symbol: environ
>>> referenced by genviron.c
>>>               glib/4430778@@glib-2.0@sha/genviron.c.o:(g_listenv)

/usr/bin/ld: error: undefined symbol: environ
>>> referenced by genviron.c
>>>               glib/4430778@@glib-2.0@sha/genviron.c.o:(g_listenv)

/usr/bin/ld: error: undefined symbol: environ
>>> referenced by genviron.c
>>>               glib/4430778@@glib-2.0@sha/genviron.c.o:(g_get_environ)

/usr/bin/ld: error: undefined symbol: environ
>>> referenced by gspawn.c
>>>               glib/4430778@@glib-2.0@sha/gspawn.c.o:(fork_exec_with_fds)
clang: error: linker command failed with exit code 1 (use -v to see invocat=
ion)
ninja: build stopped: subcommand failed.
*** Error code 1

Stop.
bmake[1]: stopped in /usr/pkgsrc/devel/glib2
*** Error code 1

Stop.
bmake: stopped in /usr/pkgsrc/devel/glib2

I tried to build it using the Clang version provided by pkgsrc:
$ /usr/pkg/bin/clang --version
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/pkg/bin
Since the problem is a linking error, I added LDFLAGS.FreeBSD+=3D
-fuse-ld=3D/usr/pkg/bin/ld.lld to use the LLD version provided by pkgsrc:
$ /usr/pkg/bin/ld.lld --version
LLD 9.0.0 (compatible with GNU linkers)
But I get similar errors:
ld.lld: error: undefined symbol: environ
>>> referenced by genviron.c
>>>               glib/4430778@@glib-2.0@sha/genviron.c.o:(g_listenv)
>>> referenced by genviron.c
>>>               glib/4430778@@glib-2.0@sha/genviron.c.o:(g_listenv)
>>> referenced by genviron.c
>>>               glib/4430778@@glib-2.0@sha/genviron.c.o:(g_get_environ)
>>> referenced by gspawn.c
>>>               glib/4430778@@glib-2.0@sha/gspawn.c.o:(fork_exec_with_fds)
clang-9: error: linker command failed with exit code 1 (use -v to see
invocation)
ninja: build stopped: subcommand failed.
*** Error code 1

Stop.
bmake[1]: stopped in /usr/pkgsrc/devel/glib2
*** Error code 1

Stop.
bmake: stopped in /usr/pkgsrc/devel/glib2

By inspecting the object file, I got the following output:
$ readelf -s work/glib-2.62.3/output/glib/4430778\@\@glib-2.0\@sha/genviron=
.c.o
| grep environ
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS genviron.c
     7: 0000000000000005    17 OBJECT  LOCAL  DEFAULT    4
.L__func__.g_environ_getenv
     8: 0000000000000027    17 OBJECT  LOCAL  DEFAULT    4
.L__func__.g_environ_setenv
     9: 000000000000006b    19 OBJECT  LOCAL  DEFAULT    4
.L__func__.g_environ_unsetenv
    14: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND environ
    15: 0000000000000000   208 FUNC    GLOBAL DEFAULT    2 g_environ_getenv
    16: 00000000000000d0   424 FUNC    GLOBAL DEFAULT    2 g_environ_setenv
    17: 0000000000000280   264 FUNC    GLOBAL DEFAULT    2 g_environ_unsete=
nv
    19: 0000000000000590    20 FUNC    GLOBAL DEFAULT    2 g_get_environ

--=20
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-220103-29464-0OEWwLciBl>