News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

invalid_ compiler, should break the build

Started by oBFusCATed, February 26, 2012, 11:44:16 PM

Previous topic - Next topic

oBFusCATed

It turned out that if you have an invali_d compiler and then try to debug something, there is no error message shown as it should.
I'm talking about the debugger's branch of course.

I've debugged it a bit and the reason is that the exit code from the compiler is not set to != 0.
I've tried this patch and it works:

Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 7860)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -2387,6 +2387,7 @@
                           _T("Skipping..."),
                           prj->GetTitle().wx_str(), tlist[x].wx_str(), compilerName.wx_str(), compilerName2.wx_str());
                Manager::Get()->GetLogManager()->LogWarning(msg, m_PageIndex);
+                m_LastExitCode = 1;
                continue;
            }
            else if (!tgt->SupportsCurrentPlatform())
Index: src/plugins/debuggergdb/debuggergdb.cpp
===================================================================
--- src/plugins/debuggergdb/debuggergdb.cpp (revision 7860)
+++ src/plugins/debuggergdb/debuggergdb.cpp (working copy)
@@ -2126,7 +2126,10 @@
bool DebuggerGDB::CompilerFinished(bool compilerFailed, StartType startType)
{
    if (compilerFailed || startType == StartTypeUnknown)
+    {
+        m_Canceled = true;
        return false;
+    }
    if (DoDebug(startType == StartTypeStepInto) != 0)
        return false;
    return true;


Is it OK, to commit it? (The m_LastExitCode is going to be committed in trunk).

p.s. Morten can you add me to an exclude list, so I can post about invalid __ compilers?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

killerbot

what exactly will this mean. Something that should NOT break are the following use cases. A project with several targets, each building with a different compiler. It is well possible that sometimes certain compilers are not installed. Then a build 'all' (aka every target) should not fail, because some compiler is missing.
This is just for compiling/linking, not for launching the debugger off course.

oBFusCATed

Two corrections to the patch:

Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 7860)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -1152,6 +1152,7 @@
            cmd = m_CommandQueue.Next();
            if (!cmd && m_BuildState == bsNone && m_NextBuildState == bsNone)
            {
+                m_LastExitCode = 0;
                NotifyJobDone(true);
                ResetBuildState();
                if (m_RunAfterCompile)
@@ -2387,6 +2388,7 @@
                           _T("Skipping..."),
                           prj->GetTitle().wx_str(), tlist[x].wx_str(), compilerName.wx_str(), compilerName2.wx_str());
                Manager::Get()->GetLogManager()->LogWarning(msg, m_PageIndex);
+                m_LastExitCode = 1;
                continue;
            }
            else if (!tgt->SupportsCurrentPlatform())
@@ -2395,6 +2397,7 @@
                msg.Printf(_T("\"%s - %s\" does not support the current platform. Skipping..."),
                            prj->GetTitle().wx_str(), tlist[x].wx_str());
                Manager::Get()->GetLogManager()->LogWarning(msg, m_PageIndex);
+                m_LastExitCode = 1;
                continue;
            }
            BuildJobTarget bjt;
Index: src/plugins/debuggergdb/debuggergdb.cpp
===================================================================
--- src/plugins/debuggergdb/debuggergdb.cpp (revision 7860)
+++ src/plugins/debuggergdb/debuggergdb.cpp (working copy)
@@ -2126,7 +2126,10 @@
bool DebuggerGDB::CompilerFinished(bool compilerFailed, StartType startType)
{
    if (compilerFailed || startType == StartTypeUnknown)
+    {
+        m_Canceled = true;
        return false;
+    }
    if (DoDebug(startType == StartTypeStepInto) != 0)
        return false;
    return true;



The "m_LastExitCode = 0;" part is needed, because if I have two target project and I try to build a failing target, then switch to the correct target and try to launch the debugger, it thinks that the build failed.

killerbot: You case seems to work and I think the reason is that the invalid_compiler message is printed at the beginning of the build, so if there is something that modifies the m_LastExitCode after I've set it, everything is OK.
Also m_LastExitCode it not used inside the compiler, it is meant for the outside world:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

MortenMacFly

Quote from: oBFusCATed on February 26, 2012, 11:44:16 PM
Is it OK, to commit it? (The m_LastExitCode is going to be committed in trunk).
If it doesn't break other builds (i.e. building C::B) go ahead.

Quote from: oBFusCATed on February 26, 2012, 11:44:16 PM
p.s. Morten can you add me to an exclude list, so I can post about invalid __ compilers?
Not possible, sorry. That's a kind of "global search & replace) independent of users. The same would happen to me and even Yiannis.

...but I saw you find a work-around... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]