Author Topic: SConstruct (Scons)  (Read 16775 times)

Offline Mad Scientist

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: SConstruct (Scons)
« Reply #15 on: July 29, 2007, 02:31:49 am »
Quote
Actually, this is a Linux project and I'm using gcc compiler.
O ok cool, then you could use the options "-Wall -O3 -pipe" ( warnings all treated as errors, level 3 opts, and pipe data instead of files ) instead of the "-0x". Also note though that scons will default to the msvc compiler if it is installed and in the PATH env var.

As to 16 bit 32 bit and 64 bit builds, I don't know about msvc but with gcc I haven't seen it as an option. I believe it would be considered a cross-compile if you are on a 32 bit computer just as mingw32 is a cross compile on Linux. So you would need to get a compiler built for 16 bit, probably would be a define in the build but I dont know how it is done.

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: SConstruct (Scons)
« Reply #16 on: July 30, 2007, 05:33:45 pm »
Today I decided to cheat and read the manual..!! I discovered that for my particular platform (x86) the g++ compiler can accept the optional parameters -m32 and -m64. So I'm assuming that in the absence of these it might default to 16-bit compilation. There's also an option called -mcmodel (which stands for "code model") but exactly what that is, doesn't seem to be explained anywhere.

If I wanted to experiment, how would I go about passing these parameters to the compiler from within Code::Blocks?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: SConstruct (Scons)
« Reply #17 on: July 31, 2007, 03:01:43 pm »
So I'm assuming that in the absence of these it might default to 16-bit compilation.
You are totally wrong :)

The default value depends on the architecture the compiler was build for(x86 -> 32bits, amd64/x86_64 -> 64bits).

I think linux can't be built for a 16bit architecture. :)

To be sure what is happening try to make scons and C::B print the commands they are executing (eg: gcc .... ).
For scons I don't know how to do it, but for C::B there is options in options->compiler & debugger -> other -> full compiler output ( I'm not 100% sure that the menus are named that, no C::B in front of me).

(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 johne53

  • Regular
  • ***
  • Posts: 253
Re: SConstruct (Scons)
« Reply #18 on: August 04, 2007, 06:09:25 pm »
This is slowly driving me nuts..! Here's the command that gets sent to g++ (by Scons) for compiling one of the relevant source files:-

Code
g++ -o libs/sigc++2/sigc++/connection.os -c -g -DARCH_X86 -msse -mfpmath=sse -DUSE_XMMINTRIN
-DBUILD_SSE_OPTIMIZATIONS -Wall -DHAVE_LIBLO -DENABLE_NLS -Woverloaded-virtual -fPIC -Ilibs/sigc++2 libs/sigc++2/sigc++/connection.cc

As you can see, this is to compile the Debug version of connection.cc. There's only one copy of connection.cc on my sysem. I opened up a terminal window and typed that exact same command (except with a different name for the target file). Then I compared the size of my 'manual' compile with the Scons compile. Both object files were absolutely the same size. Next I entered all those parameters into my C::B project, being very careful to ensure that all the preprocessor directives were the same and all the include folders were in the same order.

And yet, the C::B object file is a different size!?! In fact, all the object files come out at a different size. Mostly bigger though occasionally smaller.

I've even checked that I haven't inadvertantly got 2 versions of gcc/g++ on my system (which I haven't). So why on earth are the C::B modules not coming out at the right size?? Could C::B be re-ordering things? Or sending some additional parameters to the compiler that I don't know about?

Is there any way to view what C::B is sending to the compiler, so I can see if there's a difference?

[Edit...] Oops, oBFusCATed - I just noticed your last sentence. I'll try that now...!
« Last Edit: August 04, 2007, 06:31:51 pm by johne53 »

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: SConstruct (Scons)
« Reply #19 on: August 04, 2007, 06:31:24 pm »
Code
gcc -Wall -g -c -msse -mfpmath=sse -Woverloaded-virtual -fPIC -Ilibs/sigc++2 -DARCH_X86 -DUSE_XMMINTRIN -DBUILD_SSE_OPTIMIZATIONS -DHAVE_LIBLO -DENABLE_NLS
 -I/opt/gnome/lib/glib-2.0/include -I/media/SHAREDDATA/ardour2/libs/sigc++2 -I/media/SHAREDDATA/ardour2/libs/glibmm2 -I/opt/gnome/include/glib-2.0
-I/media/SHAREDDATA/ardour2/libs/pbd -I/usr/include/libxml2 -I/usr/include -I/media/SHAREDDATA/ardour2/libs
-c /media/SHAREDDATA/ardour2/libs/sigc++2/sigc++/connection.cc -o obj/Debug/sigc++/connection.o

Well, there's one difference immediately obvious.... it's using the wrong compiler!! C::B is compiling ".cc" files, using gcc, whereas Scons is using g++.

Any way to force C::B to use g++ ? It doesn't seem to appear in my list of compiler options.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: SConstruct (Scons)
« Reply #20 on: August 04, 2007, 08:19:19 pm »
Suggesting to modify line 561 of cbproject.cpp would do it :wink:

Code
    if (ext.IsSameAs(FileFilters::C_EXT) || ext.IsSameAs(FileFilters::CC_EXT))
        f->compilerVar = _T("CC");

I haven't actually tried it, but I think that's the right place to fix it in Code::Blocks, and I do think it should be changed. .cc is supposed to be a C++ extension.

In the meanwhile, right click your source file in the Projects tab, click on Properties, go to Advanced and change "Compiler variable:" to "CPP".

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: SConstruct (Scons)
« Reply #21 on: August 04, 2007, 08:34:45 pm »
Thanks for those suggestions. The second one won't be practical because there are literally thousands of files with the CC extension!! I might try the first one though. The only problem is that I don't have a file called cbproject.cpp. I do have its header file but not the source file. Is it possible that I just installed C::B in binary form? If so, I'll need to download the full source code.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: SConstruct (Scons)
« Reply #22 on: August 04, 2007, 09:17:24 pm »
Thanks for those suggestions. The second one won't be practical because there are literally thousands of files with the CC extension!! I might try the first one though. The only problem is that I don't have a file called cbproject.cpp. I do have its header file but not the source file. Is it possible that I just installed C::B in binary form? If so, I'll need to download the full source code.

Please wait for the next nightly. C::B will now handle it automatically. :)

Thanks Ceniza for the solution.
Be a part of the solution, not a part of the problem.

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: SConstruct (Scons)
« Reply #23 on: August 04, 2007, 11:09:26 pm »
Thanks to you both.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: SConstruct (Scons)
« Reply #24 on: August 04, 2007, 11:37:43 pm »
I see you committed that change. I didn't want to do it because Don Corleone wasn't around to ask him. After all, that plugin is one of his "babies" :wink:

Let's hope the Don agree with that change :)

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: SConstruct (Scons)
« Reply #25 on: August 08, 2007, 04:19:15 pm »
To be sure what is happening try to make scons and C::B print the commands they are executing (eg: gcc .... ).
For scons I don't know how to do it, but for C::B there is options in options->compiler & debugger -> other -> full compiler output ( I'm not 100% sure that the menus are named that, no C::B in front of me).

