Author Topic: Compilation with SDCC fails on winxp  (Read 11452 times)

Offline squalyl

  • Multiple posting newcomer
  • *
  • Posts: 14
Compilation with SDCC fails on winxp
« on: June 22, 2009, 10:07:00 pm »
Hi,

here's an annoying bug: When compiling a static library with SDCC, the whole IDE crashes.

The report file .rpt shows that it's a NULL read in compiler.dll: http://www.mirari.fr/vAxK

- What is the problem?
CodeBlocks crashes, either in the 8.02 release or in the latest svn nightly (21 june)

- What did you do to when it happened?
Compiled a static lib containing a few C source files

- Can you reproduce it? How?
install codeblocks as usual
install SDCC-win32-2.9.0-setup.exe from sourceforge
create a "static lib project" with the SDCC compiler. The wizard complains about compiler settings, discard.
No need to add new files, the crash is there with the default file.
run "rebuild"
*crash*

- What release of Code::Blocks are you using?
both release 8.02 and 21 june nightly showed the problem

- Which was the latest release that did not have this problem?
no idea :)

Any clue?

I noticed that in the advanced compiler settings, the macro for compiling static libraries was empty.
I tried to fill it, to add what it should be, ie " $lib_linker $static_output $link_objects "
When closing dialogs with OK, then reopening the advanced settings, the macro has gone.
I suspect a bad textbox reading, then the command to execute is not defined and calling it results in null pointer dereference.
But I don't know C::B internals so someone with this knownledge may be faster than me to detect the problem.

Thanks in advance.
Sebastien

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: Compilation with SDCC fails on winxp
« Reply #1 on: June 23, 2009, 04:55:10 am »
SDCC Compiler most likely is not compatible with the Static Lib Template; It crashed on my also.
Will see if I can find cause; but, might not be worth it.

An Line of code in file src\plugins\compilergcc\compilerSDCC.cpp is commented out; it defines ctLinkStaticCmd which is needed in the code that crashes (src/plugins/compilergcc/directcommands.cpp:575). Removing comment and seeing what breaks with the old code.

Tim S
« Last Edit: June 23, 2009, 05:21:12 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: Compilation with SDCC fails on winxp
« Reply #2 on: June 23, 2009, 05:30:47 am »
Patch that appears to fix the problem, but should be tested by an more regular SDCC user. It looks like it is working using the sdcclib -m (option -m lists modules in library).
Tim S

Code
Index: src/plugins/compilergcc/compilerSDCC.cpp
===================================================================
--- src/plugins/compilergcc/compilerSDCC.cpp (revision 5679)
+++ src/plugins/compilergcc/compilerSDCC.cpp (working copy)
@@ -138,7 +138,7 @@
     m_Commands[(int)ctGenDependenciesCmd].push_back(CompilerTool(_T("$compiler -MM $options -MF $dep_object -MT $object $includes $file")));
     m_Commands[(int)ctLinkExeCmd].push_back(CompilerTool(_T("$linker $libdirs -o $exe_output $options $link_options $libs $link_objects")));
     m_Commands[(int)ctLinkConsoleExeCmd].push_back(CompilerTool(_T("$linker $libdirs -o $exe_output $options $link_options $libs $link_objects")));
-    //m_Commands[(int)ctLinkStaticCmd].push_back(CompilerTool(_T("$lib_linker -r $static_output $link_objects\n\tranlib $exe_output")));
+    m_Commands[(int)ctLinkStaticCmd].push_back(CompilerTool(_T("$lib_linker -r $static_output $link_objects")));
     m_Commands[(int)ctLinkNativeCmd] = m_Commands[(int)ctLinkConsoleExeCmd]; // unsupported currently
 
     LoadDefaultRegExArray();
« Last Edit: June 23, 2009, 05:40:56 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline squalyl

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Compilation with SDCC fails on winxp
« Reply #3 on: June 23, 2009, 07:48:43 am »
Hi,

I will test today with my project that builds a binary with dependencies on 3 different static libs.

Keeping you up to date.

Hey, HUGE thanks Tim, That's really nice to see so strong support! C::B is definitely the only IDE I need (along with netbeans :) )

Offline squalyl

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Compilation with SDCC fails on winxp
« Reply #4 on: June 23, 2009, 05:57:56 pm »
Well, I tried to recompile CB from SVN sources, and while the program builds, it does not run. All I get is a splash screen, then a windows crash message, and nothing more, not even a crash report.

I have mingw with gcc 3.4.5, I recompiled wxmsw 2.8.4.

The share/ folder was empty except the plugins subdirectory. This makes CB complains of missing resources, thus the crash comes after this check, if that helps.
I copied the share/subdirectory (except plugins) from my 8.02 release.

Do I have to use a gcc 4 series? not sure.
Do I have to recompile contrib plugins? I think not.

PS: Also tried to replace the 8.02 compiler.dll with the just compiled version (no patch applied yet) but it does not work :(

Any help ? I feel lame :(

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: Compilation with SDCC fails on winxp
« Reply #5 on: June 23, 2009, 06:55:16 pm »
I posted the patch in the current nightly thread so it might be added to the next build.

Building Code::Blocks from source is easy for me; but, first time it took a day or two to figure it out.

My compiler setup is not the same as the Code::Blocks build so I have to replace every thing not just the Code::Blocks SDK DLL.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: Compilation with SDCC fails on winxp
« Reply #6 on: June 23, 2009, 08:02:06 pm »
I am uploading my compiled Code::Blocks without contrib plugins output folder to
http://www.savefile.com/projects/1039215
"CodeBlocks with SDCC patch"
12 Megabytes 7Zipped file.

Marked file as removed.

Direct link to file is http://www.savefile.com/files/2136539


NOTE: Please copy your default.conf file in case it is damaged or erased by this Code::Blocks.
The default.conf file in folder %APPDATA%\codeblocks

You should be able to download and unzip file to folder and use the CodeBlocks.exe to test patch.

PLEASE: Respond that you got the file and it works; because it is very large and I want to delete it as soon as I can.
« Last Edit: June 24, 2009, 01:18:43 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline squalyl

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Compilation with SDCC fails on winxp
« Reply #7 on: June 24, 2009, 09:48:23 am »
Hi, I just got the big file, you can remove it.

It worked out of the box on my first PC.

It also worked fine on my other PC.

I can confirm the libraries are compiled OK and the application HEX file that uses the libraries are identical when compiled using makefiles and codeblocks.

HUGE thanks.

In a bug tracker I would mark this issue as "resolved" :)

Offline squalyl

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Compilation with SDCC fails on winxp
« Reply #8 on: June 24, 2009, 12:06:07 pm »
And BTW, I got codeblocks svn to compile, then run in safe mode, but the autocompletion plugin crashes.