gitfredy / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

Fix Apple clang & libc++ issues #121

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by heinrich...@gmail.com on 2 Apr 2012 at 8:35

Attachments:

GoogleCodeExporter commented 9 years ago
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

Original comment by heinrich...@gmail.com on 2 Apr 2012 at 9:42

Attachments:

GoogleCodeExporter commented 9 years ago
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

Original comment by malcolm....@gmail.com on 4 Feb 2013 at 4:55

GoogleCodeExporter commented 9 years ago
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++.

Original comment by bobrober...@gmail.com on 28 Jul 2013 at 3:31

Attachments:

GoogleCodeExporter commented 9 years ago
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))

Original comment by hannessc...@gmail.com on 24 Oct 2013 at 9:09

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

Original comment by zhangyun...@gmail.com on 24 Oct 2013 at 9:12

GoogleCodeExporter commented 9 years ago
Yes, it does. Patch the awesomeness into trunk!

Original comment by zhangyun...@gmail.com on 24 Oct 2013 at 9:20

GoogleCodeExporter commented 9 years ago
I can confirm that this patch fixes it.

Original comment by hannessc...@gmail.com on 24 Oct 2013 at 9:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It worked for me too. Please apply it to r139

Original comment by carles.f...@gmail.com on 8 Nov 2013 at 7:36

GoogleCodeExporter commented 9 years ago
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...!

Original comment by tom.ritc...@gmail.com on 18 Nov 2013 at 7:40

GoogleCodeExporter commented 9 years ago
Fixed: https://code.google.com/p/google-glog/source/detail?r=142

Sorry for the latency and thanks for  suggestions.

Original comment by shinichi...@gmail.com on 5 Mar 2014 at 5:22

GoogleCodeExporter commented 9 years ago
Did not work for me.  I'm still getting an error.

Original comment by Antma...@gmail.com on 2 Feb 2015 at 2:00

GoogleCodeExporter commented 9 years ago
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/MacO
SX.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

Original comment by drirr.g...@gmail.com on 6 Feb 2015 at 12:30

GoogleCodeExporter commented 9 years ago
I can confirm that this is still an issue on OSX 10.10 with the latest version 
of Xcode command line tools.

Original comment by lgtorre...@gmail.com on 12 Mar 2015 at 12:04