Author Topic: DMD compiler problems... -Wall option?  (Read 18245 times)

Offline Silverling

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: DMD compiler problems... -Wall option?
« Reply #15 on: November 23, 2006, 05:18:47 pm »
All problems seem to have been solved. A few bugs however I want to point out. I choose DMD as the default compiler,but he ignored me :shock:. No big deal, I simply choose the one appropriate when creating a new project. Now,when I add a file, I have to specifically change it's extension from the default c/c++ to .d He should assume the extension from the compiler...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5179
Re: DMD compiler problems... -Wall option?
« Reply #16 on: November 23, 2006, 05:30:54 pm »
All problems seem to have been solved. A few bugs however I want to point out. I choose DMD as the default compiler,but he ignored me :shock:. No big deal, I simply choose the one appropriate when creating a new project. Now,when I add a file, I have to specifically change it's extension from the default c/c++ to .d He should assume the extension from the compiler...
this is very valuable feedback. Please create for each a bug report at berlios, and specify a detailed "how to reproduce".
Many thanks

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: DMD compiler problems... -Wall option?
« Reply #17 on: November 23, 2006, 06:00:48 pm »
the project wizard script should be checked, probably add this options in too many cases --> probably only valid for gnu ?
The reason is simple: There is a common function that handles setting the "enable warnings". It's function is basically "If MSVC -> (Set For MSVC) Otherwise FallBack to GNU (GCC) default".
This works in more cases than e.g. "If MSVC -> (Set For MSVC) Else If GNU (GCC) -> Do "-Wall" Otherwise FallBack to nothing."
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5179
Re: DMD compiler problems... -Wall option?
« Reply #18 on: November 23, 2006, 09:43:41 pm »
I suggest we enhance it for our build in compilers, we already know now it's not ok for Borland and Dmd

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: DMD compiler problems... -Wall option?
« Reply #19 on: November 23, 2006, 10:31:35 pm »
I suggest we enhance it for our build in compilers, [...]
I'm not quite sure what that means (you mean the new compiler framework, right?) but yes... why not. ;-)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5179
Re: DMD compiler problems... -Wall option?
« Reply #20 on: November 23, 2006, 11:12:28 pm »
no, I was talking to do that if this else if this, else if this, else default in the wizard script on when to add -Wall. Where the if this is at least the compilers which have built-in support in CB

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: DMD compiler problems... -Wall option?
« Reply #21 on: November 23, 2006, 11:52:56 pm »
no, I was talking to do that if this else if this, else if this, else default in the wizard script on when to add -Wall. Where the if this is at least the compilers which have built-in support in CB
Right... so you mean we should really extend the wizard script for all built-in compilers? Ok - will do this... hopefully I understand what compiler switch is meant to be the "Warning all" for all supported compilers... ;-)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: DMD compiler problems... -Wall option?
« Reply #22 on: November 24, 2006, 04:39:57 am »
The bug (-Wall for Borland) does not exist for MSVC.

Also as Silverling posted, even if the default compiler is set to a compiler other than GNU GCC, the project wizard always takes GCC as default.
Be a part of the solution, not a part of the problem.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: DMD compiler problems... -Wall option?
« Reply #23 on: November 24, 2006, 09:10:40 am »
[...] even if the default compiler is set to a compiler other than GNU GCC, the project wizard always takes GCC as default.
Please file a bug report accordingly and (if possible) assign to me or tell me. Otherwise this will get lost. But I agree - this shouldn't happen. (Will think about that.)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: DMD compiler problems... -Wall option?
« Reply #24 on: November 24, 2006, 10:47:56 am »
I have added two bug reports in Berilios. They are as follows-

  • [ Bug #9533 ] Default Compiler is always set to GCC
  • [ Bug #9534 ] -Wall Option in project file of Borland C++ and DMD compiler

I have added short description to reproduce the bug.  :D
Be a part of the solution, not a part of the problem.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: DMD compiler problems... -Wall option?
« Reply #25 on: November 24, 2006, 11:50:10 am »
I have added two bug reports in Berilios. They are as follows-
Ok - thanks, I've assigned them to me so they shouldn't get lost.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: DMD compiler problems... -Wall option?
« Reply #26 on: November 24, 2006, 02:51:27 pm »
Hi MortenMacFly,

I have created a partial patch.

File to be patched: common_functions.script
Quote
12c12
<     else
---
>    else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
16a17,21
>    else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc")))
>    {
>       // Set option for genearting all warnings with BCC
>       base.AddCompilerOption(_T("-w"));
>    }
28c33
<     else
---
>     else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
44c49
<     else
---
>     else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
59c64
<     else
---
>     else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))


The patch solves Bug #9534. But the one can't build app with bcc as several compiler and linker options are missing from the project file as it was never added by the project wizard. I can find the support for Borland Compiler is broken. That is why I call this a partial patch.

Some more work needs to be done in order to fix the building and linking properly. I have modified some of the code to not to block some wrong options to be set for bcc (like -g, which has different meaning in bcc).

Regards,

