kierenj / 0x10c-DevKit

0x10c DevKit
http://0x10c-devkit.com/
39 stars 4 forks source link

Bug in C compiler? #170

Closed calzoneman closed 12 years ago

calzoneman commented 12 years ago

Hello,

I downloaded and installed 0x10c DevKit 1.7.5 Beta today, and while trying it out I appear to have encountered a bug in the C compiler.

DESCRIPTION: Attempting to build a solution with a simple C source file will cause one or more undesirable outcomes:

HOW TO REPRODUCE: Create a new solution and a new project inside that solution. Create a C source file in that project with the following source:

int main()
{
    return 0;
}

Click "Build Solution"

SYSTEM INFO: Windows 7 64-bit Home Premium AMD Athlon 64 X2 (2.5GHz) 3GB DDR2 RAM Freshly installed copy of 0x10c DevKit 1.7.5-Beta (no previous versions have ever been installed)

I wish I could give specific information about the problem but unfortunately the program has a tendency to crash before I can save the exception log. I did submit 2 bug reports via the automatic exception handler that may hold information relevant to this issue.

calzoneman

kierenj commented 12 years ago

I have the reports, thanks. It's having trouble parsing the output from DTCC. I tried the exact example above, and it worked. I wonder.. if MSVCRT.dll is required. When I download the dcputoolchain binaries/source, that's not included. I can't find a MSVCRT to try, but would you mind downloading and trying to run dtcc.exe from http://dcputoolcha.in/ please?

calzoneman commented 12 years ago

Running dtcc.exe from the Windows Beta binaries available on http://dcputoolcha.in/ on the source code mentioned above produces the following assembly, no errors, no warnings, no problems:


.IMPORT _stack_caller_init
.IMPORT _stack_caller_init_overlap
.IMPORT _stack_callee_return
.IMPORT _halt
.IMPORT _halt_debug
.ULINE 4 "test.c"

:_DATA

.SECTION INIT
.SECTION CODE
    SET X, 0
    SET Z, _halt
    JSR _stack_caller_init
    SET PC, cfunc_main
.ULINE 1 "test.c"
.BOUNDARY
.EXPORT cfunc_main
:cfunc_main
    SET PC, cfunc_main_actual
    DAT 0
:cfunc_main_actual
    SUB SP, 0
.ULINE 3 "test.c"
.ULINE 3 "test.c"
.ULINE 3 "test.c"
    SET A, 0

    ADD SP, 0
    SET X, 0
    SET PC, _stack_callee_return

    ADD SP, 0
    SET A, 0xFFFF
    SET X, 0
    SET PC, _stack_callee_return
calzoneman commented 12 years ago

Does 0x10c-DevKit automatically include the bootstrap file for C sources or do I have to include that manually? If the latter is the case, then it's possible that DevKit just needs better error handling for unresolved imports.

kierenj commented 12 years ago

You need to add it manually, but it will give an error inside devkit (not dtcc) if you miss it.  The error indicates its a problem parsing dtcc's stdout or stderr output. Could you compile that same code using dtcc.exe includes in devkit and let me know the output in the console window (rather than asm) please? Finally regarding the memory leak, could you try disabling autoload of the vector plugin (via menu), then restart devkit and see if the leak persists? Very much appreciated :)

Sent from Samsung Galaxy Note

-------- Original message -------- Subject: Re: [0x10c-DevKit] Bug in C compiler? (#170) From: Calvin Montgomery reply@reply.github.com To: Kieren Johnstone kierenj@gmail.com CC:

Does 0x10c-DevKit automatically include the bootstrap file for C sources or do I have to include that manually?  If the latter is the case, then it's possible that DevKit just needs better error handling for unresolved imports.


Reply to this email directly or view it on GitHub: https://github.com/kierenj/0x10c-DevKit/issues/170#issuecomment-6114221

calzoneman commented 12 years ago

Hello,

dtcc.exe from the DevKit installation folder works as expected with no console output. I will try disabling the vector plugin, but the memory leak is not consistently reproducible (whereas failing to compile C sources occurs on 100% of builds with C files). Please let me know if there is additional information I can provide.

calzoneman

kierenj commented 12 years ago

Hi, here's a new version of the toolchain integration plugin: https://dl.dropbox.com/u/18385630/Devkit.DCPUToolchainPlugin.zip

Could you overwrite the existing one, then click Properties in explorer and check theres no 'Unblock' button to press, then try the build in devkit again? If there's a problem there should at least be an error message logged! Thanks ;)

kierenj commented 12 years ago

Can you also confirm there's a newline at the end of your C file?

ghost commented 12 years ago

Both of these were also caused by another bug with missing/incorrect propertys, or non-existant/incorrect files.

Exception that crashes IDE Build Output is stuck at "Building Solution..."

It might be worth checking if it's related.

WarlockD commented 12 years ago

I was having the exact problem and downloaded the new plugin dll. Instead of it just saying "Building Solution.." It gives some errors.

AH! I found it! the last line was in the '}' of main.c. I added an extra line below that and it works. To get around this issue, make sure the last line in the c file has an extra line feed.

calzoneman commented 12 years ago

Ah, I don't know why I didn't think of that, that seems to be a common bug (standard?) in C compilers. Although admittedly the error handling could be better :P