WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
138420
Undefined reference to `environ' when linking libgtest.so on FreeBSD
https://bugs.webkit.org/show_bug.cgi?id=138420
Summary
Undefined reference to `environ' when linking libgtest.so on FreeBSD
Ting-Wei Lan
Reported
2014-11-05 06:25:53 PST
I got this error when compiling WebKit trunk with debug on FreeBSD: Linking CXX shared library ../../../lib/libgtest.so CMakeFiles/gtest.dir/__/__/ThirdParty/gtest/src/gtest-death-test.cc.o: In function `testing::internal::GetEnviron()': /usr/home/lantw44/webkit/source/WebKit/Source/ThirdParty/gtest/src/gtest-death-test.cc:846: undefined reference to `environ' It seems it is caused by the -Wl,--no-undefined flag added in Source/cmake/OptionsCommon.cmake. The environ symbol is not defined in libc.so.7, but it exists in crt1.o.
Attachments
Work around undefined reference error for gtest on FreeBSD
(1.38 KB, patch)
2014-11-15 00:15 PST
,
Ting-Wei Lan
no flags
Details
Formatted Diff
Diff
Work around undefined reference error for gtest on FreeBSD
(1.57 KB, patch)
2015-01-22 04:33 PST
,
Ting-Wei Lan
no flags
Details
Formatted Diff
Diff
Patch
(1.61 KB, patch)
2015-07-07 02:12 PDT
,
Ting-Wei Lan
no flags
Details
Formatted Diff
Diff
Patch
(2.44 KB, patch)
2015-07-15 10:17 PDT
,
Ting-Wei Lan
no flags
Details
Formatted Diff
Diff
Remove usage of environ in gtest
(3.16 KB, patch)
2016-01-01 10:29 PST
,
Ting-Wei Lan
no flags
Details
Formatted Diff
Diff
Remove usage of environ in gtest
(3.45 KB, patch)
2016-01-01 22:11 PST
,
Ting-Wei Lan
no flags
Details
Formatted Diff
Diff
Patch
(3.49 KB, patch)
2016-01-02 08:41 PST
,
Ting-Wei Lan
no flags
Details
Formatted Diff
Diff
Show Obsolete
(6)
View All
Add attachment
proposed patch, testcase, etc.
Ting-Wei Lan
Comment 1
2014-11-15 00:15:47 PST
Created
attachment 241660
[details]
Work around undefined reference error for gtest on FreeBSD
Ting-Wei Lan
Comment 2
2015-01-22 04:33:51 PST
Created
attachment 245137
[details]
Work around undefined reference error for gtest on FreeBSD
Ting-Wei Lan
Comment 3
2015-07-07 02:12:52 PDT
Created
attachment 256294
[details]
Patch
Martin Robinson
Comment 4
2015-07-07 10:08:12 PDT
Comment on
attachment 256294
[details]
Patch This bug should probably be fixed upstream and the fix should probably not leave symbols unresolved.
Ting-Wei Lan
Comment 5
2015-07-07 11:05:47 PDT
(In reply to
comment #4
)
> Comment on
attachment 256294
[details]
> Patch > > This bug should probably be fixed upstream and
The upstream project doesn't have this problem because they don't use -Wl,--no-undefined.
> the fix should probably not leave symbols unresolved.
I leave it unresolved because I can't find other ways to solve the problem. The environ symbol doesn't exist in any shared library, so it can't be resolved by adding -l arguments. I also tried to add crt1.o to the linking arguments, but it also doesn't work. If I use /usr/lib/crt1.o: ld: /usr/lib/crt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC /usr/lib/crt1.o: error adding symbols: Bad value clang++: error: linker command failed with exit code 1 (use -v to see invocation) If I use /usr/lib/gcrt1.o: ld: /usr/lib/gcrt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcrt1.o: error adding symbols: Bad value clang++: error: linker command failed with exit code 1 (use -v to see invocation) If I use /usr/lib/Scrt1.o: /usr/lib/Scrt1.o: In function `_start': /usr/src/lib/csu/amd64/crt1.c:(.text+0xa4): undefined reference to `__preinit_array_start' ld: /usr/lib/Scrt1.o: relocation R_X86_64_PC32 against undefined hidden symbol `__preinit_array_start' can not be used when making a shared object ld: final link failed: Bad value clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Martin Robinson
Comment 6
2015-07-07 11:25:11 PDT
(In reply to
comment #5
)
> (In reply to
comment #4
) > > Comment on
attachment 256294
[details]
> > Patch > > > > This bug should probably be fixed upstream and > > The upstream project doesn't have this problem because they don't use > -Wl,--no-undefined.
I think a proper fix upstream would be to not use environ based on some conditional compilation flag.
Ting-Wei Lan
Comment 7
2015-07-10 01:16:46 PDT
I sent a message to gtest upstream:
https://groups.google.com/forum/#!topic/googletestframework/wrrMj_fmXMc
I hope I will get a reply ...
Michael Catanzaro
Comment 8
2015-07-10 05:04:50 PDT
I don't think I quite understand the problem, what crt1.o is and why gtest does not link to it. Asking upstream to not use environ does not seem reasonable, and dropping use of --no-undefined does not seem desirable either.
Ting-Wei Lan
Comment 9
2015-07-10 05:36:11 PDT
crt1.o contains the entrypoint of a C program, _start function. _start function makes argc, argv, environ and possibly other initialization works, and calls main function. environ global variable is in crt1.o on FreeBSD. crt1.c, the file containing _start function:
http://svn.freebsd.org/base/releng/10.1/lib/csu/amd64/crt1.c
ignore_init.c, the file included by crt1.c and containing environ variable:
http://svn.freebsd.org/base/releng/10.1/lib/csu/common/ignore_init.c
When using a C compiler driver to make an executable, crt1.o and other crt*.o files are automatically added to the linker arguments. This can be found by running 'cc -v'. gtest doesn't link to it because it is a shared library. It is not an executable and it does not have a vaild entrypoint.
Ting-Wei Lan
Comment 10
2015-07-15 10:17:40 PDT
Created
attachment 256844
[details]
Patch
Michael Catanzaro
Comment 11
2015-12-31 14:50:43 PST
Comment on
attachment 256844
[details]
Patch This can't hurt anything, so go ahead, but please add a note to Source/ThirdParty/gtest/README.WebKit.
Ting-Wei Lan
Comment 12
2016-01-01 10:29:03 PST
Created
attachment 268072
[details]
Remove usage of environ in gtest
Ting-Wei Lan
Comment 13
2016-01-01 10:32:08 PST
I don't have commit privilege, so I have to get the patch reviewed again to add a note in Source/ThirdParty/gtest/README.WebKit.
Michael Catanzaro
Comment 14
2016-01-01 22:06:03 PST
Comment on
attachment 268072
[details]
Remove usage of environ in gtest View in context:
https://bugs.webkit.org/attachment.cgi?id=268072&action=review
> Source/ThirdParty/gtest/src/gtest-death-test.cc:861 > DeathTestAbort(String::Format("execve(%s, ...) in %s failed: %s",
Oops, should probably update this string too.
Ting-Wei Lan
Comment 15
2016-01-01 22:11:52 PST
Created
attachment 268085
[details]
Remove usage of environ in gtest
Michael Catanzaro
Comment 16
2016-01-02 08:04:13 PST
Comment on
attachment 268085
[details]
Remove usage of environ in gtest Thanks. In the future, please set cq? to request commit.
WebKit Commit Bot
Comment 17
2016-01-02 08:05:39 PST
Comment on
attachment 268085
[details]
Remove usage of environ in gtest Rejecting
attachment 268085
[details]
from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'validate-changelog', '--check-oops', '--non-interactive', 268085, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit /Volumes/Data/EWS/WebKit/Source/ThirdParty/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive). Full output:
http://webkit-queues.webkit.org/results/639848
Ting-Wei Lan
Comment 18
2016-01-02 08:41:19 PST
Created
attachment 268104
[details]
Patch
WebKit Commit Bot
Comment 19
2016-01-02 12:08:57 PST
Comment on
attachment 268104
[details]
Patch Clearing flags on attachment: 268104 Committed
r194501
: <
http://trac.webkit.org/changeset/194501
>
WebKit Commit Bot
Comment 20
2016-01-02 12:09:01 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug