Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interesting project attempting a simple C+ preprocessor #6

Open
mingodad opened this issue Feb 25, 2022 · 17 comments
Open

Interesting project attempting a simple C+ preprocessor #6

mingodad opened this issue Feb 25, 2022 · 17 comments

Comments

@mingodad
Copy link
Owner

mingodad commented Feb 25, 2022

Today on the tinycc mailing list Steffen Nurpmeso sent this link https://directory.fsf.org/wiki/Lightweight_C++ and I just downloaded it and fixed several compilers warnings/errors but but there is a need to add code to handle/ignore __attribute__ for the preprocessed headers.

I'm attaching it here just in case someone else wants to work on it too.
lwc-1.3.2.zip

@rofl0r
Copy link

rofl0r commented Feb 25, 2022

I'm attaching it here just in case someone else wants to work on it too.

wouldnt it make more sense to put up a git repo ? makes it easier to see what was changed and why.

@rofl0r
Copy link

rofl0r commented Feb 25, 2022

@mingodad i noticed you're not watching your own repo, which makes you miss comments like the above, therefore i added this additional comment to notify you via "mention"

@Kochise
Copy link

Kochise commented Feb 26, 2022

This looks like version "1.4" (1.3.2 with some update already) :

https://github.com/funny-falcon/lwc

Regards.

@mingodad
Copy link
Owner Author

Yes thank you for pointing out https://github.com/funny-falcon/lwc and also looking on https://github.com/funny-falcon/pyvm that uses lwc, but it also needs changes to cope with new __attribute__ and __asm__ .

@Kochise
Copy link

Kochise commented Feb 26, 2022

Of course, but since it hasn't been maintained for almost more than 15 years, that might explain an update is of a great necessity.

I looked at this project for quite a long time, as you can see me mentioning it there too :

https://www.osnews.com/story/28486/the-sortix-operating-system/

You can find the latest pyvm version here :

http://students.ceid.upatras.gr/~sxanth/pyvm-3.0/ (but the file is not accessible)

Release announcement :

https://lwn.net/Articles/398705/

Btw, also pay attention to :

http://students.ceid.upatras.gr/~sxanth/ncc/ (file available)

And also :

http://students.ceid.upatras.gr/~sxanth/lndbase/ (file not available)

At least you can grab the previous version here (2.0.1) :

https://www.ibiblio.org/pub/Linux/apps/database/

If someone can reach either Stelios Xanthakis or Nikos Fotoulis...

thatd-be-great

@mingodad
Copy link
Owner Author

Thank you again for all of your links and info, here is my fork https://github.com/mingodad/lwc that can be built on ubuntu 18.04 and several of the samples can be built (it's only one big commit, sorry).

Anyway it's easier to hack it now !

@mingodad
Copy link
Owner Author

Do you have the latest Pyvm ? And if so can you share it ?

@Kochise
Copy link

Kochise commented Feb 26, 2022

Sadly, I don't have it.

What I don't understand is that obviously pyvm didn't took off when it was released and its author(s) disappeared not too long after that.

The latest pyvm I found so far is :

http://web.archive.org/web/20090324002539/http://students.ceid.upatras.gr/~sxanth/pyvm (version 1.2 from 2006/04/30)

The git repository is still available though (better archive it as well) :

http://students.ceid.upatras.gr/~sxanth/pyvm.git/ (latest changes was on 2010/03/29)

Announced there :

https://www.reddit.com/r/programming/comments/ak8ql/miniature_userspace_system_in_2mb/
https://grokbase.com/t/python/python-announce-list/061vkgcb64/pyvm-1-1
https://grokbase.com/t/python/pyathens/106azje2dw/pyvm-3-0

Maybe a start to get in touch with the author(s).

Btw this repository (as seen in Greek announcement) doesn't exist even on web.archive :

http://pyvm.hobby-site.org/pyvm/

Some more links :

https://code.activestate.com/lists/python-list/453628
https://bytes.com/topic/python/answers/44657-pyvm-faster-python
https://python-list.python.narkive.com/T9vp9w78/pyvm-source-code
https://lists.gnu.org/archive/html/savannah-register-public/2009-03/msg00107.html
https://mail.python.org/archives/list/python-announce-list@python.org/thread/DH2CGMNRAYXVMRARXAYWLBJQYUPZ52VW/

So right now, the lwc, pyvm and ccat projects were removed from the server.

@Kochise
Copy link

Kochise commented Feb 26, 2022

I recreated the pyvm repository from the previous post :

pyvm-2.1.zip (7099 KiB)

Branches are :

2 -> 2.0
master -> 2.1

Profit.

@mingodad
Copy link
Owner Author

I also cloned that repository and tried to build it but even after transferring several of my fixes it doesn't build:

lwc/objdir/lwc seg-malloc.c+ > objdir/seg-malloc.c
*** stack smashing detected ***: <unknown> terminated
Aborted (core dumped)

So more work need to be done to get it to at least build, for now I'll stick with https://github.com/mingodad/lwc

@mingodad
Copy link
Owner Author

After looking at it again and making the change bellow the stack smash stopped but other problems still remain:
In main.c:

