Bug 129223 - Build breaking due to linking error on clang with libc++
Summary: Build breaking due to linking error on clang with libc++
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-22 19:16 PST by Rajaram Gaunker
Modified: 2014-06-04 00:50 PDT (History)
4 users (show)

See Also:


Attachments
Patch (3.27 KB, patch)
2014-02-22 19:24 PST, Rajaram Gaunker
no flags Details | Formatted Diff | Diff
config.log file (97.39 KB, text/x-log)
2014-02-24 01:49 PST, Rajaram Gaunker
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rajaram Gaunker 2014-02-22 19:16:30 PST
Linking errors due to absence of some methonds in libc++. These functions are present in libsupc++.
Linking with libsupc++ fixes these problems.

  CXXLD  Programs/TestWebKitAPI/WebKit2/TestWebKit2
/usr/bin/ld: Libraries/.libs/../../Source/ThirdParty/gtest/src/.libs/Libraries_libgtest_la-gtest-all.o: undefined reference to symbol '__cxa_bad_typeid@@CXXABI_1.3'
/usr/bin/ld: note: '__cxa_bad_typeid@@CXXABI_1.3' is defined in DSO /home/rajaram/os/gcc_install_root/lib64//libstdc++.so.6 so try adding it to the linker command line


There are some missing $(ATSPI2_LIBS) flags which were causing build break.

/home/rajaram/os/webkit_deps/lib/libatk-bridge-2.0.so.0: undefined reference to `atspi_is_initialized'
/home/rajaram/os/webkit_deps/lib/libatk-bridge-2.0.so.0: undefined reference to `atspi_set_main_context'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Programs/TestWebKitAPI/WTF/TestWTF] Error 1
make[1]: Leaving directory `/home/rajaram/os/WebKit/WebKitBuild/Release'
make: *** [all] Error 2
Comment 1 Rajaram Gaunker 2014-02-22 19:24:53 PST
Created attachment 224989 [details]
Patch
Comment 2 Rajaram Gaunker 2014-02-23 09:48:19 PST
gtk and gtk-w2 breaks are fixed in another change set attached with https://bugs.webkit.org/show_bug.cgi?id=129229
Comment 3 Martin Robinson 2014-02-23 20:29:05 PST
"Libsupc++ is a support library for g++ that contains functions dealing with run-time type information (RTTI) and exception handling. If you attempt to use either exceptions or RTTI in a C++ kernel you have compiled with a GCC Cross-Compiler you will also need the libsupc++ library." (quoting from http://wiki.osdev.org/Libsupcxx). We shouldn't be using exceptions or RTTI in WebKit, so perhaps this fix isn't correct.

I don't see anywhere that atspi_is_initialized is in WebKit, so it's quite likely that the missing symbols might be a bug in your packages.
Comment 4 Zan Dobersek 2014-02-24 01:41:13 PST
How are you configuring the WebKitGTK+ build?
What compiler are you using? What OS/distribution?
Can you please attach the config.log file?
Comment 5 Rajaram Gaunker 2014-02-24 01:48:02 PST
uname -a : Linux saqi 3.5.0-43-generic #66~precise1-Ubuntu SMP Thu Oct 24 14:52:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

 $CXX --version
clang version 3.5 (http://llvm.org/git/clang.git a7b48ed6e362947101b732f840405b784bf185e0) (http://llvm.org/git/llvm.git f39297678b212ab5ee7885474762fc8c3f6c370f)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$CC --version
clang version 3.5 (http://llvm.org/git/clang.git a7b48ed6e362947101b732f840405b784bf185e0) (http://llvm.org/git/llvm.git f39297678b212ab5ee7885474762fc8c3f6c370f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Comment 6 Rajaram Gaunker 2014-02-24 01:49:27 PST
Created attachment 225045 [details]
config.log file

Attaching config.log file.
Comment 7 Rajaram Gaunker 2014-02-24 01:56:08 PST
gtest uses RTTI.

/WebKit/Source/ThirdParty (master)$ grep -r typeid *
gtest/include/gtest/internal/gtest-type-util.h.pump:  const char* const name = typeid(T).name();
gtest/include/gtest/internal/gtest-type-util.h.pump:  // gcc's implementation of typeid(T).name() mangles the type name,
gtest/include/gtest/internal/gtest-type-util.h:  const char* const name = typeid(T).name();
gtest/include/gtest/internal/gtest-type-util.h:  // gcc's implementation of typeid(T).name() mangles the type name,
gtest/include/gtest/internal/gtest-port.h:// both the typeid and dynamic_cast features are present.
gtest/include/gtest/internal/gtest-port.h:  GTEST_CHECK_(typeid(*base) == typeid(Derived));
Comment 8 Zan Dobersek 2014-02-24 12:37:04 PST
The imported gtest code is quite old, 1.5.0 was released in April 2010.

Still, I can build gtest with Clang 3.4 and libc++ 1.0 (r199600) after applying a small patch:

diff --git a/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h b/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h
index e8c6ae0..3b09af1 100644
--- a/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h
+++ b/Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h
@@ -197,7 +197,7 @@
 #define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/"
 
 // Determines the version of gcc that is used to compile this.
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
 // 40302 means version 4.3.2.
 #define GTEST_GCC_VER_ \
     (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
Comment 9 Csaba Osztrogonác 2014-06-04 00:50:21 PDT
Comment on attachment 224989 [details]
Patch

Cleared review? from attachment 224989 [details] so that this bug does not appear in http://webkit.org/pending-review.  If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).