The use of environ causes linking failure when -Wl,--no-undefined is used on FreeBSD

150 views
Skip to first unread message

藍挺瑋

unread,
Jul 8, 2015, 12:39:45 PM7/8/15
to googletes...@googlegroups.com
This problem is found by compiling WebKit on FreeBSD because WebKit uses -Wl,--no-undefined by default. The environ symbol exists in crt1.o, but it does not exist in libc.so.7 on FreeBSD, which causes undefined reference error if -Wl,--no-undefined is used.

  https://bugs.webkit.org/show_bug.cgi?id=138420

Can we just use execv() instead of execve() in src/gtest-death-test.cc, so we don't need environ? The comment says we should avoid unsafe functions, so we can only use direct system calls. I think execv() should be safe, as it is just a simple wrapper that calls execve().

藍挺瑋

unread,
Jul 10, 2015, 10:28:06 AM7/10/15
to googletes...@googlegroups.com
A simple patch is attached. I don't know whether this is acceptable ...
gtest.patch

藍挺瑋

unread,
Apr 23, 2016, 2:22:18 PM4/23/16
to googletes...@googlegroups.com, 藍挺瑋
My patch is already committed to WebKit, but I still get no response on this
official mailing list ...

Ed Maste

unread,
Jan 5, 2017, 11:27:37 AM1/5/17
to 藍挺瑋, googletes...@googlegroups.com
On 23 April 2016 at 10:49, 藍挺瑋 <lan...@gmail.com> wrote:
> My patch is already committed to WebKit, but I still get no response on this
> official mailing list ...

We had the same issue in LLVM -- FreeBSD support was added to LLVM's
copy[1] in early 2014, and I submitted[2] the changes to googletest in
June 2014. The change was finally applied upstream in January 2015.

[1] https://reviews.llvm.org/D2632
[2] https://groups.google.com/forum/#!topic/googletestframework/aDr8j10KuxE

However, since then googletest has moved to github, so I'd suggest
opening an issue and pull request.
Reply all
Reply to author
Forward
0 new messages