...
void init ()
{
	Token t;
	int p [8] = { -1, }; // it was p[6]  before
	Token nodcl [] = { -1 };
...

@rofl0r
Copy link

rofl0r commented Feb 27, 2022

since you guys appear to prefer zip files over git repos i independently mirrored the pyvm repo mentioned above and made it available here https://github.com/rofl0r/pyvm . this can also be used to compare the zip file above and verify it hasnt been tampered with.
the only change i made is that i made available the 2.1 changes which were in "master" branch (as a single parent-less commit) as a separate commit on top of the 2.0 branch which contained the full git history, and renamed that branch to master.

@Kochise
Copy link

Kochise commented Feb 27, 2022

Good work and clever idea to put "2.1" on top of "2.0"

Keep in mind there is still a version "3.0" somewhere to be found, though.

The zip is easier to move around and it was a simple extract of the original repository.

@rofl0r
Copy link

rofl0r commented Feb 27, 2022

Keep in mind there is still a version "3.0" somewhere to be found, though.

indeed, but when looking at changes from 2.0 to 2.1 it appears it can be safely ignored, at least when it comes to pyvm core and lwc.

@mingodad
Copy link
Owner Author

Now adding _Float128 type recognition we are almost there with pyvm (see mingodad/lwc@cdff48b):

lwc/objdir/lwc seg-malloc.c+ > objdir/seg-malloc.c
lwc/objdir/lwc threading.c+ > objdir/threading.c
lwc/objdir/lwc file.c+ > objdir/file.c
lwc/objdir/lwc util.c+ > objdir/util.c
lwc/objdir/lwc marshal.c+ > objdir/marshal.c
lwc/objdir/lwc IO.c+ > objdir/IO.c
lwc/objdir/lwc module.sys.c+ > objdir/module.sys.c
lwc/objdir/lwc module.posix.c+ > objdir/module.posix.c
lwc/objdir/lwc module.time.c+ > objdir/module.time.c
lwc/objdir/lwc main.c+ > objdir/pyvm.c
lwc/objdir/lwc module.thread.c+ > objdir/module.thread.c
lwc/objdir/lwc module.__builtins__.c+ > objdir/module.__builtins__.c
BAD FUNCTION[lround]
module.__builtins__.c+:79 [Token 44298]: overloading match, type mis-match
 Somewhere in ### [ 0 ] . as_double -> f ) ; } extern int lround ( double ) ; __section__ ( ".text.modules"  ###
Makefile:211: recipe for target 'objdir/module.__builtins__.c' failed
make[1]: [objdir/module.__builtins__.c] Error 1 (ignored)
lwc/objdir/lwc modules.misc.c+ > objdir/modules.misc.c
lwc/objdir/lwc module.math.c+ > objdir/module.math.c
lwc/objdir/lwc module.binascii.c+ > objdir/module.binascii.c
lwc/objdir/lwc module.unicode.c+ > objdir/module.unicode.c
lwc/objdir/lwc cold.c+ > objdir/cold.c
lwc/objdir/lwc interned.c+ > objdir/interned.c
lwc/objdir/lwc dict2.c+ > objdir/dict2.c
lwc/objdir/lwc sort.c+ > objdir/sort.c
lwc/objdir/lwc pyby.c+ > objdir/pyby.c
lwc/objdir/lwc module.string.c+ > objdir/module.string.c
lwc/objdir/lwc module._itertools.c+ > objdir/module._itertools.c
lwc/objdir/lwc module._bisect.c+ > objdir/module._bisect.c
lwc/objdir/lwc module.gc.c+ > objdir/module.gc.c
lwc/objdir/lwc module.JIT.c+ > objdir/module.JIT.c
lwc/objdir/lwc module.marshal.c+ > objdir/module.marshal.c
lwc/objdir/lwc array.c+ > objdir/array.c
lwc/objdir/lwc module.re.c+ > objdir/module.re.c
lwc/objdir/lwc module.pyvm_extra.c+ > objdir/module.pyvm_extra.c
lwc/objdir/lwc importfile.c+ > objdir/importfile.c
lwc/objdir/lwc module.__socket.c+ > objdir/module.__socket.c
lwc/objdir/lwc module.cStringIO.c+ > objdir/module.cStringIO.c
lwc/objdir/lwc iidict.c+ > objdir/iidict.c
lwc/objdir/lwc poller.c+ > objdir/poller.c
lwc/objdir/lwc vmpoll.c+ > objdir/vmpoll.c
lwc/objdir/lwc stdout.c+ > objdir/stdout.c
lwc/objdir/lwc filedes.c+ > objdir/filedes.c
lwc/objdir/lwc boot.c+ > objdir/boot.c
lwc/objdir/lwc module.struct.c+ > objdir/module.struct.c
lwc/objdir/lwc Long.c+ > objdir/Long.c
lwc/objdir/lwc liblong.c+ > objdir/liblong.c
lwc/objdir/lwc module.zlib.c+ > objdir/module.zlib.c
lwc/objdir/lwc module.html.c+ > objdir/module.html.c
lwc OK.

@mingodad
Copy link
Owner Author

I've submitted my changes to rofl0r/pyvm#1 you can check and see the output shown above with:

make clean
make -i > make.log 2>&1

@mingodad
Copy link
Owner Author

mingodad commented Mar 1, 2022

Finally I found the problem in module.__builtins__.c+ and fixed it here mingodad/pyvm@3cd01d5 now at least lwc is transpiling everything without showing erros (if what it does make any sense is another story).
Also update https://github.com/mingodad/lwc with the version at https://github.com/mingodad/pyvm/tree/master/pyvm/lwc , now if someone want to further fix/improve it you're welcome !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants