NO

Author Topic: Objective-C port for PEllesC - Bootstrap patch  (Read 11568 times)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Objective-C port for PEllesC - Bootstrap patch
« on: August 14, 2007, 02:48:41 PM »
We have already discussed of the issue.
This patch builds the PellesC bootstrap compiler.
Will follow the patch to build the compiler.
Enjoy  ;D

Frankie.
« Last Edit: August 14, 2007, 06:51:58 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Freddy

  • Guest
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #1 on: August 14, 2007, 08:08:07 PM »
Thank you!
I like to use Pelles C over other IDEs/compiler.
OOP was what Pelles C was really missing (well, not really missing, but it's something good to have).
Objective C looks like a nice choice.
Could you please explain how to use it?

Thanks

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #2 on: August 15, 2007, 02:44:06 AM »
The 'Portable object Compiler' is write in Objective C.
So when you download the source package you cannot compile it unless you have a working object compiler  ???
So to create your first working copy you need to 'bootstrap' the compiler someway. For this reason there is a distribution called 'bootstrap' indeed. It is composed of a precompiled version of the original object files (extension .m). They are pure 'C' files that you can compile locally with a plain 'C' compiler as the PellesC.
When the bootstrap is compiled you will use it to compile the source package to obtain a full working compiler.
What I have done is a long work of adaptation, on the bootstrap files before and then on the objective sources, to create packages that can be compiled under PellesC (a POC port to PellesC) but still usable to compile on all the other targets (I should submit it to the authors to be included in the original distribution?  :-\).
The instructions to build packages are inside the distribution (it seems that the modified files are few, but has not been an easy job   >:().
Anyway let me know if it is of any use, in my opininion it is a very heavy implementation that sucks in space and CPU.
I'm not sure it is useful for gui programming. Probably it's necessary to use the DLL version of libraries, but I've not been able yet to compile them, and I'm annoyed now ....  ;D
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

gedumer

  • Guest
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #3 on: November 13, 2008, 05:22:30 PM »
frankie,

I can't get the bootstrap to compile. Here are the errors I get:

C:\ObjC\bootstrap>pomake
md bin
del *.com
Could Not Find C:\ObjC\bootstrap\*.com
pocc -DNDEBUG -Ot -W0 trlunit.c -Fo trlunit.obj
trlunit.m(171): error #2048: Undeclared identifier '__ctypetab'.
trlunit.m(171): error #2144: Type error: pointer expected.
POMAKE: fatal error: 'pocc', error 1.


At first, I got errors regarding missing "(&__stderr)" and "(&__stdout)", but I think I solved that by removing the (&__ ...) for both. I can't find any reference to "__ctypetab" anywhere.

Can you  help?

Gary.
« Last Edit: November 13, 2008, 07:47:34 PM by gedumer »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #4 on: November 14, 2008, 01:08:34 PM »
Gary,
it works for me without any touch.
Have you followed the instructions in the file "BOOTSTRAP" included in my patch?
I report them here again:

 BOOTSTRAP PROCEDURE
 -------------------

1.  Create the compiler base directory, i.e. "ObjC", under the disk root.
    ***WARNING***: don't install package under directories that contains
    spaces. You could have problems configuring and using the compiler.

2.  Obtain the bootstrap package "objc-bootstrap-3.1.32.tar.tar" from the
    site http://sunsite.unc.edu/pub/Linux/devel/lang/objc, and extract the
    contents in "bootstrap" subdirectory of the one created above.
    (Now you'll find "objc-bootstrap-3.1.32.tar.gz")

3.  Extract the whole contents of my patch in this subdirectory.
     Answer YES to override existing files
    Some files will be added and some will be overwrited with the patch version.

4.  Open a command window in the subdirectory "bootstrap", be sure PellesC path
    is accessible (Run "povars32.cmd"), then type "pomake".
    This will build the three executables objc.exe, objc1.exe and postlink.exe
    These are the Win32 executables you need to build the compiler.
   
5.  If you want to use the bootstrap as final compiler get also the include files
    from the sources package and you need the libraries also.
    If you're not able to compile the last by yourself download my sources patch
    package that will be posted in the forum.
   
    Now you you can start compiling Objective-C programs. :)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

gedumer

  • Guest
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #5 on: November 14, 2008, 04:49:40 PM »
Yes... I followed it to the letter. Question is... what is "__ctypetab" and where is it? Is it referenced in the source you use? Is it defined in your source. If so, why isn't it defined in my copy? If its not defined in yours, why aren't you getting the same error?

Look at line 471 of trlunit.c... "__ctypetab" id used there but not defined anywhere. Am I missing a header file? Maybe you could post the version you're now using and I'll try it again?

Thanks... Gary.

gedumer

  • Guest
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #6 on: November 14, 2008, 06:56:14 PM »
Question is... what is "__ctypetab" and where is it?

I found out where __ctypetab is. It's defined in ctype.h along with (&__stderr) and (&__stdout). The question is... why is PellesC not finding them? My PATH includes C:\PellesC and C:\PellesC\bin. Any ideas?

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #7 on: November 14, 2008, 07:29:33 PM »
Did you execute povars32.cmd before you executed pomake ???
---
Stefan

Proud member of the UltraDefrag Development Team

gedumer

  • Guest
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #8 on: November 14, 2008, 10:43:58 PM »
Did you execute povars32.cmd before you executed pomake ???


I looked at the povars32.bat file and my environment was already set with those variables.

I have since, completely uninstalled PellesC and reinstalled it in the Program Files directory where it seems to want to be. Then after setting up a clean version of c:\objc\bootstrap as per frankies instructions, it finally ran and created the 3 exe files although there was a make error stating it didn't know how to make default.

After I got those files created, I copied both patch files into the ObjC directory, in the proper sequence. I then executed setup followed by make where objc.exe proceeded to crash 5 times.

So... I'm a step closer, but miles away. After each crash, I get the typical MS error box saying objc.exe has encountered a problem... etc. with the options to Debug, Send Error Report, or Don't Send.

The following shows the sequence of events:

Code: [Select]
C:\ObjC>setup poc
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
C:\ObjC>make
Global make for PellesC

C:\ObjC\>cd   src\objcrt

C:\ObjC\src\objcrt>pomake
..\..\bin\objc -noPostLink -c -Ot -DNDEBUG  Object.m
POMAKE: fatal error: '..\..\bin\objc', error -1073741819.

C:\ObjC\src\objcrt>if exist objcrt.lib copy /Y objcrt.lib ..\..\lib\ob
jcrt.lib

C:\ObjC\src\objcrt>cd   ..\objpak

C:\ObjC\src\objpak>pomake
POMAKE: fatal error: '..\..\bin\objc', error -1073741819.

C:\ObjC\src\objpak>if exist objpak.lib copy /Y objpak.lib ..\..\lib\ob
jpak.lib

C:\ObjC\src\objpak>cd   ..\oclib

C:\ObjC\src\oclib>pomake
POMAKE: fatal error: '..\..\bin\objc', error -1073741819.

C:\ObjC\src\oclib>if exist oclib.lib copy /Y oclib.lib ..\..\lib\oclib
.lib

C:\ObjC\src\oclib>cd   ..\objc

C:\ObjC\src\objc>pomake
POMAKE: fatal error: '..\..\bin\objc', error -1073741819.

C:\ObjC\src\objc>if exist objc.exe copy /Y objc.exe ..\..\bin\objc.exe


C:\ObjC\src\objc>if exist objc1.exe copy /Y objc1.exe ..\..\bin\objc1.
exe

C:\ObjC\src\objc>if exist postlink.exe copy /Y postlink.exe ..\..\bin\
postlink.exe

C:\ObjC\src\objc>cd   ..\cakit

C:\ObjC\src\cakit>pomake
POMAKE: fatal error: '..\..\bin\objc', error -1073741819.

C:\ObjC\src\cakit>if exist cakit.lib copy /Y cakit.lib ..\..\lib\cakit
.lib

C:\ObjC\src\cakit>cd   ..\..

C:\ObjC>if exist src\objc\objchelp.txt copy /Y src\objc\objchelp.txt l
ib\objchelp.txt
        1 file(s) copied.
C:\ObjC>
« Last Edit: November 14, 2008, 11:34:32 PM by gedumer »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #9 on: November 15, 2008, 04:55:27 PM »
Gary,
I checked again, and I found that the problem presents with the last version of the compiler (5.00.8 ) when the optimization are on ("-Ot" flag).
I created a new set of patches removing the optimization from makefiles. Unfortunately I had no time to check extensively so maybe there is still some "-Ot" floating around in makefiles.
For the same reason (no time) I don't have investigated on the the problem (a compiler bug or a patch bug), so for now use it unoptimized. Maybe you can do some debug on yourself, in this case I'll appreciate your commitment.
About the pomake errors as "POMAKE: fatal error: Don't know how to make 'ALL'." don't bother to them, they are due to incompatibility between standar UNIX make and pomake (if you like also to my approximation to translate them  ::) ).
I'll appreciate feedback.

P.S. To check the compiler build the application "words", for this you need the "flex" utility that can be downloaded here: http://gnuwin32.sourceforge.net/packages/flex.htm
« Last Edit: November 15, 2008, 05:55:43 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

gedumer

  • Guest
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #10 on: November 16, 2008, 04:17:06 AM »
Frankie,

It compiled and created the 3 files, but when I try to compile a simple objc program, for example... main.m, it says it can't find main.i. What is main.i and why is it looking for it? I can't find any reference to it anywhere. If I compile a hello world program without Objective-c statements, it happily compiles it, but with ObjC statements... no go. It always looks for a .i file and sometimes a .p file.

Gary

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #11 on: November 16, 2008, 05:53:18 AM »
Gary,
the objc is a multipass compiler, it generates many ".i" or intermediate files, that are the translation of ".m" files to plain c to be feed to the standard compiler. The ".p" are other intermediate files generated from objc compiler (preprocessed m files). The compilation is in many steps, the C compiler is run as preprocess only, then compiler. There is also the postlink to manage the message tables... in plane word a little mess  ???
Have you used the bootstrap compiler to build the objc 3.1.32 compiler and libraries? (the bootstrap doesn't have libraries).
I think that your problem is the correct use of objc compiler switches, for the usage of the compiler you have to refer to objc compiler standard documentation. The use of objc is not easy like PellesC compiler, I suggest you to read through the whole objc standard doc.
In the source there is the "words" example where I patched the makefile, so you can build it by simply running pomake in the words subdirectory (see instructions, and use it as reference to how build an objc executable). If you're not able to compile and run it there is still a problem on your building. I can build and execute words here.

P.S. Objc is not fully compatible with C# compilers around, so don't try to import complex projects unless you can manage it well ;)
« Last Edit: November 16, 2008, 06:04:50 AM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

gedumer

  • Guest
Re: Objective-C port for PEllesC - Bootstrap patch
« Reply #12 on: November 16, 2008, 05:58:24 PM »
Frankie,

Words worked fine, but when I tried to apply the same principles to my main.m example, the same thing happened as before. So... I went to the examples directory and tried to compile them. I only got delegates.m to compile and execute. Then I tried to compile the example programs using the MinGW Objective-C compiler and I discovered that POC is implemented quite differently than that compiler. My own examples compile correctly with MinGW, however the POC examples do not.

The whole reason I wanted to try your version of POC was to have an alternative to MinGW, but that's not going to be possible. So... I'm not going to pursue POC any further.

Thank you Frankie for all the help you've given me, but I've spent more than enough time evaluating this implementation and it just isn't what I was hoping it would be, that is, essentially a seemless alternative to MinGW.

Thanks again... Gary.