A new version of GCC (GNU C Compiler) entered FreeBSD -CURRENT in Q2 2007. Currently, there are hundreds of ports that do not compile with gcc4. We need your help fixing as many ports as possible.

How to test compilation with gcc4

Either run CURRENT or:

Install lang/gcc42, then build a failing port with

CC=gcc42 CXX=g++42 make

What needs fixing

We will be using the pointyhat build cluster as our main reference for failing ports.

Go to http://pointyhat.freebsd.org/errorlogs/i386-7-latest/index-reason.html for the lastest list on i386-current. The list will be incomplete if the build is currently running, but there's usually enough to look at anyway. The last full run on i386-current is http://pointyhat.freebsd.org/errorlogs/i386-7-full/index-reason.html; you can also look at http://pointyhat.freebsd.org/errorlogs/amd64-7-latest/index-reason.html and http://pointyhat.freebsd.org/errorlogs/amd64-7-full/index-reason.html.

Note that not all failures are there due to gcc4, but most appropriate ones are now labeled as gcc4. A few stray ones will show up as ???.

In addition to the above, any port already marked as BROKEN (whether due to gcc4 error or not) will not be in the latest runs. To see a list of those ports, see http://portsmon.freebsd.org/portsconcordanceforbroken.py. The advantage of this page is that it will show you any existing PRs for the ports. Note: portmgr is in the process of marking all ports that do not work on gcc4 as BROKEN in the appropriate buildenvs.

portsmon will also show you a cross-reference of the latest gcc4 error log, across all architectures, at http://portsmon.freebsd.org/portsconcordanceforbuilderror.py?build_error=gcc4+error.

Note: up until now, portsmon has only sent complaint-mail about ports that have some problem on i386-6. With the upcoming release, in the first few days of October the default will be switched to i386-7, and the complaint-mails will be sent on that basis.

Tips on effective fixing

Before you start hacking on the source code, please follow this checklist:

How to get your fix applied

If you are a committer, just commit away. If you are an ordinary contributor, file a PR.

Please, respect maintainership. There is no blanket approval to fix ports for gcc4 at this time. If you're fixing someone else's port, try to get maintainer's approval first. Filing a PR with the patch is best way to achieve this, because 1) it emails the maintainer automatically 2) the patch is seen by others so work is not duplicated.

Typical failures

Static declaration follows non-static declaration

hf.c:471: error: static declaration of 'CreateHfTriangle' follows non-static declaration
hf.c:45: error: previous declaration of 'CreateHfTriangle' was here

 45  hfTri *CreateHfTriangle(), *GetQueuedTri();
...
471  static hfTri * CreateHfTriangle(hf, x1, y1, x2, y2, x3, y3, which) {

The forward declaration is not static, the actual function is. The fix is to make the forward declaration on line 45 static too.

 45  static hfTri *CreateHfTriangle(), *GetQueuedTri();

If the declarations are not in the same file, the fix is to remove the static keyword altogether from the function.

Invalid lvalue in assignment

ode_notrimesh.c:12346: error: invalid lvalue in assignment

... how to fix ...

Invalid storage class

wnnfns.c:433: error: invalid storage class for function 'yes_or_no'

... how to fix ...

Extra qualification on member

SWFOutputDev.cc:248: error: extra qualification 'SWFOutputDev::' on member 'setGfxFont'

Just remove the extra qualification

Unlikely undefined references

/usr/local/lib/libgnomecanvasmm-2.6.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)@GLIBCXX_3.4.9'
/usr/local/lib/libgnomecanvasmm-2.6.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)@GLIBCXX_3.4.9'

You're probably trying to link against gcc4-compiled libs with gcc3. Just relax the USE_GCC=3.4 requirement to USE_GCC=3.4+.

A very helpful link suggested by krion: http://www.digitalfanatics.org/index.php?title=CompilerErrors

Also http://dev.gentoo.org/~vanquirius/gcc4-porting-guide.html describes some common gcc4 errors and suggested patches.

Also http://gcc.gnu.org/gcc-4.3/porting_to.html for gcc-4.3 (see the other links at the bottom).

Also http://www.cyrius.com/journal/gcc/gcc-4.4-preprocessor-errors and http://www.cyrius.com/journal/gcc/gcc-4.4-include for gcc-4.4.

gcc4 (last edited 2009-04-21 20:23:50 by ThierryThomas)