Author Topic: invalid_ compiler, should break the build  (Read 5619 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
invalid_ compiler, should break the build
« on: February 26, 2012, 11:44:16 pm »
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:
Code
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!]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: invalid_ compiler, should break the build
« Reply #1 on: February 27, 2012, 12:18:05 am »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: invalid_ compiler, should break the build
« Reply #2 on: February 27, 2012, 12:27:08 am »
Two corrections to the patch:
Code
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!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: invalid_ compiler, should break the build
« Reply #3 on: February 27, 2012, 10:13:29 am »
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.

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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