Opened 10 years ago

Closed 10 years ago

#43757 closed defect (fixed)

cppcheck @1.65: error: unrecognized command line option "-std=c++0x"

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: xythobuz@…
Priority: Normal Milestone:
Component: ports Version: 2.2.1
Keywords: Cc: cooljeanius (Eric Gallager)
Port: cppcheck

Description

building cppcheck 1.65 failed on the snowleopard buildbot:

https://build.macports.org/builders/buildports-snowleopard-x86_64/builds/26449/steps/compile/logs/stdio

--->  Building cppcheck
DEBUG: Executing org.macports.build (cppcheck)
DEBUG: Environment: CPATH='/opt/local/include' CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/.CC_PRINT_OPTIONS' LIBRARY_PATH='/opt/local/lib' CC_PRINT_OPTIONS='YES' MACOSX_DEPLOYMENT_TARGET='10.6'
DEBUG: Assembled command: 'cd "/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.65" && /usr/bin/make -j8 -w all man CXX="/usr/bin/g++-4.2 -arch x86_64" HAVE_RULES=yes CFGDIR=/opt/local/share/cppcheck DB2MAN=/opt/local/share/xsl/docbook-xsl/manpages/docbook.xsl'
DEBUG: Executing command line:  cd "/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.65" && /usr/bin/make -j8 -w all man CXX="/usr/bin/g++-4.2 -arch x86_64" HAVE_RULES=yes CFGDIR=/opt/local/share/cppcheck DB2MAN=/opt/local/share/xsl/docbook-xsl/manpages/docbook.xsl 
make: Entering directory `/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.65'
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/check64bit.o lib/check64bit.cpp
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkassert.o lib/checkassert.cpp
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkassignif.o lib/checkassignif.cpp
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkautovariables.o lib/checkautovariables.cpp
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkbool.o lib/checkbool.cpp
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkboost.o lib/checkboost.cpp
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkbufferoverrun.o lib/checkbufferoverrun.cpp
/usr/bin/g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkclass.o lib/checkclass.cpp
cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"
make: *** [lib/check64bit.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [lib/checkclass.o] Error 1
make: *** [lib/checkbufferoverrun.o] Error 1
make: *** [lib/checkboost.o] Error 1
make: *** [lib/checkbool.o] Error 1
make: *** [lib/checkassert.o] Error 1
make: *** [lib/checkassignif.o] Error 1
make: *** [lib/checkautovariables.o] Error 1

Attachments (2)

Portfile-cppcheck.diff (308 bytes) - added by xythobuz@… 10 years ago.
Portfile-cppcheck-compiler.diff (305 bytes) - added by xythobuz@… 10 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 10 years ago by xythobuz@…

It seems as if cppcheck requires a C++11 compiler since version 1.65 (http://sourceforge.net/p/cppcheck/news/2014/05/cppcheck-165/)

These features are used throughout the code. I was able to compile it without the "-std=c++0x" option using Clang, but a lot of warnings were produced.

To be honest, I'm not sure if there is a way around this problem, except upgrading the GCC used by the build bot from 4.2 to 4.4 (the minimum version mentioned by cppcheck), which is probably easier said then done.

Should I somehow tell the buildbot not to build cppcheck for Snow Leopard?

comment:2 Changed 10 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:3 Changed 10 years ago by cooljeanius (Eric Gallager)

To be honest, I'm not sure if there is a way around this problem, except upgrading the GCC used by the build bot from 4.2 to 4.4 (the minimum version mentioned by cppcheck), which is probably easier said then done.

The gcc-4.2 used by the buildbot is the system compiler, and Apple stopped upgrading its system gcc at version 4.2, so upgrading the system gcc to 4.4 is out of the question. Instead, the port should use compiler.blacklist (and/or possibly also compiler.whitelist and/or compiler.fallback) to only allow MacPorts to use compilers that work. See the UsingTheRightCompiler wiki page for more info on how to do this.

Version 0, edited 10 years ago by cooljeanius (Eric Gallager) (next)

comment:4 in reply to:  3 ; Changed 10 years ago by xythobuz@…

Edit: turns out that that wiki page fails to mention those keywords specifically, but it still contains the same general idea that is necessary here.

Will the attached diff do the trick? I don't think I'm using these keywords in the right way, but I can't find proper documentation.

Last edited 10 years ago by xythobuz@… (previous) (diff)

Changed 10 years ago by xythobuz@…

Attachment: Portfile-cppcheck.diff added

comment:5 in reply to:  4 Changed 10 years ago by cooljeanius (Eric Gallager)

Replying to xythobuz@…:

Edit: turns out that that wiki page fails to mention those keywords specifically, but it still contains the same general idea that is necessary here.

Will the attached diff do the trick? I don't think I'm using these keywords in the right way, but I can't find proper documentation.

I would use -append with those keywords, and especially with compiler.fallback, because MacPorts already comes with a default fallback list of compilers, and without using -append, you end up overwriting it. Not exactly sure where the default fallback list is stored/documented though...

Edit: found the default fallback list (from larryv in comment:ticket:44129:7 for reference), it can be found in the sources: tags/release_2_3_1/base/src/port1.0/portconfigure.tcl#L426

(updated the UsingTheRightCompiler wiki page with this link as well)

Last edited 10 years ago by cooljeanius (Eric Gallager) (previous) (diff)

comment:6 Changed 10 years ago by xythobuz@…

I have added the changes to the updated cppcheck 1.66 portfile in #44537, so this ticket can be closed.

comment:7 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)

In #44537 your attachment adds these lines:

compiler.blacklist-append   gcc* 
compiler.fallback-append    macports-clang

Blacklisting just "gcc*" will not blacklist any MacPorts gcc compilers, only those provided by Xcode, nor will it blacklist Xcode's or MacPorts' llvm-gcc, so think about what you really want there.

There is no compiler called "macports-clang". There are multiple versions of MacPorts clang, e.g. "macports-clang-3.4", etc.

comment:8 Changed 10 years ago by xythobuz@…

Okay, that makes sense. Will this work?

Changed 10 years ago by xythobuz@…

comment:9 Changed 10 years ago by neverpanic (Clemens Lang)

In r123101. If the code really uses C++11 the C++ runtime on SL will also be too old for this code and the use of libc++ would be required. So far, projects using C++11 are only supported on Mavericks and beyond in MacPorts. It's worth a shot anyway, though.

comment:10 Changed 10 years ago by neverpanic (Clemens Lang)

Resolution: fixed
Status: newclosed

comment:11 Changed 10 years ago by neverpanic (Clemens Lang)

Resolution: fixed
Status: closedreopened

OK, the results from the SL buildbot are in, and unfortunately this doesn't solve the problem yet. That's because the system clang shipped with Xcode on SL was too old to compile C++ code and always used llvm-gcc to do that:

DEBUG: Assembled command: 'cd "/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.66" && /usr/bin/make -j8 -w all man CXX="/usr/bin/llvm-g++-4.2 -arch x86_64" HAVE_RULES=yes CFGDIR=/opt/local/share/cppcheck DB2MAN=/opt/local/share/xsl/docbook-xsl/manpages/docbook.xsl'
DEBUG: Executing command line:  cd "/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.66" && /usr/bin/make -j8 -w all man CXX="/usr/bin/llvm-g++-4.2 -arch x86_64" HAVE_RULES=yes CFGDIR=/opt/local/share/cppcheck DB2MAN=/opt/local/share/xsl/docbook-xsl/manpages/docbook.xsl 
make: Entering directory `/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.66'
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/check.o lib/check.cpp
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/check64bit.o lib/check64bit.cpp
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkassert.o lib/checkassert.cpp
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkassignif.o lib/checkassignif.cpp
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkautovariables.o lib/checkautovariables.cpp
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkbool.o lib/checkbool.cpp
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkboost.o lib/checkboost.cpp
/usr/bin/llvm-g++-4.2 -arch x86_64 -Ilib -Iexternals/tinyxml  -DCFGDIR=\"/opt/local/share/cppcheck\" -O2 -include lib/cxx11emu.h  -DNDEBUG -Wall -DHAVE_RULES -DTIXML_USE_STL -I/opt/local/include  -std=c++0x -c -o lib/checkbufferoverrun.o lib/checkbufferoverrun.cpp
cc1plus: error: unrecognized command line option "-std=c++0x"cc1plus: error: unrecognized command line option "-std=c++0x"cc1plus: error: unrecognized command line option "-std=c++0x"cc1plus: error: unrecognized command line option "-std=c++0x"

