Giter VIP home page Giter VIP logo

openspin's People

Contributors

dbetz avatar jesrui avatar redvers avatar reltham avatar stephengroat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openspin's Issues

#warn vs #warning vs preprocessor's wiki page

Summary: #warn or #warning?

(yeti@kumari:22)/opt/openspin/src/test$ cat PreProcessorTestWARN.spin 
#warn Testing WARN

pub main
        ' empty main to keep the compiler happy
(yeti@kumari:22)/opt/openspin/src/test$ /opt/openspin/bin/openspin -q PreProcessorTestWARN.spin 
PreProcessorTestWARN.spin(1:6) : error : Expected "," or end of line
Line:
#warn Testing WARN
Offending Item: Testing
(yeti@kumari:22)/opt/openspin/src/test$ cat PreProcessorTestWARNING.spin 
#warning Testing WARNING

pub main
        ' empty main to keep the compiler happy
(yeti@kumari:22)/opt/openspin/src/test$ /opt/openspin/bin/openspin -q PreProcessorTestWARNING.spin 
PreProcessorTestWARNING.spin:1: warning: #warn:  Testing WARNING

...so it seems to be #warning.

The preprocessor's wiki page mentiones #warn.

And...

PreProcessorTestWARNING.spin:1: warning: #warn:  Testing WARNING

...probably would be...

PreProcessorTestWARNING.spin:1: warning: #warning:  Testing WARNING

...if the text constant in the code would reflect the choice of #warning.

open spin landing page

the description comment on the open spin landing page is
"Add to Github"

Please change to something descriptive such as
"compiles SPIN source code file into EEPROM firmware image for the Propeller 1"
or similar

Openspin bug

I found a bug with openspin, it seems that the program size is calculated before unused code is removed using the -u command, I get object exceeds memory limits, my work around has been to use -M 35000 command so the program complies to 29K and runs fine

Mac supports

The file OpenSpin_x­x­x_x86_64­Mac.tar.bz2 dose not existe.

Thanks

Unused Method Cleanup

Hi Roy,

I've been away from all aspects of Propeller development for awhile (long story), otherwise I would have told you this months ago. Nevertheless, unused method cleanup still isn't stable enough for me to release as part of PropellerIDE.

Now that I've returned to work, my first order of business is automating my release processes. As part of this, I have set up a continuous integration server for my distribution of OpenSpin, which will now run regression testing of the compiler against the Spin library distribution as well as the LameStation SDK, and hopefully more software packages later.

Anyhow, I'm not sure how these were introduced, but it seems like there are a lot more errors from the previous release. I'm not even yet building from my Qt version. I'm pulling straight from upstream for these tests, and I have confirmed locally that building against 1.00.77 has similar results.

See for yourself here.
https://travis-ci.org/bweir/OpenSpin/jobs/82146770

From now on, when you have updates, it'll be possible to test them immediately. You can get results even faster by incorporating continuous integration into the mainline.

Anyway, I thought you should know. Are you still working on these issues or any other aspect of OpenSpin?

Thanks,

Multiple defines at command line (-D)

OpenSpin accepts only the first -D parameter at command line. The reason is a not needed break:

--- OpenSpin.orig/SpinSource/openspin.cpp       2014-04-21 17:27:54.000000000 +0200
+++ OpenSpin/SpinSource/openspin.cpp    2014-04-21 17:31:22.000000000 +0200
@@ -716,7 +716,6 @@
                         CleanupMemory();
                         return 1;
                     }
-                    break;
                 }
             }
         }

Unused method removal removes methods passed to cognew

MusicPlayer is a private function passed to a cognew, but is used nowhere else, so -u removes the function.

Compiling without unused method removal:

$ ./openspin ~/Projects/lamestation-sdk/games/Brettris/Brettris.spin -L ~/Projects/lamestation-sdk/
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2015 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.72 Compiled on Mar 19 2015 21:49:36
Compiling...
/home/brett/Projects/lamestation-sdk/games/Brettris/Brettris.spin
|-LameLCD.spin
  |-Pinout.spin
|-LameGFX.spin
|-LameAudio.spin
  |-Pinout.spin
|-LameMusic.spin
  |-LameAudio.spin
    |-Pinout.spin
|-LameControl.spin
  |-Pinout.spin
  |-LameFunctions.spin
|-LameFunctions.spin
|-gfx_bretrominos.spin
|-gfx_wall.spin
|-gfx_font4x6_w.spin
|-gfx_scorebox.spin
|-song_tetris.spin
|-gfx_bretris_logo.spin
|-gfx_gameover.spin
Done.
Program size is 11752 bytes

With unused method removal enabled:

$ ./openspin ~/Projects/lamestation-sdk/games/Brettris/Brettris.spin -L ~/Projects/lamestation-sdk/ -u
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2015 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.72 Compiled on Mar 19 2015 21:53:47
Compiling...
/home/brett/Projects/lamestation-sdk/games/Brettris/Brettris.spin
|-LameLCD.spin
  |-Pinout.spin
|-LameGFX.spin
|-LameAudio.spin
  |-Pinout.spin
|-LameMusic.spin
  |-LameAudio.spin
    |-Pinout.spin
|-LameControl.spin
  |-Pinout.spin
  |-LameFunctions.spin
|-LameFunctions.spin
|-gfx_bretrominos.spin
|-gfx_wall.spin
|-gfx_font4x6_w.spin
|-gfx_scorebox.spin
|-song_tetris.spin
|-gfx_bretris_logo.spin
|-gfx_gameover.spin
Done.
NOT IMPLEMENTED
NOT IMPLEMENTED
NOT IMPLEMENTED
NOT IMPLEMENTED
|-LameLCD.spin
|-LameGFX.spin
|-LameAudio.spin
|-LameMusic.spin
  |-LameAudio.spin
LameMusic.spin(48:12) : error : Expected an expression term
Line:
    cognew(MusicPlayer, @MusicPlayerStack)
Offending Item: MusicPlayer

I'm building off a fresh checkout of parallaxinc/OpenSpin.

I did try a few projects that didn't use this feature and it reduced the binary size significantly, so it's looking good so far. :)

Segfault crash in CON section.

The following Spin source will cause openspin to segfault with no indication of the syntax error:

CON
#

PUB start

Like so:

$ cat con_crash.spin
CON
#

PUB start

