Issue 121 in google-glog: Fix Apple clang & libc++ issues

289 views
Skip to first unread message

codesite...@google.com

unread,
Apr 2, 2012, 4:36:17 AM4/2/12
to googl...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 121 by heinrich...@gmail.com: Fix Apple clang & libc++ issues
http://code.google.com/p/google-glog/issues/detail?id=121

What steps will reproduce the problem?

1. Install recent Xcode command line tools.

Use

CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure

to configure.

What is the expected output?

Clean build, unit tests execute successfully.

What do you see instead?

Compile fails with

"./src/glog/stl_logging.h:77:11: fatal error: 'ext/slist' file not found"

What version of the product are you using?

glog SVN revision r109.

On what operating system?

Mac OS X 10.7.3, Apple clang version 3.1

Please provide any additional information below.

Even if the inclusion of the missing header is fixed, unit tests would
still fail. This is actually a separate issue, but I will include it here
since it is related to clang and libc++ as well:

In logging.cc, the use of std::strstream in the macro definition
DEFINE_CHECK_STROP_IMPL corrupts memory. This seems to be a general issue
with std::strstream producing garbage. Replacing strstream with the safer
stringstream fixes this issue.

I have attached a patch that fixes the issues reported here. In order to
compile glog on clang with libc++ use the configure command as mentioned
above:

CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure

then

make && make check

should execute successfully.

cheers,

Heinrich


Attachments:
clang_libcpp_patch.patch 3.9 KB

codesite...@google.com

unread,
Apr 2, 2012, 5:42:55 AM4/2/12
to googl...@googlegroups.com

Comment #1 on issue 121 by heinrich...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

I further removed strstream usage from logging.h.in. This is just a quick
fix, it's probably not optimal as binary sizes increases by a factor of at
least 2 (due to the inclusion of stringstream.h in logging.h.)

- h

Attachments:
further_replacement.patch 801 bytes

codesite...@google.com

unread,
Feb 4, 2013, 11:55:10 AM2/4/13
to googl...@googlegroups.com

Comment #2 on issue 121 by malcolm....@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

As far as I can see this compilation error is still present in the latest
SVN version, with the. I've applied the first patch above, and it fixes the
compilation errors using clang++ based on LLVM version 4.2 (this appears to
be the default for Mountain Lion 10.8.2 / latest XCode command line tools).
There are no warnings during compilation. However, `make check` fails as
follows:

$ make check
make logging_striplog_test_sh demangle_unittest_sh
signalhandler_unittest_sh
./src/logging_striplog_test.sh
In DBG mode; not checking strings
./src/logging_striplog_test.sh: line 76: 59433 Abort trap:
6 ./logging_striptest2 2> /dev/null
PASS
./demangle_unittest # force to create lt-demangle_unittest
make[1]: *** [demangle_unittest_sh] Segmentation fault: 11
make: *** [check-am] Error 2

Is there something I've missed? I'm starting a new project and extremely
keen to use Glog if possible but I also want to use clang++ with C++11
features. Is it possible to do both?

Cheers,

Malcolm

codesite...@google.com

unread,
Jul 27, 2013, 11:32:01 PM7/27/13
to googl...@googlegroups.com

Comment #3 on issue 121 by bobrober...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

The trunk version almost compiles in libc++ thanks to r119 and r134. I've
attached a very minor patch that makes it fully compile and pass all unit
tests with clang and libc++.

Attachments:
libc++.diff 737 bytes

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

codesite...@google.com

unread,
Oct 24, 2013, 5:10:01 AM10/24/13
to googl...@googlegroups.com

Comment #4 on issue 121 by hannessc...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

It would be great to have this patch in trunk. The current HEAD does not
compile under OS X 10.9. (Apple LLVM version 5.0 (clang-500.2.79) (based on
LLVM 3.3svn))

codesite...@google.com

unread,
Oct 24, 2013, 5:12:21 PM10/24/13
to googl...@googlegroups.com

Comment #5 on issue 121 by zhangyun...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

Does this patch (libc++.diff 737 bytes) help compilation on OS X 10.9?
Thanks!

codesite...@google.com

unread,
Oct 24, 2013, 5:20:32 PM10/24/13
to googl...@googlegroups.com

Comment #6 on issue 121 by zhangyun...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

Yes, it does. Patch the awesomeness into trunk!

codesite...@google.com

unread,
Oct 24, 2013, 5:23:24 PM10/24/13
to googl...@googlegroups.com

Comment #7 on issue 121 by hannessc...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

I can confirm that this patch fixes it.

codesite...@google.com

unread,
Nov 7, 2013, 4:54:07 PM11/7/13
to googl...@googlegroups.com

Comment #8 on issue 121 by carles.f...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

It woked for me too, on Mac OS X 10.9 and clang 5.0.0

codesite...@google.com

unread,
Nov 8, 2013, 2:36:39 PM11/8/13
to googl...@googlegroups.com

Comment #9 on issue 121 by carles.f...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

It worked for me too. Please apply it to r139

codesite...@google.com

unread,
Nov 18, 2013, 2:41:45 PM11/18/13
to googl...@googlegroups.com

Comment #10 on issue 121 by tom.ritc...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

This patch works for me too.

It'd be nice to fix this - particularly since you need to build the unit
test for make install to work...!

codesite...@google.com

unread,
Mar 5, 2014, 12:23:10 AM3/5/14
to googl...@googlegroups.com
Updates:
Status: Fixed

Comment #11 on issue 121 by shinichi...@gmail.com: Fix Apple clang & libc++
issues
http://code.google.com/p/google-glog/issues/detail?id=121

Fixed: https://code.google.com/p/google-glog/source/detail?r=142

Sorry for the latency and thanks for suggestions.

codesite...@google.com

unread,
Feb 1, 2015, 9:01:04 PM2/1/15
to googl...@googlegroups.com

Comment #12 on issue 121 by Antma...@gmail.com: Fix Apple clang & libc++
issues
https://code.google.com/p/google-glog/issues/detail?id=121

Did not work for me. I'm still getting an error.

codesite...@google.com

unread,
Feb 5, 2015, 7:30:17 PM2/5/15
to googl...@googlegroups.com

Comment #13 on issue 121 by drirr.g...@gmail.com: Fix Apple clang & libc++
issues
https://code.google.com/p/google-glog/issues/detail?id=121

It doesn't work for me either. I get:

In file included from src/stl_logging_unittest.cc:55:
./src/glog/stl_logging.h:56:11: fatal error: 'ext/slist' file not found
# include <ext/slist>

My compiler:

$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
Reply all
Reply to author
Forward
0 new messages