lizhanhui / typhoon-blade

Automatically exported from code.google.com/p/typhoon-blade
0 stars 1 forks source link

Too many strict compiler flags that even standard C++ lib under Mac OS X does not pass build check #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When I use a simple BUILD file:

c_binary(
    name='a',
    srcs=['a.cc'],
    deps=['#pthread','#dl'],
)

to build a simple C++ program 

#include <iostream>

int main() {
  std::cout << "Hello World!\n";
  return 0;
}

on my Mac OS X with XCode 4.6 using the following command:

~/blade build --verbose

I can see the command by blade to invoke g++:

$g++ -o a.cc.o -c -Wno-invalid-offsetof -Woverloaded-virtual -Wnon-virtual-dtor 
-Werror=non-virtual-dtor -fPIC -Wall -Wextra -Wno-unused-parameter 
-Wno-missing-field-initializers -Wendif-labels -Wfloat-equal -Wformat=2 
-Wmissing-include-dirs -Wpointer-arith -Wwrite-strings -Werror=char-subscripts 
-Werror=comments -Werror=empty-body -Werror=endif-labels -Werror=format 
-Werror=format-nonliteral -Werror=missing-include-dirs -Werror=non-virtual-dtor 
-Werror=overflow -Werror=overloaded-virtual -Werror=parentheses -Werror=reorder 
-Werror=return-type -Werror=sequence-point -Werror=sign-compare -Werror=switch 
-Werror=unused-label -Werror=unused-value -Werror=unused-variable 
-Werror=write-strings -m64 -pipe -g -DNDEBUG -D_FILE_OFFSET_BITS=64 -O2 
-fno-omit-frame-pointer -Ithirdparty -Ibuild64_release -I. 
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 
a.cc

And unfortunately, it seems that the compiler flags implies too strict code 
style check that even the standard C++ library cannot pass the check:

cc1plus: warning: thirdparty: No such file or directory
cc1plus: warning: build64_release: No such file or directory
In file included from /usr/include/c++/4.2.1/locale:46,
                 from /usr/include/c++/4.2.1/bits/ostream.tcc:46,
                 from /usr/include/c++/4.2.1/ostream:635,
                 from /usr/include/c++/4.2.1/iostream:45,
                 from a.cc:1:
/usr/include/c++/4.2.1/bits/locale_facets.tcc: In member function '_InIter 
std::money_get<_CharT, _InIter>::_M_extract(_InIter, _InIter, std::ios_base&, 
std::_Ios_Iostate&, std::string&) const':
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1388: error: suggest a space 
before ';' or explicit braces around empty body in 'for' statement
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1469: error: suggest a space 
before ';' or explicit braces around empty body in 'for' statement
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1481: error: suggest a space 
before ';' or explicit braces around empty body in 'for' statement

Original issue reported on code.google.com by Yi.Wang.2005 on 22 Feb 2013 at 1:55

GoogleCodeExporter commented 8 years ago
I resolved the problem by removing some G++ flags, in particular, 
-Werror=empty-body.  More details are listed in my blog post: 
http://cxwangyi.github.com/2013/02/22/use-blade-with-mac-os-x/

Original comment by Yi.Wang.2005 on 22 Feb 2013 at 1:56

GoogleCodeExporter commented 8 years ago
System headers should contains a '#pragma GCC system_header' line to suppress 
any warning, check it please.

/usr/include/c++/4.6.3/bits/locale_facets.tcc:

#ifndef _LOCALE_FACETS_TCC
#define _LOCALE_FACETS_TCC 1

#pragma GCC system_header

namespace std _GLIBCXX_VISIBILITY(default)

Original comment by chen3feng on 2 Mar 2013 at 4:39