Bug 883 - Optimized build fails at perf-io.cc - debug build completes without error
Optimized build fails at perf-io.cc - debug build completes without error
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: build system
pre-release
All All
: P5 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-18 06:14 UTC by Antti Mäkelä
Modified: 2010-04-19 13:48 UTC (History)
3 users (show)

See Also:


Attachments
patch (453 bytes, patch)
2010-04-19 09:46 UTC, Lalith Suresh
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Mäkelä 2010-04-18 06:14:27 UTC
At least after latest "hg pull && hg update", the optimized build fails at following:

[ 947/1170] cxx: src/contrib/topology-read/topology-reader.cc -> build/optimized/src/contrib/topology-read/topology-reader_1.o                                  
[ 948/1170] cxx: src/contrib/topology-read/inet-topology-reader.cc -> build/optimized/src/contrib/topology-read/inet-topology-reader_1.o                        
[ 949/1170] cxx: src/contrib/topology-read/orbis-topology-reader.cc -> build/optimized/src/contrib/topology-read/orbis-topology-reader_1.o                      
[ 950/1170] cxx: src/test/perf/perf-io.cc -> build/optimized/src/test/perf/perf-io_3.o                                                                          
cc1plus: warnings being treated as errors                                       
../src/test/perf/perf-io.cc: In function 'void PerfFile(FILE*, uint32_t, const char*, uint32_t)':                                                               
../src/test/perf/perf-io.cc:53: error: ignoring return value of 'size_t fwrite(const void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result
Waf: Leaving directory `/home/zarhan/VirtISP/repos/ns-3-allinone/ns-3-dev/build'
Build failed
 -> task failed (err #1):
        {task: cxx perf-io.cc -> perf-io_3.o}

However, debug build builds just fine. I've run distclean between builds due to bug #855.
Comment 1 Josh Pelkey 2010-04-18 14:44:01 UTC
Mine fails here using optimized build:

[ 968/1203] cxx: utils/test-runner.cc -> build/optimized/utils/test-runner_1.o
cc1plus: warnings being treated as errors
../utils/test-runner.cc: In function ‘std::string BaseDir()’:
../utils/test-runner.cc:110: error: ignoring return value of ‘char* getcwd(char*, size_t)’, declared with attribute warn_unused_result
Comment 2 Craig Dowell 2010-04-19 01:25:39 UTC
I'm unable to reproduce this on Fedora 12 (gcc 4.4.3) or Ubuntu 8.04 (gcc 4.2.4).  What systems/compilers are you using?  Have you changd anything recently?

I'm a bit surprised at this since perf-io.cc hasn't changed in almost three months and has been happily building since then on our build farm.  I'm not sure what changed that could suddenly start flagging these instances.

A fix is simple enough, but it would be good to know why your compilers suddenly started complaining.
Comment 3 Antti Mäkelä 2010-04-19 01:37:00 UTC
My gcc is 4.3.4, using Gentoo.
Comment 4 Antti Mäkelä 2010-04-19 03:21:59 UTC
(In reply to comment #3)
> My gcc is 4.3.4, using Gentoo.

  Oh, and I have no previous reference really since this is first time I have been (doing an attempt in) running optimized build.
Comment 5 Lalith Suresh 2010-04-19 09:23:31 UTC
I've got the same error as Josh:

[ 956/1151] cxx: utils/test-runner.cc -> build/optimized/utils/test-runner_1.o
cc1plus: warnings being treated as errors
../utils/test-runner.cc: In function ‘std::string BaseDir()’:
../utils/test-runner.cc:110: error: ignoring return value of ‘char* getcwd(char*, size_t)’, declared with attribute warn_unused_result

I'm on Ubuntu 9.10 with gcc/g++ 4.4.1.
Comment 6 Lalith Suresh 2010-04-19 09:46:07 UTC
Created attachment 834 [details]
patch

I know this is a silly hack, but it builds after this. Attaching the patch.
Comment 7 Craig Dowell 2010-04-19 13:13:47 UTC
It turns out that this is due to library writers deciding what is best for us lowly users.

At least on Ubuntu, -D_FORTIFY_SOURCE was turned on with version 8.10 (Karmic).  This enabled library functions with attribute warn_unused_result.  In Jaunty, they decided to turn off that attribute for fwrite (presumably due to the outcry).  

It seems that some of us have libraries with warn_unused_result and some not, some of us have FORTIFY_SOURCE on and some not.

Unfortunately, the people assigning attributes have decided that they know best and there is no way to selectively turn this attribute off.  You must either globally change FORTIFY_SOURCE or reduce your optimization level.

So the error Antii observes (fwrite) goes away on the next library update, but the error Josh apparently won't go away.

The better part of valor seems to be to just check the results and abort, even though we really don't care in one case, and the other case "can't happen."

Should be fixed with changeset 3ccf4cea2480.  Can one of you (Antii or Josh) please confirm and close if satisfied.
Comment 8 Josh Pelkey 2010-04-19 13:48:32 UTC
fixed with changeset 3ccf4cea2480, thanks Craig!