Biplab Kumar Modak
Be a part of the solution, not a part of the problem.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: DMD compiler problems... -Wall option?
« Reply #27 on: November 24, 2006, 07:38:44 pm »
I'm posting more polished patches.

Latest Changes:
  • Bug #9534 is fixed.
  • Improvements to Console Wizards

Console Wizard Improvements:
  • Adds exception handling compiler flags for GCC, MSVC 2005 (MSVC 2003 not tested) and Borland C++ 5.5.1 compilers. (Earlier wizard script had a function, but the call was not being executed. The function have been improved and added appropriately to wizard)
  • Adds appropriate Optimization compiler flags for GCC, MSVC 2005 (MSVC 2003 not tested) and Borland C++ 5.5.1 compilers. (Earlier wizard script had a function, but the call was not being executed. The function have been improved and added appropriately to wizard)
  • Adds appropriate libraries for linking with MSVC 2005 and Borland C++ 5.5.1 compilers. (Linking with MSVC 2003 may face problem)

What it Broke??  :shock:
  • The /NODEFAULTLIB:libcmt.lib flag has been added. I'm not sure whether this will work for MSVC 6 or MSVC 2003. This is necessary to compile app with MSVC 2005.
  • Other compiler flags may break MSVC 6 and MSVC 2003 support (I'm not sure as I don't have them to test).

I'll make improvements to this patch after my upcoming exam.. :D

Patches:
common_functions.patch (Patch #001657 submitted in Berlios)
Code: C++
  1. --- C:/CB_20061121_rev3253_win32/share/CodeBlocks/templates/wizard/old_common_functions.script  Tue Jul 25 21:05:04 2006
  2. +++ C:/CB_20061121_rev3253_win32/share/CodeBlocks/templates/wizard/common_functions.script      Sat Nov 25 02:01:18 2006
  3. @@ -5,31 +5,44 @@
  4.  // Warnings On
  5.  function WarningsOn(base, compilerID)
  6.  {
  7. -    if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("msvc*")))
  8. +       if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("msvc*")))
  9.      {
  10.          base.AddCompilerOption(_T("/W3"));
  11.      }
  12. -    else
  13. +       else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
  14.      {
  15.          // GCC options are used as fallback
  16.          base.AddCompilerOption(_T("-Wall"));
  17.      }
  18. +       else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc")))
  19. +       {
  20. +               // Set option for genearting warnings with BCC
  21. +               base.AddCompilerOption(_T("-w"));
  22. +       }
  23.  }
  24.  
  25.  // Debug symbols On
  26.  function DebugSymbolsOn(base, compilerID)
  27.  {
  28. -    if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("msvc*")))
  29. +       if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("msvc*")))
  30.      {
  31.          base.AddCompilerOption(_T("/Zi"));
  32.          base.AddCompilerOption(_T("/D_DEBUG"));
  33.          base.AddLinkerOption(_T("/DEBUG"));
  34. +               base.AddLinkerOption(_T("/NODEFAULTLIB:libcmt.lib"));
  35. +               base.AddLinkLib(_T("libcmtd.lib"));
  36.      }
  37. -    else
  38. +    else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
  39.      {
  40.          // GCC options are used as fallback
  41.          base.AddCompilerOption(_T("-g"));
  42.      }
  43. +       else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc")))
  44. +    {
  45. +        // BCC options for generating debug symbols
  46. +        base.AddCompilerOption(_T("-v"));
  47. +               base.AddLinkerOption(_T("-v"));
  48. +    }
  49.  }
  50.  
  51.  // Optimizations On
  52. @@ -40,13 +53,19 @@
  53.          base.AddCompilerOption(_T("/Og"));
  54.          base.AddCompilerOption(_T("/Ox"));
  55.          base.AddCompilerOption(_T("/DNDEBUG"));
  56. +               base.AddLinkLib(_T("libcmt.lib"));
  57.      }
  58. -    else
  59. +    else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
  60.      {
  61.          // GCC options are used as fallback
  62.          base.AddCompilerOption(_T("-O2"));
  63.          base.AddLinkerOption(_T("-s"));
  64.      }
  65. +       else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc")))
  66. +    {
  67. +        // BCC options for optimizations
  68. +        base.AddCompilerOption(_T("-O2"));
  69. +    }
  70.  }
  71.  
  72.  // C++ Exceptions On
  73. @@ -56,11 +75,34 @@
  74.      {
  75.          base.AddCompilerOption(_T("/EHsc"));
  76.      }
  77. -    else
  78. +    else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
  79.      {
  80.          // GCC options are used as fallback
  81.          base.AddCompilerOption(_T("-fexceptions"));
  82.      }
  83. +       else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc")))
  84. +    {
  85. +        // BCC options for exceptions. Not Tested
  86. +        base.AddCompilerOption(_T("-x"));
  87. +    }
  88. +}
  89. +
  90. +//To include additional Libraries needed for linking
  91. +function IncludeAdditionalLib(base, compilerID)
  92. +{
  93. +       if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("msvc*")))
  94. +       {
  95. +               //Add any library which is needed
  96. +       }
  97. +       else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc")))
  98. +       {
  99. +               //Add any library which is needed
  100. +       }
  101. +       else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc")))
  102. +       {
  103. +               base.AddLinkLib(_T("cw32mt.lib"));
  104. +               base.AddLinkLib(_T("import32.lib"));
  105. +       }
  106.  }
  107.  
  108.  function VerifyDirectory(dir_or_macro)
  109.  