I don't understand.... since I updated to the latest version (today) I seem to have lost the ability to select 'full compiler output'. I remember it being quite simple to find but I've now been searching for about half an hour and I can't find that setting any more. Can someone please remind me how to get to it?

[Edit...] It's okay, I found it - but to my dismay, C::B is still calling the gcc compiler for a ".cc" file! I'm running the build from 5th August, svn 4349. Will the change only happen for new projects or should it have worked for an existing project? I don't want to have to change that 'Advanced' setting for literally thousands of source files....
« Last Edit: August 08, 2007, 04:27:46 pm by johne53 »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: SConstruct (Scons)
« Reply #26 on: August 08, 2007, 05:11:35 pm »
I see you committed that change. I didn't want to do it because Don Corleone wasn't around to ask him. After all, that plugin is one of his "babies" :wink:

Let's hope the Don agree with that change :)

I hope so. But gcc manual says .cc belongs to C++. So I don't see any harm with this change. ;)
Be a part of the solution, not a part of the problem.

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: SConstruct (Scons)
« Reply #27 on: August 09, 2007, 07:42:37 am »
I see you committed that change. I didn't want to do it because Don Corleone wasn't around to ask him. After all, that plugin is one of his "babies" :wink:

Let's hope the Don agree with that change :)

From simple experimentation, I don't think that the change is working properly (although I guess that depends on how you define "properly").

As far as I can tell, if I add some new ".cc" files to a project, they'll now have their 'Compiler Variable' set to CPP (this can be found in the Advanced Settings dialog for each source file). This causes them to get compiled correctly, using the g++ compiler (although it could be argued that that's just a happy accident). However, pre-existing files still retain their old setting of CC - which, from the behaviour that I'm observing, is still being compiled using the wrong compiler. In effect, the compiler used for ".cc" files will depend on the age of the project - not on the ".cc" extension. Can anyone confirm/deny/comment on whether or not that was the expected behaviour?
« Last Edit: August 09, 2007, 07:57:34 am by johne53 »