Author Topic: How to see the generated compiler parameters?  (Read 5561 times)

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
How to see the generated compiler parameters?
« on: April 03, 2011, 08:23:26 pm »
I am compiling a few Code::Blocks projects with wxWidgets, using wx-config. I have a configuration issue on Linux and need to see what exactly Code::Blocks is saying to the compiler, i.e. the compiler and linker command line parameters.

Where can I find the fully expanded cimpiler parameters?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(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 cacb

  • Lives here!
  • ****
  • Posts: 536
Re: How to see the generated compiler parameters?
« Reply #2 on: April 03, 2011, 09:02:32 pm »
Read here: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Thank you, that gave me exactly what I was looking for!  :D I can see the options generated now.

The problem I trying to solve is that I don't seem to have 100% control over which wx-config I am using in Linux build targets, thereby leaving a big 'hole' in the configuration of Code::Blocks projects using wxWidgets. My projects have compiler settings like this

Code
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="`wx-config --version=2.8 --toolkit=gtk2 --debug --cxxflags`" />
<Add option="`wx-config --cflags`" />
<Add option="-DNOPCH" />
<Add option="-D__WXDEBUG__" />
<Add option="-D_DEBUG" />
<Add option="-D__WX__" />
</Compiler>

As I have a locally compiled version of wxWidgets (using static libraries, among other things), I was trying to tell Code::Blocks to use the wx-config found in /usr/local/bin by means of the Code::Blocks global variable "wx" (defined as /usr/local):

Code
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="`$(#wx)/bin/wx-config --version=2.8 --toolkit=gtk2 --debug --cxxflags`" />
<Add option="`$(#wx)/bin/wx-config --cflags`" />
<Add option="-DNOPCH" />
<Add option="-D__WXDEBUG__" />
<Add option="-D_DEBUG" />
<Add option="-D__WX__" />
</Compiler>

However, this didn't work, as it now becomes clear that Code::Blocks global variables don't get expanded in the context of "backticks". So instead I had to manually expand it to

Code
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="`/usr/local/bin/wx-config --version=2.8 --toolkit=gtk2 --debug --cxxflags`" />
<Add option="`/usr/local/bin/wx-config --cflags`" />
<Add option="-DNOPCH" />
<Add option="-D__WXDEBUG__" />
<Add option="-D_DEBUG" />
<Add option="-D__WX__" />
</Compiler>

Which isn't 100% general, as I would like everything to be dependent in the wx global variable. Any tips on how to achive it is welcome.

But you answered my original question, so thanks for that  :D


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to see the generated compiler parameters?
« Reply #3 on: April 03, 2011, 09:18:08 pm »
Add /usr/local/bin to your PATH, you can probably use the envvar plugin.
I think there is a way to combine all wx-config scripts in one, but I don't know how.
Probably you should ask the wx guys.

p.s. you should remove the `wx-config --cflags`
(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 cacb

  • Lives here!
  • ****
  • Posts: 536
Re: How to see the generated compiler parameters?
« Reply #4 on: April 03, 2011, 09:41:43 pm »
Add /usr/local/bin to your PATH, you can probably use the envvar plugin.
I think there is a way to combine all wx-config scripts in one, but I don't know how.
Probably you should ask the wx guys.

I see, but the idea was to keep as much configuration as possible in the .cbp file. If you share the project file with others it is important. But it is a good idea to learn more about wx-config from the wx guys.

p.s. you should remove the `wx-config --cflags`

Aha. Thanks.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to see the generated compiler parameters?
« Reply #5 on: April 03, 2011, 11:54:42 pm »
It would be easy to expand macros in backticked expressions before evaluating them:

Code
Index: compilercommandgenerator.cpp
===================================================================
--- compilercommandgenerator.cpp (Revision 7071)
+++ compilercommandgenerator.cpp (Arbeitskopie)
@@ -919,6 +919,7 @@
 /** Adds support for backtick'd expressions under windows. */
 wxString CompilerCommandGenerator::ExpandBackticks(wxString& str)
 {
+    Manager::Get()->GetMacrosManager()->ReplaceMacros(str);
     wxString ret;
 
     // this function is not windows-only anymore because we parse the backticked command's output

@other devs:
Is there any obvious reason I miss not to do it ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to see the generated compiler parameters?
« Reply #6 on: April 04, 2011, 06:32:12 am »
Is there any obvious reason I miss not to do it ?
Such things are usually dangerous for auto-generated files because the macros may be expanded too early. I didn't see when this is called though (no access to the sources). You should play the tutorial from the WiKi concerning auto-generated files and see it that would still work. If that's the case I see not reason not to do it.

Also, verify what gets saved to the project. Remember: This is a by reference call... not that we loose the original setup.
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

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to see the generated compiler parameters?
« Reply #7 on: April 04, 2011, 08:54:42 am »
Is there any obvious reason I miss not to do it ?
Such things are usually dangerous for auto-generated files because the macros may be expanded too early. I didn't see when this is called though (no access to the sources). You should play the tutorial from the WiKi concerning auto-generated files and see it that would still work. If that's the case I see not reason not to do it.
Which tutorial ?

Also, verify what gets saved to the project. Remember: This is a by reference call... not that we loose the original setup.
Both calls to ExpandBackticks use temporary strings at the moment, so it does not harm.
And what's more the actual code also changes the wxString passed to the function (it replaces the backtick-part with the evaluated stuff).

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: How to see the generated compiler parameters?
« Reply #8 on: April 04, 2011, 09:36:19 am »
Both calls to ExpandBackticks use temporary strings at the moment, so it does not harm.
And what's more the actual code also changes the wxString passed to the function (it replaces the backtick-part with the evaluated stuff).

Just saying that I appreciate your efforts here... It would indeed be useful to allow the expansion inside backticks! As mentioned, it is obviously important that the expanded string is not written back to the .cbp file. It must be left as written.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
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