Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Why does CC always link (even with no files!?

Help
2005-06-27
2013-04-24
  • Markus Wankus
    Markus Wankus
    2005-06-27

    I am trying to implement conditional builds using the "unless=" clause in my <compiler> and <linker> clauses.  I am generating the XML for my Cpptask-based builder.  What I noticed is that if the user does not specify any source files for the linker, it blindly goes along and fires up a linker anyway with no source files.  What is going on here?  To reproduce this, I reduced the entire build file down to the case where I wanted it to do nothing, i.e. both my <compiler> and <linker> "unless=" clauses failed, and I noticed it said:

              [cc] 0 total files to be compiled.
              [cc] Starting link
              [cc] gcc: no input files

    BUILD FAILED

    Hmm... - it knows there are no files to compile and it does not call my compiler - good.  But there are also no files to link - yet is still calls "gcc -c"!?!?  It knows enough to not call MY linker (which is most definitely NOT gcc), but why it is blindly calling "gcc -c" for no reason whatsoever, and furthermore, how do I stop it?

    So...my question is - how can I generate a build file, with conditional <compiler> and <linker> definitions in my <cc> task (using the "unless=" flag), and have it not do anything?  It looks to me like I have no control over the default linker (gcc) - which is always called no matter what, and breaks the entire build process.  That seems to defeat the purpose of the "unless=" clause. 

    Furthermore, if I define a <linker> with no input files, why is it even run?  Should it not detect this case and not fire up the tool?

    Thanks,
    Mark.