parallaxinc / OpenSpin

Spin/PASM compiler for the Parallax Propeller.
56 stars 19 forks source link

Hitting OpenSpin's `error : Limit of 256 subroutines + objects exceeded` #34

Closed drawkula closed 6 years ago

drawkula commented 7 years ago
$ /opt/openspin/bin/openspin -u -L lib system/regnatix/regime.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on May  8 2017 04:19:27
Compiling...
system/regnatix/regime.spin
reg-ios.spin(2754:5) : error : Limit of 256 subroutines + objects exceeded
Line:
PUB rd_next:stradr | i,j                                'ramdisk: verzeichniseintrag lesen
Offending Item: rd_next

Which constant (in PropellerCompiler/PropellerCompiler.h#L42-L57?) needs to be increased to compile sources with more than 256 such items?

reltham commented 7 years ago

You can't increase this number. The Spin interpreter (in the ROM on the chip) would have to be changed to allow more, since the number has to fit in a byte.

drawkula commented 7 years ago

Then something really strange is going on that I really do not understand...

$ ./bstc.linux -b -Oa -L lib system/regnatix/regime.spin
Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved
Compiled for i386 Linux at 08:17:46 on 2009/07/20
Loading Object regime
Loading Object reg-ios
Loading Object glob-con
Loading Object glob-string
Program size is 9868 longs
2 Constants folded
Compiled 2868 Lines of Code in 0.15 Seconds
$ ls -l regime.binary 
-rw-r--r-- 1 yeti yeti 9872 Mai 18 07:46 regime.binary
$ asciiless lib/reg-ios.spin | grep PUB | wc -l
299

regime is the command line interpreter of TriOS (https://hive-project.de/) and the binary built by BSTC is in use for years now.

I'm trying to get TriOS built by OpenSpin.

reltham commented 7 years ago

It's removing unused PUBs, -Oa includes that feature. Try using the -u feature of OpenSpin.

drawkula commented 7 years ago

Using OpenSpin's "-u" makes no difference:

$ /opt/openspin/bin/openspin -L lib system/regnatix/regime.spin
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on May  8 2017 04:19:27
Compiling...
system/regnatix/regime.spin
|-reg-ios.spin
reg-ios.spin(2754:5) : error : Limit of 256 subroutines + objects exceeded
Line:
PUB rd_next:stradr | i,j                                'ramdisk: verzeichniseintrag lesen
Offending Item: rd_next
$ /opt/openspin/bin/openspin -u -L lib system/regnatix/regime.spin
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on May  8 2017 04:19:27
Compiling...
system/regnatix/regime.spin
reg-ios.spin(2754:5) : error : Limit of 256 subroutines + objects exceeded
Line:
PUB rd_next:stradr | i,j                                'ramdisk: verzeichniseintrag lesen
Offending Item: rd_next

...but indeed: Running BSTC without optimisations does fail:

$ ./bstc.linux -b -L lib system/regnatix/regime.spin
Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved
Compiled for i386 Linux at 08:17:46 on 2009/07/20
Loading Object regime
Loading Object reg-ios
Loading Object glob-con
Loading Object glob-string

glob-string - Relocation pointer error!! 0B13
glob-string - FATAL! Unable to locate Object to fixup!! 19

Compiled 2868 Lines of Code in 0.1 Seconds
reltham commented 7 years ago

Okay, I guess BSTC does things differently and manages to make it work.

I'm not sure this can be solved easily with OpenSpin, because of how the internal structure works (based on Chips original x86 code).

You might need to split apart the file that has 299 PUBs to be in separate objects in order to get it working. If that is even an option for you.

drawkula commented 7 years ago

Thanks!

Maybe some PUBs could be used like a BDOS call with function numbers as 1st argument. That would be a dramatic change of the OS's function call API. This code in its current state is in use for years now.

IIRC the OS and it's transient programs (without counting some separately distributed add-ons) make >51000 lines of code now.

We definitely have something to discuss: Change or stick to BSTC forever?

Tertium non datur?