Odd BST behavior
Mike Green
Posts: 23,101
I have BST 0.19.4-pre12 for the MacOS. I took the F32 demo and modified FloatString and the demo program to use just F32. When I compile it using the "Compile information" menu item, I get a dependency chart that's missing the F32 entry under FloatString. This is regardless of whether the optimization to eliminate unused methods is on or off. The Propeller Tool properly shows F32 under FloatString as well as under the main program.
Attached is the archive that demonstrates this. The problem originally showed up in a much larger and more complex program that I was modifying to use F32.
Attached is the archive that demonstrates this. The problem originally showed up in a much larger and more complex program that I was modifying to use F32.
Comments
Your modified FloatString uses F32, but never calls F32.start. Will that be a problem since F32 uses a cog?
That's a good catch, but it solves a different problem. The few variables in F32 should have been moved to a DAT section rather than a VAR section so there's only one copy no matter how many times F32 is included in the object tree. That way, only the main program needs to start up the cog. All other uses of F32 refer to the same (already running) cog. Unfortunately, fixing that doesn't seem to change the way BST displays the object tree. F32 is still missing under FloatString.
Here's the version with F32 using a DAT section.
Jonathan
Also (and I hope this isn't hijacking the thread. I'll start a new thread if you prefer) if you use your modified F32 as a singleton does that not create a potential race condition if F32 is being accessed from processes in multiple cogs?
This is one of those "natural situations" (running two copies of F32) where an object (F32) needs to be referenced from more than one object (Main and FloatString) and there are legitimate reasons why some of these references should be to one instance and other references should be to another instance and there's no way to specify that or make it happen. The code involved (F32) is identical in all instances and ought to be shared. It can be done by duplicating source code with different file names, but that's a cludge.
It takes more than different files names to force inclusion of separate load modules -- at least for the Prop Tool. Chip's compiler actually compares the object code generated by different objects and, when there's an exact match, includes only one in the build. You'd have to change the source code slightly to force two copies.
-Phil