$ openspin con_crash.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2014 Parallax Inc. DBA Parallax     Semiconductor.
Version 1.00.71 Compiled on Nov 30 2014 07:40:47
Compiling...
con_crash.spin
Segmentation fault
$

This on Debian Wheezy.

Intent of DEV block designator?

When I created a method with 'dev' as a parameter, openspin failed to build, stating "error : Block designator must be in first column"
At first I thought I accidentally indented the method's PUB block designator, but it wasn't, and after paying closer attention to the error, I noticed it marked the offending item as 'dev'
I was puzzled, looking through my source, but then thought maybe it was something in openspin I wasn't aware of, so grepping found it defined as a block designator in PropellerCompiler/PropellerCompiler.cpp
I didn't see it mentioned in the README, so wasn't sure what it was?
It's not a showstopper for me - I have little issue with changing the name of my variable, but thought I'd raise the issue in case someone else encountered it.

case_limit

For some of my projects I need a higher case_limit (e.g. 256). Is there any reason to set this to 64?

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

$ /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?

CON limit

On the forums, it has been stated that there is a CON limit on OpenSpin of ~255 constants allowed in a program.

Are there any plans for this limit to be removed?

Automatic removal of unused methods from Spin objects.

Many object developers like to create general purpose objects with many more functions than needed because bstc automatically culls any functions from the final binary. This feature is a requirement for OpenSpin to be considered a compelling replacement for bstc.

Preprocessor clear defines