wizard.patch (Patch #001656 submitted in Berlios)
Code: C++
  1. --- C:/CB_20061121_rev3253_win32/share/CodeBlocks/templates/wizard/console/old_wizard.script    Sat Nov 25 01:15:26 2006
  2. +++ C:/CB_20061121_rev3253_win32/share/CodeBlocks/templates/wizard/console/wizard.script        Sat Nov 25 01:27:49 2006
  3. @@ -97,13 +97,21 @@
  4.      // Debug build target
  5.      local target = project.GetBuildTarget(Wizard.GetDebugName());
  6.      if (!IsNull(target))
  7. +       {
  8.          SetupTarget(target, true);
  9. +               CppExceptionsOn(target, Wizard.GetCompilerID());
  10. +               IncludeAdditionalLib(target, Wizard.GetCompilerID());
  11. +       }
  12.  
  13.      // Release build target
  14.      target = project.GetBuildTarget(Wizard.GetReleaseName());
  15.      if (!IsNull(target))
  16. +       {
  17.          SetupTarget(target, false);
  18. -
  19. +               CppExceptionsOn(target, Wizard.GetCompilerID());
  20. +               IncludeAdditionalLib(target, Wizard.GetCompilerID());
  21. +       }
  22. +      
  23.      // all done!
  24.      return true;
  25.  }
  26. @@ -124,12 +132,14 @@
  27.      if (is_debug)
  28.      {
  29.          // enable debugging symbols for this target
  30. -        DebugSymbolsOn(target, Wizard.GetTargetCompilerID());
  31. +        //DebugSymbolsOn(target, Wizard.GetTargetCompilerID());
  32. +               DebugSymbolsOn(target, Wizard.GetCompilerID());
  33.      }
  34.      else
  35.      {
  36.          // enable optimizations for this target
  37. -        OptimizationsOn(target, Wizard.GetTargetCompilerID());
  38. +        //OptimizationsOn(target, Wizard.GetTargetCompilerID());
  39. +               OptimizationsOn(target, Wizard.GetCompilerID());
  40.      }
  41.  
  42.      // all done!
  43.  

Results of Some Test Applications:
Quote
-------------- Build: Debug in TestBor ---------------
Compiling: main.cpp
main.cpp:
Linking console executable: .\TestBor.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

-------------- Build: Release in TestBor ---------------
Compiling: main.cpp
main.cpp:
Linking console executable: .\TestBor.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

-------------- Build: Debug in TestVC ---------------
main.c
Linking console executable: .\TestVC.exe
LINK : .\TestVC.exe not found or not built by the last incremental link; performing full link
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

-------------- Build: Release in TestVC ---------------
cl : Command line warning D9035 : option 'Og' has been deprecated and will be removed in a future release
main.c
Linking console executable: .\TestVC.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
-------------- Build: Debug in TestVC ---------------
main.cpp
Linking console executable: .\TestVC.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

-------------- Build: Release in TestVC ---------------
cl : Command line warning D9035 : option 'Og' has been deprecated and will be removed in a future release
main.cpp
Linking console executable: .\TestVC.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

-------------- Build: Debug in TestGCC ---------------
Compiling: main.cpp
Linking console executable: .\TestGCC.exe
Process terminated with status 0 (0 minutes, 3 seconds)
0 errors, 0 warnings
 
-------------- Build: Release in TestGCC ---------------
Compiling: main.cpp
Linking console executable: .\TestGCC.exe
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings

You can see that all the test applications generated by the wizard compiled with GCC, MSVC 2005 and Borland C++ 5.5.1 without any error or warnings.

Please test it and post your feedback.

Regards,

Biplab Kumar Modak
« Last Edit: November 24, 2006, 07:52:18 pm by biplab »
Be a part of the solution, not a part of the problem.

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: DMD compiler problems... -Wall option?
« Reply #28 on: November 30, 2006, 10:04:38 am »
There are so many guys discussing this problem! The D is getting hotter and hotter :P. I have been planning to solve it. It seems to be unnecessary.

I want to give a suggestion :
    The D is just a language like C or C++, and can also be used for programming in Console and GUI (wxD now works.) environment. Maybe we can delete the catalog item of "D application", and add it to Console and GUI.

By the way, I want to give another my problem that is I can't use the GDC compiler in FreeBSD after I have installed GDC. Of course, I'll try my best to solve it.
« Last Edit: November 30, 2006, 10:07:27 am by heromyth »

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: DMD compiler problems... -Wall option?
« Reply #29 on: November 30, 2006, 10:17:43 am »
I want to give a suggestion :
    The D is just a language like C or C++, and can also be used for programming in Console and GUI (wxD now works.) environment. Maybe we can delete the catalog item of "D application", and add it to Console and GUI.

Currently D is a C/C++ compiler in Code::Blocks. Once that bug/workaround/hack is fixed, we can update the wizards.