cc1plus: error: unrecognized command line option "-std=c++0x"cc1plus: error: unrecognized command line option "-std=c++0x"cc1plus: error: unrecognized command line option "-std=c++0x"
cc1plus: error: unrecognized command line option "-std=c++0x"




make: *** [lib/checkbool.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [lib/checkboost.o] Error 1
make: *** [lib/checkassignif.o] Error 1
make: *** [lib/checkassert.o] Error 1
make: *** [lib/check64bit.o] Error 1
make: *** [lib/checkbufferoverrun.o] Error 1
make: *** [lib/check.o] Error 1
make: *** [lib/checkautovariables.o] Error 1
make: Leaving directory `/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.66'
Command failed:  cd "/opt/local/var/macports/build/_opt_mports_dports_devel_cppcheck/cppcheck/work/cppcheck-1.66" && /usr/bin/make -j8 -w all man CXX="/usr/bin/llvm-g++-4.2 -arch x86_64" HAVE_RULES=yes CFGDIR=/opt/local/share/cppcheck DB2MAN=/opt/local/share/xsl/docbook-xsl/manpages/docbook.xsl 

See https://lists.macosforge.org/pipermail/macports-dev/2014-July/027365.html for an explanation of the problem. The fix is to add

PortGroup compiler_blacklist_versions 1.0

and to add

{clang < 137}

to the blacklist. OK to commit?

comment:12 Changed 10 years ago by xythobuz@…

Yes, please do that.

comment:13 Changed 10 years ago by neverpanic (Clemens Lang)

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.