With the new function pp_clear_define_state in preprocess.c it is necessary to place the OBJ block before the first use (e.g. CON block with obj#constant). If I comment out pp_clear_define_state in preprocess.c, all sources are compiloe as before.

Allows #warn as an alias to #warning

This relates to Issue #33.

Add #warn as an alias to the #warning directive since there's an existing precedent in bstc for @warn.

Each should result in essentially the same output:

#warn User-Message-Here

generates

warning: #warn: User-Message-Here

and

#warning User-Message-Here

generates

warning: #warning: User-Message-Here

OpenSpin fails to detect circular dependencies

Hi Roy,

I wanted to report a little bug. OpenSpin does not detect when an object includes itself, either directly or indirectly. Instead, the compiler happily processes it until it meets the recursion limit, leading to output that is very scary for beginners (I got to experience this firsthand in a classroom).

I will add code in PropellerIDE to stop compilation, but it'd be nice if I didn't have to.

Thanks in advance for taking a look at it.

Compiling /home/brett/Projects/lamestation-sdk/library/demos/maps/01_DrawingMaps.spin
|-LameLCD.spin
  |-LamePinout.spin
|-LameGFX.spin
|-LameMap.spin
  |-LameGFX.spin
|-gfx_cave.spin
|-map_cave.spin
|-01_DrawingMaps.spin
  |-LameLCD.spin
    |-LamePinout.spin
  |-LameGFX.spin
  |-LameMap.spin
    |-LameGFX.spin
  |-gfx_cave.spin
  |-map_cave.spin
  |-01_DrawingMaps.spin
    |-LameLCD.spin
      |-LamePinout.spin
    |-LameGFX.spin
    |-LameMap.spin
      |-LameGFX.spin
    |-gfx_cave.spin
    |-map_cave.spin
    |-01_DrawingMaps.spin
      |-LameLCD.spin
        |-LamePinout.spin
      |-LameGFX.spin
      |-LameMap.spin
        |-LameGFX.spin
      |-gfx_cave.spin
      |-map_cave.spin
      |-01_DrawingMaps.spin
        |-LameLCD.spin
          |-LamePinout.spin
        |-LameGFX.spin
        |-LameMap.spin
          |-LameGFX.spin
        |-gfx_cave.spin
        |-map_cave.spin
        |-01_DrawingMaps.spin
          |-LameLCD.spin
            |-LamePinout.spin
          |-LameGFX.spin
          |-LameMap.spin
            |-LameGFX.spin
          |-gfx_cave.spin
          |-map_cave.spin
          |-01_DrawingMaps.spin
            |-LameLCD.spin
              |-LamePinout.spin
            |-LameGFX.spin
            |-LameMap.spin
              |-LameGFX.spin
            |-gfx_cave.spin
            |-map_cave.spin
            |-01_DrawingMaps.spin
              |-LameLCD.spin
                |-LamePinout.spin
              |-LameGFX.spin
              |-LameMap.spin
                |-LameGFX.spin
              |-gfx_cave.spin
              |-map_cave.spin
              |-01_DrawingMaps.spin
                |-LameLCD.spin
                  |-LamePinout.spin
                |-LameGFX.spin
                |-LameMap.spin
                  |-LameGFX.spin
                |-gfx_cave.spin
                |-map_cave.spin
                |-01_DrawingMaps.spin
                  |-LameLCD.spin
                    |-LamePinout.spin
                  |-LameGFX.spin
                  |-LameMap.spin
                    |-LameGFX.spin
                  |-gfx_cave.spin
                  |-map_cave.spin
                  |-01_DrawingMaps.spin
                    |-LameLCD.spin
                      |-LamePinout.spin
                    |-LameGFX.spin
                    |-LameMap.spin
                      |-LameGFX.spin
                    |-gfx_cave.spin
                    |-map_cave.spin
                    |-01_DrawingMaps.spin
                      |-LameLCD.spin
                        |-LamePinout.spin
                      |-LameGFX.spin
                      |-LameMap.spin
                        |-LameGFX.spin
                      |-gfx_cave.spin
                      |-map_cave.spin
                      |-01_DrawingMaps.spin
                        |-LameLCD.spin
                          |-LamePinout.spin
                        |-LameGFX.spin
                        |-LameMap.spin
                          |-LameGFX.spin
                        |-gfx_cave.spin
                        |-map_cave.spin
                        |-01_DrawingMaps.spin
                          |-LameLCD.spin
                            |-LamePinout.spin
                          |-LameGFX.spin
                          |-LameMap.spin
                            |-LameGFX.spin
                          |-gfx_cave.spin
                          |-map_cave.spin
                          |-01_DrawingMaps.spin
                            |-LameLCD.spin
                              |-LamePinout.spin
LamePinout.spin : error : Object nesting exceeds limit of 16 levels.

Invalid data after using res

Error description

I found a bug that leads to losing initial data when declaring and initializing a variable after a variable gets declared using only res.

Example

The following example is a working program that can be executed via cognew(…).
It lets an LED change its state each second.

CON
    _CLKMODE = xtal1 + pll16x
    _XINFREQ = 5_000_000

    LED_B = 27

PUB main
    cognew(@blinka, 0)
    cogstop(cogid)

DAT
            org     0
blinka      or      dira,   :led
            rdlong  :delay, #0
            mov     :clock, cnt
            add     :clock, #9
:loop       waitcnt :clock, :delay
            xor     outa,   :led
            jmp     #:loop

:led        long    |<      LED_B
:delay      long    80_000_000
:clock      res     1
            fit

When I exchange the following lines, the value of :delay gets lost without any warnings:

:led        long    |<      LED_B
:clock      res     1
:delay      long    80_000_000     ' :delay will  not  be set to 80'000'000
            fit

What I'd expected

I'd expect at least an error message from OpenSpin.

Further information

OpenSpin Version: 1.00.81:

openspin --version
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2018 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.81 Compiled on Jul  5 2019 09:30:36

Call of OpenSpin: No special flags set:

openspin -o $BINARY $SOURCE

FIT directive behvior differs from PropTool for some values

In testing a new SDRAM cache driver for PropGCC, I found that a particular way I was using the ORG+FIT directives, for a compile-time configuration validation check, generated an error in OpenSpin, when it seemed to work fine for both BST and the Propeller Tool.

For example, to make sure a compile-time configuration setting is in an acceptable range, I use the ORG + FIT directives to make sure that a constant has a power-of-two value:

org 1
' The CACHE_SIZE_BYTES must be a power of two.
' Error means CACHE_SIZE_BYTES is not a power of 2
fit (CACHE_SIZE_BYTES == |< ((>| CACHE_SIZE_BYTES)-1))

The above works fine with BST and PropTool, but generates an error with OpenSpin.

This can be worked around using the absolute value operator (||):

fit ||(CACHE_SIZE_BYTES == |< ((>| CACHE_SIZE_BYTES)-1))

I was just surprised that this was needed.

I have/will upload a full test program that shows the inconsistency to the Parallax forums.

I suspect that both BST and the Propeller Tool treat the ORG-FIT comparison as an unsigned comparison, while (I know that) OpenSpin performs a signed comparison. Furthermore, the difference for $20000000 is because OpenSpin converts the COG addresses to "byte" offsets by left-shifting them by 2 bits, so all values in the $20000000..$3FFFFFFF range will become negative from that shift, thereby failing the signed comparison.

OpenSpin accepts constants that exceed 32 bits

The following program compiles successfully with OpenSpin:

pub main | x
x := $FF_FF_FF_FF_FF

The program should not compile, because it attempts to store a 40-bit constant into 'x'.
An attempt to compile with the Propeller tool returns this error:

Constant exceeds 32 bits.

OpenSpin should generate a similar error.

Add #info directive

Add an #info directive the generates an information message during compilation; much the same way as #warning does (non-fatal message event) but implies less serious nature.

#info User-Information-Message-Here

generates

info: #info: User-Information-Message-Here

Memory leaks

Running openspin compiled with clang and using LeakSanitizer we get the following memory leaks detected. Duplicates have been removed.

See: https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer

==23654==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1113216 byte(s) in 8676 object(s) allocated from:
#0 0x47d2bb in realloc /home/michael/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:96
#1 0x4a87bb in flexbuf_addmem(flexbuf_, char const_, unsigned long) /home/michael/OpenSpin/SpinSource/flexbuf.c:58
#2 0x4a8f7f in flexbuf_addstr(flexbuf_, char const_) /home/michael/OpenSpin/SpinSource/flexbuf.c:71
#3 0x4b2fe4 in expand_macros(preprocess_, flexbuf_, char_) /home/michael/OpenSpin/SpinSource/preprocess.c:584
#4 0x4b081f in do_line(preprocess_) /home/michael/OpenSpin/SpinSource/preprocess.c:793
#5 0x4aff43 in pp_run(preprocess_) /home/michael/OpenSpin/SpinSource/preprocess.c:848
#6 0x496963 in LoadFile(char_, int_) /home/michael/OpenSpin/SpinSource/openspin.cpp:138
#7 0x497990 in GetPASCIISource(char_) /home/michael/OpenSpin/SpinSource/openspin.cpp:195
#8 0x49956e in CompileRecursively(char_, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:276
#9 0x499e94 in CompileRecursively(char_, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:307
#10 0x499e94 in CompileRecursively(char*, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:307
#11 0x4a3549 in main /home/michael/OpenSpin/SpinSource/openspin.cpp:787
#12 0x7f9c3e050eac in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eeac)

Direct leak of 480 byte(s) in 15 object(s) allocated from:
#0 0x47da31 in operator new(unsigned long) /home/michael/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:62
#1 0x5217b8 in HashTable::Insert(int, Hashable_) /home/michael/OpenSpin/PropellerCompiler/./Utilities.h:130
#2 0x51fd2a in SymbolEngine::AddSymbol(char const_, symbolType, int, int, bool) /home/michael/OpenSpin/PropellerCompiler/SymbolEngine.cpp:410
#3 0x4c91ee in CompileObjSymbols() /home/michael/OpenSpin/PropellerCompiler/PropellerCompiler.cpp:964
#4 0x4c66dc in Compile2() /home/michael/OpenSpin/PropellerCompiler/PropellerCompiler.cpp:160
#5 0x49acbe in CompileRecursively(char_, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:369
#6 0x499e94 in CompileRecursively(char_, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:307
#7 0x499e94 in CompileRecursively(char*, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:307
#8 0x4a3549 in main /home/michael/OpenSpin/SpinSource/openspin.cpp:787
#9 0x7f9c3e050eac in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eeac)

Indirect leak of 118 byte(s) in 13 object(s) allocated from:
#0 0x47db41 in operator new[](unsigned long) /home/michael/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64
#1 0x51f3c0 in SymbolEngine::AddSymbol(char const_, symbolType, int, int, bool) /home/michael/OpenSpin/PropellerCompiler/SymbolEngine.cpp:394
#2 0x4c91ee in CompileObjSymbols() /home/michael/OpenSpin/PropellerCompiler/PropellerCompiler.cpp:964
#3 0x4c66dc in Compile2() /home/michael/OpenSpin/PropellerCompiler/PropellerCompiler.cpp:160
#4 0x49acbe in CompileRecursively(char_, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:369
#5 0x499e94 in CompileRecursively(char*, bool, bool) /home/michael/OpenSpin/SpinSource/openspin.cpp:307
#6 0x4a3549 in main /home/michael/OpenSpin/SpinSource/openspin.cpp:787
#7 0x7f9c3e050eac in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x1eeac)

SUMMARY: AddressSanitizer: 5008997 byte(s) leaked in 39070 allocation(s).

ER: Add an option that displays the openspin version number

Often difficult to know what version of a compiler is installed on a system. Would be helpful to include a command-line option to display the compiler version. Currently, compiled output gives a "Compiled On" date but, a version/revision number would be better. Looks like "-v" is use to set verbose logging. Could possibly use "-V" or "-r" (revision)...

Just a thought!

Thanks
dgately

Preprocessor directives throw error when child object contains specific pattern of characters

Consider the following objects

top.spin:

#define PREPROC_SYMB

OBJ

    ch : "child"

PUB Main

child.spin:

PUB Null

DAT

alabel  byte "{|}", 0

The compiler aborts with the error:

Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2018 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.81 Compiled on Sep  3 2018 09:56:10
Compiling...
openspin-preproc-dat-bug.spin
|-child.spin
openspin-preproc-dat-bug.spin(1:8) : error : Expected "," or end of line
Line:
#define PREPROC_SYMB
Offending Item: PREPROC_SYMB

shell returned 1

I narrowed down the source of the issue to the line in the child object that defines the data, specifically the "{|}"

  • Simply commenting the line out has no effect. If the offending text is removed, or redefined such that each character is enclosed in its own quotes (i.e., "{", "|", "}"), build is successful.
  • Defining the same data in the top object doesn't exhibit the issue.

Could this be clashing with OpenSpin's comment processing code somehow?

(for reference, this was first discovered in a derivative of the PS/2 keyboard driver from the original Propeller Tool library's Keyboard.spin, and the problem also manifests in that original version)

"test" instruction with "ina" as first operand does not work

I once again spent days of debugging a problem a simple warning or an error could have avoided.

Description of the Problem

I had the following code in a function that should read data from an SPI device:

test    ina,  :pin_miso   WZ

My problem was that I got no data from that device, I always received 0-Bytes.
I then connected an FPGA between the SPI Device and the Propeller to observe the communication and figured out, that the whole communication worked.
After flipping the operands I finally got the valid response in the Propeller:

test    :pin_miso,  ina   WZ

Investigation of the Problems Origin

The documentation explicitly writes about the test command that it does not perform writing, so I was not concerned about the order of operands.:

Explanation
TEST is similar to AND except it doesn’t write a result to Value1; [..]

Anyway, in the description of the ina register, the following warning was spoken:

[..] Do not use INA as the destination operand; that only results in reading and modifying the shadow register whose address INA occupies. [..]

Suggestion as Solution

Obviously the assembler knows that this was an invalid use of the test instruction to access the ina register.
A warning like: "WARNING: Invalid use of ina register. ina should only be used as source register." would have helped a lot.

Environment

Version 1.00.81 Compiled on Jul  5 2019 09:30:36

Compiler throws no warning if invalid boolean operators used

A common mistake I make writing spin code is the use of Spin's unusual greater-than/less-than operators.

I frequenty mistype:

>=
<=

When it should be:

=>
=<

However, Spin compilers rarely seem to pick up on this and other syntax issues, allowing programs to successfully compile then silently fail. This is a trap for users unfamiliar with Spin's quirkiness.

Stricter syntax checking should be implemented to make the language less susceptible to this kind of mistake.

Memory access alignment errors.

There are a number of memory alignment errors. Mostly caused by casting from char pointers into ints or shorts whilst accessing various data structures.

Whist this is not an issue on most modern architectures it does cause a large slowdown in openspin when compiled to JavaScript and run in a browser environment.

The following is a grep of all the offending misaligned accesses found so far. They are marked with "FIXME Alignment error." Line numbers are only approximate as they changed a bit when instrumenting the code.

DistillObjects.cpp:212: memmove(&g_pCompilerData->dis[disPtr], &g_pCompilerData->dis[disPtr + (3 + numSubObjects)], (g_pCompilerData->dis_ptr - disPtr) * 2); // FIXME: Aligment error.

PropellerCompiler.cpp:911: short vsize = ((short)(&pData[0])); // FIXME: Alignment Error.

PropellerCompiler.cpp:912: short psize = ((short)(&pData[2])); // FIXME: Alignment error.

PropellerCompiler.cpp:962: int value = ((int)(&pData[1])); // FIXME: Alignment error.

PropellerCompiler.cpp:1412: unsigned char* pObj = &(g_pCompilerData->obj_data[g_pCompilerData->obj_offsets[i]]); // FIXME Alignment error.

PropellerCompiler.cpp:1418: objvar[i] = (int)(((unsigned short)(pObj))); // FIXME: Alignment error.

PropellerCompiler.cpp:1426: unsigned short psize = ((unsigned short)(pObj)); // FIXME: Alignment error.

StringConstantRoutines.cpp:102: ((short)&(g_pCompilerData->obj[g_pCompilerData->str_patch[strIndex]])) = strAddress; // FIXME: Aligment error.

Utilities.cpp:264: ((int)pSymbol) = temp; // FIXME Alignment error.

#define vs Newton and Schroedinger and his cat (Milton)

Newton has no cat (subobject):

$ cat Newton.spin 
#ifdef X
#warning X defined
#endif

#ifndef X
#warning X not defined
#endif

pub Newton

Compiling without defining X looks ok:

$ /opt/openspin/bin/openspin Newton.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Newton.spin
Newton.spin:6: warning: #warn:  X not defined
Done.
Program size is 28 bytes

Compiling with -D(-efining) X and with and without -a(-lternative preprocesor) looks ok too...

$ /opt/openspin/bin/openspin -D X Newton.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Newton.spin
Newton.spin:2: warning: #warn:  X defined
Done.
Program size is 28 bytes
$ /opt/openspin/bin/openspin -a -D X Newton.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Newton.spin
Newton.spin:2: warning: #warn:  X defined
Done.
Program size is 28 bytes

Now adding -u(-ncertainty):

$ /opt/openspin/bin/openspin -u -D X Newton.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Newton.spin
Newton.spin:2: warning: #warn:  X defined
Newton.spin:6: warning: #warn:  X not defined
Done.
Unused Method Elimination:
Nothing removed.
--------------------------
Program size is 28 bytes
$ /opt/openspin/bin/openspin -u -a -D X Newton.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Newton.spin
Newton.spin:2: warning: #warn:  X defined
Newton.spin:6: warning: #warn:  X not defined
Done.
Unused Method Elimination:
Nothing removed.
--------------------------
Program size is 28 bytes

But now for something not really completely different:

Schroedinger has a cat (subobject):

$ cat Schroedinger.spin 
#ifdef X
#warning X defined
#endif

#ifndef X
#warning X not defined
#endif

obj

  cat : "Milton"

pub Schroedinger
$ cat Milton.spin 
#ifdef X
#warning X defined
#endif

#ifndef X
#warning X not defined
#endif

pub Milton

Compiling without a define and without -u(-ncertainty):

$ /opt/openspin/bin/openspin Schroedinger.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Schroedinger.spin
Schroedinger.spin:6: warning: #warn:  X not defined
|-Milton.spin
Milton.spin:6: warning: #warn:  X not defined
Schroedinger.spin:6: warning: #warn:  X not defined
Done.
Program size is 44 bytes

Compiling with defining X and not using -u(-ncertainty):

$ /opt/openspin/bin/openspin -D X Schroedinger.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Schroedinger.spin
Schroedinger.spin:2: warning: #warn:  X defined
|-Milton.spin
Milton.spin:6: warning: #warn:  X not defined
Schroedinger.spin:6: warning: #warn:  X not defined
Done.
Program size is 44 bytes
$ /opt/openspin/bin/openspin -a -D X Schroedinger.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Aug 15 2017 15:07:36
Compiling...
Schroedinger.spin
Schroedinger.spin:2: warning: #warn:  X defined
|-Milton.spin
Milton.spin:6: warning: #warn:  X not defined
Schroedinger.spin:6: warning: #warn:  X not defined
Done.
Program size is 44 bytes

This is confusing enough, so adding -u(-ncertainty) is not needed to make my head spin...

Meow!

Can please someone explain this to me without using quantum physics?

Undefined object name symbol

I just tried switching from BSTC to OpenSpin for compiling the Spin portions of xbasic and am running into a problem. I get an "undefined symbol 'vm'" error when compiling this code:

CON

  ' make some vm_interface constants available
  _MBOX_SIZE = vm#_MBOX_SIZE
  _STATE_SIZE = vm#_STATE_SIZE
  FLASH_BASE = vm#FLASH_BASE
  RAM_BASE = vm#RAM_BASE
  HUB_BASE = vm#HUB_BASE

  ' character codes
  CR = $0d
  LF = $0a

OBJ
  ser : "FullDuplexSerial"
  vm : "vm_interface"

PUB init_serial(baudrate, rxpin, txpin)
  ser.start(rxpin, txpin, 0, baudrate)

PUB init(mbox, state, code, data, cache_mbox, cache_line_mask) | params[vm#_INIT_SIZE]
  params[vm#INIT_BASE] := data
  params[vm#INIT_STATE] := state
  params[vm#INIT_MBOX] := mbox
  params[vm#INIT_CACHE_MBOX] := cache_mbox
  params[vm#INIT_CACHE_MASK] := cache_line_mask
  vm.start(code, @params)

Here is the error message:

Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.80 Compiled on Sep 29 2016 10:35:12
Compiling...
spin/serial_helper.spin
|-packet_driver.spin
|-vm_runtime.spin
vm_runtime.spin(21:73) : error : Undefined symbol
Line:
PUB init(mbox, state, code, data, cache_mbox, cache_line_mask) | params[vm#_INIT_SIZE]
Offending Item: vm

I built OpenSpin from sources cloned today from github so it should be the latest version.

Excessively large input object causes stack overflow

Hi there,

I stumbled across this trying to compile a way-too-large LameStation image into an object. OpenSpin detects the error properly but does a core dump instead of exiting gracefully, which then triggers the OS error reporting mechanism (making it seem like something horrible just happened). Just thought I should let you know.

Click here to download the offending file.

$ ../OpenSpin/build/openspin gfx_Blit.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.78 Compiled on Mar 25 2016 17:21:58
Compiling...
gfx_Blit.spin
gfx_Blit.spin(525:740) : error : Object exceeds 128k (before distilling)
Line:
word    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$5555,$5555,$0000,$0000,$0000,$0000,$0000,$0000,$5555,$0000,$0000,$0000,$5555,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$5555,$0000,$5555,$0000,$5555,$0000,$5555,$0000,$5555,$0000,$5555,$0000,$0000,$0000,$5555,$5555,$5555,$5555,$5555,$5555,$5555,$5555,$5555,$5555,$5555,$0000,$0000,$0000,$0000,$5555,$0000,$0000,$5555,$5555,$0000,$0000,$0000 ' ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
Offending Item: ,
*** stack smashing detected ***: ../OpenSpin/build/openspin terminated
Aborted (core dumped)

Version 1.00.72 segfaults when building Pikemanz

I built from fresh copies of the mainline to be sure.

A distribution of Pikemanz can be found here:
http://lamestation.net/downloads/misc/spin/Pikemanz.zip

The error in action:

$ ./build/openspin ../../00_Pikemanz.spin -L ../../../..
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2015 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.72 Compiled on Apr 10 2015 04:10:27
Compiling...
../../00_Pikemanz.spin
|-LameLCD.spin
  |-Pinout.spin
|-LameGFX.spin
|-LameAudio.spin
  |-Pinout.spin
|-LameMusic.spin
  |-LameAudio.spin
    |-Pinout.spin
|-LameControl.spin
  |-Pinout.spin
  |-LameFunctions.spin
|-PikeState.spin
|-01_Title.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-PikeState.spin
  |-PikeMenu.spin
    |-LameGFX.spin
    |-LameLCD.spin
      |-Pinout.spin
    |-LameControl.spin
      |-Pinout.spin
      |-LameFunctions.spin
    |-LameFunctions.spin
    |-gfx_dialog.spin
    |-gfx_bar.spin
    |-gfx_healthbar.spin
    |-gfx_health.spin
    |-gfx_font6x6_b.spin
  |-gfx_title.spin
  |-gfx_font6x6_b.spin
  |-gfx_nash_fetchum.spin
|-02_Intro.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameMap.spin
    |-LameGFX.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-LameFunctions.spin
  |-PikeState.spin
  |-PikeMenu.spin
    |-LameGFX.spin
    |-LameLCD.spin
      |-Pinout.spin
    |-LameControl.spin
      |-Pinout.spin
      |-LameFunctions.spin
    |-LameFunctions.spin
    |-gfx_dialog.spin
    |-gfx_bar.spin
    |-gfx_healthbar.spin
    |-gfx_health.spin
    |-gfx_font6x6_b.spin
  |-gfx_nash_fetchum.spin
  |-gfx_arrow_d.spin
|-03_World.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameMap.spin
    |-LameGFX.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-LameFunctions.spin
  |-PikeState.spin
  |-gfx_nash.spin
  |-map_parrot_town.spin
  |-map_path1.spin
  |-map_path2.spin
  |-gfx_pikeman.spin
|-04_Battle.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameAudio.spin
    |-Pinout.spin
  |-LameMusic.spin
    |-LameAudio.spin
      |-Pinout.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-LameFunctions.spin
  |-PikeState.spin
  |-PikeMenu.spin
    |-LameGFX.spin
    |-LameLCD.spin
      |-Pinout.spin
    |-LameControl.spin
      |-Pinout.spin
      |-LameFunctions.spin
    |-LameFunctions.spin
    |-gfx_dialog.spin
    |-gfx_bar.spin
    |-gfx_healthbar.spin
    |-gfx_health.spin
    |-gfx_font6x6_b.spin
  |-PikeManager.spin
    |-LameGFX.spin
  |-Pikedox.spin
    |-PikeManager.spin
      |-LameGFX.spin
    |-gfx_pk_pakechu2.spin
    |-gfx_pk_adheri.spin
    |-gfx_pk_blardicuino.spin
    |-gfx_pk_ghosterman.spin
    |-gfx_pk_jarzzard.spin
    |-gfx_pk_mootoo.spin
    |-gfx_pk_pakechu.spin
    |-gfx_pk_pangueen.spin
    |-gfx_pk_phonyx.spin
    |-gfx_pk_tornadoo.spin
  |-gfx_arrow.spin
  |-gfx_dialog.spin
  |-gfx_bar.spin
  |-gfx_healthbar.spin
  |-gfx_health.spin
  |-gfx_hp.spin
  |-gfx_font6x6_b.spin
  |-gfx_black.spin
Segmentation fault (core dumped)

1.00.71 builds it just fine.

$ ./OpenSpin-1.00.71/openspin -L ../.. 00_Pikemanz.spin 
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2014 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.71 Compiled on Apr 10 2015 03:57:42
Compiling...
00_Pikemanz.spin
|-LameLCD.spin
  |-Pinout.spin
|-LameGFX.spin
|-LameAudio.spin
  |-Pinout.spin
|-LameMusic.spin
  |-LameAudio.spin
    |-Pinout.spin
|-LameControl.spin
  |-Pinout.spin
  |-LameFunctions.spin
|-PikeState.spin
|-01_Title.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-PikeState.spin
  |-PikeMenu.spin
    |-LameGFX.spin
    |-LameLCD.spin
      |-Pinout.spin
    |-LameControl.spin
      |-Pinout.spin
      |-LameFunctions.spin
    |-LameFunctions.spin
    |-gfx_dialog.spin
    |-gfx_bar.spin
    |-gfx_healthbar.spin
    |-gfx_health.spin
    |-gfx_font6x6_b.spin
  |-gfx_title.spin
  |-gfx_font6x6_b.spin
  |-gfx_nash_fetchum.spin
|-02_Intro.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameMap.spin
    |-LameGFX.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-LameFunctions.spin
  |-PikeState.spin
  |-PikeMenu.spin
    |-LameGFX.spin
    |-LameLCD.spin
      |-Pinout.spin
    |-LameControl.spin
      |-Pinout.spin
      |-LameFunctions.spin
    |-LameFunctions.spin
    |-gfx_dialog.spin
    |-gfx_bar.spin
    |-gfx_healthbar.spin
    |-gfx_health.spin
    |-gfx_font6x6_b.spin
  |-gfx_nash_fetchum.spin
  |-gfx_arrow_d.spin
|-03_World.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameMap.spin
    |-LameGFX.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-LameFunctions.spin
  |-PikeState.spin
  |-gfx_nash.spin
  |-map_parrot_town.spin
  |-map_path1.spin
  |-map_path2.spin
  |-gfx_pikeman.spin
|-04_Battle.spin
  |-LameLCD.spin
    |-Pinout.spin
  |-LameGFX.spin
  |-LameAudio.spin
    |-Pinout.spin
  |-LameMusic.spin
    |-LameAudio.spin
      |-Pinout.spin
  |-LameControl.spin
    |-Pinout.spin
    |-LameFunctions.spin
  |-LameFunctions.spin
  |-PikeState.spin
  |-PikeMenu.spin
    |-LameGFX.spin
    |-LameLCD.spin
      |-Pinout.spin
    |-LameControl.spin
      |-Pinout.spin
      |-LameFunctions.spin
    |-LameFunctions.spin
    |-gfx_dialog.spin
    |-gfx_bar.spin
    |-gfx_healthbar.spin
    |-gfx_health.spin
    |-gfx_font6x6_b.spin
  |-PikeManager.spin
    |-LameGFX.spin
  |-Pikedox.spin
    |-PikeManager.spin
      |-LameGFX.spin
    |-gfx_pk_pakechu2.spin
    |-gfx_pk_adheri.spin
    |-gfx_pk_blardicuino.spin
    |-gfx_pk_ghosterman.spin
    |-gfx_pk_jarzzard.spin
    |-gfx_pk_mootoo.spin
    |-gfx_pk_pakechu.spin
    |-gfx_pk_pangueen.spin
    |-gfx_pk_phonyx.spin
    |-gfx_pk_tornadoo.spin
  |-gfx_arrow.spin
  |-gfx_dialog.spin
  |-gfx_bar.spin
  |-gfx_healthbar.spin
  |-gfx_health.spin
  |-gfx_hp.spin
  |-gfx_font6x6_b.spin
  |-gfx_black.spin
Done.
Program size is 18364 bytes

BSTC builds it fine.

$ bstc.linux -L ../.. 00_Pikemanz.spin 
Found a USB Serial Device
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 00_Pikemanz
Loading Object LameLCD
Loading Object Pinout
Loading Object LameGFX
Loading Object LameAudio
Loading Object LameMusic
Loading Object LameControl
Loading Object LameFunctions
Loading Object PikeState
Loading Object 01_Title
Loading Object PikeMenu
Loading Object gfx_dialog
Loading Object gfx_bar
Loading Object gfx_healthbar
Loading Object gfx_health
Loading Object gfx_font6x6_b
Loading Object gfx_title
Loading Object gfx_nash_fetchum
Loading Object 02_Intro
Loading Object LameMap
Loading Object gfx_arrow_d
Loading Object 03_World
Loading Object gfx_nash
Loading Object map_parrot_town
Loading Object map_path1
Loading Object map_path2
Loading Object gfx_pikeman
Loading Object 04_Battle
Loading Object PikeManager
Loading Object Pikedox
Loading Object gfx_pk_pakechu2
Loading Object gfx_pk_adheri
Loading Object gfx_pk_blardicuino
Loading Object gfx_pk_ghosterman
Loading Object gfx_pk_jarzzard
Loading Object gfx_pk_mootoo
Loading Object gfx_pk_pakechu
Loading Object gfx_pk_pangueen
Loading Object gfx_pk_phonyx
Loading Object gfx_pk_tornadoo
Loading Object gfx_arrow
Loading Object gfx_hp
Loading Object gfx_black
Program size is 18360 longs
Compiled 3715 Lines of Code in 0.16 Seconds

Here's a backtrace. The error is happening somewhere in your new code.

(gdb) trace
Tracepoint 1 at 0x7ffff6935c8d: file ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S, line 40.
(gdb) backtrace
#0  __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40
#1  0x00000000004184fd in AddObjectName (pFilename=0x7fffffffa1a0 "gfx_black.spin", indent=3) at ../PropellerCompiler/UnusedMethodUtils.cpp:38
#2  0x0000000000402ff4 in CompileRecursively (pFilename=0x7fffffffa1a0 "gfx_black.spin", bQuiet=false, bFileTreeOutputOnly=false) at openspin.cpp:261
#3  0x00000000004031b5 in CompileRecursively (pFilename=0x7fffffffba20 "04_Battle.spin", bQuiet=false, bFileTreeOutputOnly=false) at openspin.cpp:296
#4  0x00000000004031b5 in CompileRecursively (pFilename=0xe7b978 "/home/brett/Projects/lamestation-sdk/games/Pikemanz/00_Pikemanz.spin", bQuiet=false, bFileTreeOutputOnly=false)
    at openspin.cpp:296
#5  0x0000000000406134 in main (argc=4, argv=0x7fffffffdf38) at openspin.cpp:746

It's always failing on that one file, but unfortunately there's nothing particularly exciting about this file.

open("gfx_black.spin", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("/home/brett/Projects/lamestation-sdk//gfx_black.spin", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/brett/Projects/lamestation-sdk/games/Pikemanz/gfx_black.spin", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0664, st_size=607, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc6af76a000
fstat(6, {st_mode=S_IFREG|0664, st_size=607, ...}) = 0
lseek(6, 0, SEEK_SET)                   = 0
read(6, "' ******************************"..., 607) = 607
lseek(6, 607, SEEK_SET)                 = 607
close(6)                                = 0
munmap(0x7fc6af76a000, 4096)            = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x60f72c8abc} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

OBJ files search order is not the same as Propeller Tool

I have a few large projects that I developed with the old Propeller Tool. When I tried compiling some of them with PropellerIDE (latest version from Github), I got some weird errors.

As it turns out, I had named one of my modules "clock.spin" and there is already such a module in the Spin libraries that are included with PropellerIDE. Both BSTC and the OpenSpin compiler found that library module before they found my module, so I got a weird error because it didn't recognize a subroutine name.

Obviously the workaround is to rename the module or put "." at the top of the include path, so it's a minor problem (though the weird error message didn't give any hints about why the subroutine name was wrong, which made it a major problem for me). But this has the potential of breaking user code in the future: Imagine a user has a module XYZZY.spin and then the team that works on the Spin libraries decides to introduce a module with the same name. As soon as the user installs the latest PropellerIDE, their existing source code stops working with no clear explanation, because the XYZZY.spin that the compiler now finds, is the one in the libraries, instead of the one that the user wrote.

The fix is to let the compiler look for modules mentioned in the OBJ section in the current directory first, before it searches in the include paths. This is how Propeller Tool worked, too. The chance that this would break existing code is minimal.

Sorry if this problem has already been addressed. I'm aware that PropellerIDE may not have the latest OpenSpin compiler.

Crash and strange behavior

Source Files:

Here's a Lamestation piXel game folder I modified to contain all the files in one place: piXel.zip
I don't know if my modification has anything to do with the behavior listed below.

Problem

On my Win 7 64-bit host, compiling piXel.spin with OpenSpin v1.0.77 ends with a "Done." message and then a Windows System crash message:

C:\piXel>openspin_v1.00.77 -u piXel.spin
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2015 Parallax Inc. DBA Parallax
Semiconductor.
Version 1.00.77 Compiled on May 29 2015 02:19:57
Compiling...
piXel.spin
|-LameLCD.spin
  |-LamePinout.spin
|-LameGFX.spin
|-LameText.spin
  |-LameGFX.spin
|-LameMap.spin
  |-LameGFX.spin
|-LameAudio.spin
  |-LamePinout.spin
|-LameMusic.spin
  |-LameAudio.spin
    |-LamePinout.spin
|-LameControl.spin
  |-LamePinout.spin
  |-LameFunctions.spin
|-LameFunctions.spin
|-piXel_Effects.spin
  |-LameGFX.spin
  |-piXel_Sound.spin
    |-LameAudio.spin
      |-LamePinout.spin
    |-LameFunctions.spin
  |-gfx_boom.spin
|-piXel_Sound.spin
  |-LameAudio.spin
    |-LamePinout.spin
  |-LameFunctions.spin
|-gfx_player_small.spin
|-gfx_ibot.spin
|-gfx_idrone.spin
|-gfx_tank.spin
|-gfx_macrosoth.spin
|-gfx_laser.spin
|-gfx_bullet.spin
|-gfx_head.spin
|-gfx_healthbar.spin
|-gfx_starmap.spin
|-gfx_pixmain.spin
|-font8x8.spin
|-gfx_tiles_pixel.spin
|-song_pixeltheme.spin
|-song_sad.spin
|-song_ohno.spin
|-song_superohno.spin
|-song_boss.spin
|-song_yeah.spin
|-map_pixel.spin
Done.

image
There is no .binary produced by this action.

Using OpenSpin v1.0.78 instead seems to work better (no crash message) but the output is strange in that it reports "Done." twice. It does indeed produce a .binary file in this case.

C:\piXel>openspin_v1.00.78 -u piXel.spin
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2016 Parallax Inc. DBA Parallax
Semiconductor.
Version 1.00.78 Compiled on Jan 16 2016 15:37:47
Compiling...
piXel.spin
|-LameLCD.spin
  |-LamePinout.spin
|-LameGFX.spin
|-LameText.spin
  |-LameGFX.spin
|-LameMap.spin
  |-LameGFX.spin
|-LameAudio.spin
  |-LamePinout.spin
|-LameMusic.spin
  |-LameAudio.spin
    |-LamePinout.spin
|-LameControl.spin
  |-LamePinout.spin
  |-LameFunctions.spin
|-LameFunctions.spin
|-piXel_Effects.spin
  |-LameGFX.spin
  |-piXel_Sound.spin
    |-LameAudio.spin
      |-LamePinout.spin
    |-LameFunctions.spin
  |-gfx_boom.spin
|-piXel_Sound.spin
  |-LameAudio.spin
    |-LamePinout.spin
  |-LameFunctions.spin
|-gfx_player_small.spin
|-gfx_ibot.spin
|-gfx_idrone.spin
|-gfx_tank.spin
|-gfx_macrosoth.spin
|-gfx_laser.spin
|-gfx_bullet.spin
|-gfx_head.spin
|-gfx_healthbar.spin
|-gfx_starmap.spin
|-gfx_pixmain.spin
|-font8x8.spin
|-gfx_tiles_pixel.spin
|-song_pixeltheme.spin
|-song_sad.spin
|-song_ohno.spin
|-song_superohno.spin
|-song_boss.spin
|-song_yeah.spin
|-map_pixel.spin
Done.
|-LameLCD.spin
|-LameGFX.spin
|-LameText.spin
  |-LameGFX.spin
|-LameMap.spin
  |-LameGFX.spin
|-LameAudio.spin
|-LameMusic.spin
  |-LameAudio.spin
|-LameControl.spin
  |-LameFunctions.spin
|-LameFunctions.spin
|-piXel_Effects.spin
  |-LameGFX.spin
  |-piXel_Sound.spin
    |-LameAudio.spin
    |-LameFunctions.spin
  |-gfx_boom.spin
|-piXel_Sound.spin
  |-LameAudio.spin
  |-LameFunctions.spin
|-gfx_player_small.spin
|-gfx_ibot.spin
|-gfx_idrone.spin
|-gfx_tank.spin
|-gfx_macrosoth.spin
|-gfx_laser.spin
|-gfx_head.spin
|-gfx_healthbar.spin
|-gfx_starmap.spin
|-gfx_pixmain.spin
|-font8x8.spin
|-gfx_tiles_pixel.spin
|-song_pixeltheme.spin
|-song_sad.spin
|-song_ohno.spin
|-song_superohno.spin
|-song_boss.spin
|-song_yeah.spin
|-map_pixel.spin
Done.
Program size is 23392 bytes

OpenSpin accepts constant values larger than 32 bits

in PropTool, when constants exceed the maximum number of bits, the compiler complains.

OpenSpin, it quietly accepts it even though the result is undefined. I played around with it and discovered that OpenSpin will apparently accept values of any size, no matter how large, like $111111111100000000000000000000000000.

Add warning system

This is a reminder for a future task to be performed at an as-of-yet unscheduled time. For now, this is a discussion item only.

Implement a warning system, in addition to the existing error feature, within the compiler. This involves a number of considerations:

  • Multiple warnings per compilation need be possible
    • Current system relies on a single fault (error) then exit; this will likely have to be extended
  • Warning suppression
    • Ability for user to suppress warnings of certain types (when they know what they are doing and tire of particular warnings)
      • Consider command-line and/or source code features to do this
    • Never completely hide existence of warnings; ie: when any warnings were suppressed during compilation, and final warning indicating that some warnings were suppressed should appear (and that final warning should not be suppressable).
  • Should multiple errors be shown (rather than just one)?
    • Not recommended; systems like that often display many errors that are a phantom related directly to the first error.
  • Unique message codes (error, warning, info) need be implemented to allow for specific warning suppression by ID rather than requiring that specific symbolic IDs be created for that purpose.

Openspin Build Fails on Fedora21

Getting this error, my hair is wet, and I can't do a thing with either of them ....
gcc and gcc-c++ are definitely installed.

ar: creating /home/sdenson/git/propeller-gcc/propeller-gcc/openspin/build/PropellerCompiler/libopenspin.a
make[1]: Leaving directory '/home/sdenson/git/propeller-gcc/propeller-gcc/openspin/PropellerCompiler'
g++ -o ./build/openspin -Wall -g -static ./build/openspin.o ./build/flexbuf.o ./build/preprocess.o ./build/textconvert.o ./build/pathentry.o ./build/objectheap.o ./build/PropellerCompiler/libopenspin.a
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Makefile:44: recipe for target 'all' failed
make: *** [all] Error 1
[sdenson@localhost openspin]$

Add summary and detail in Unused Method Removal results

Add a report summary that displays by default when a -u (Unused Method Removal) operation is performed, and an optional details report (via -v(erbose) switch).

The summary report appears after the object hierarchy:

<hierarchy structure here>
Optimized out # unused objects.
Optimized out # unused methods.
Optimization saved # longs.

where # is replaced by the actual number of objects, methods, and longs involved.

When -u is used with -v, it can report in a verbose way, such as:

Removed unused objects:
  parent1.object1
  parent1.child.object2
  parent2.child.child.object2
  parent2.child.object1
  parent3.object2
Removed unused methods:
  object3.method1
  object3.method2
  object4.method1
  object4.method5
  object4.method9
--------
Optimized out 2 unused objects.
Optimized out 5 unused methods.
Optimization saved # longs.

Note that it does not count the methods of completely removed objects in the tally of unused method.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.