Shop OBEX P1 Docs P2 Docs Learn Events
-ffunction-sections -fdata-sections don't work with cogc — Parallax Forums

-ffunction-sections -fdata-sections don't work with cogc

KyeKye Posts: 2,200
edited 2015-01-06 03:32 in Propeller 1
I've been compiling my own cogc code with -ffunction-sections -fdata-sections. However, when you define static _COGMEM variables they get put into their own .bss section using this versus being put into the .text section. Thus when you link these variables end up in the hub even though they are supposed to be in a cog. Non-cog mem variables are put into the hub .data/.bss like you would expect and are optimized out if they are unused with the -ffunction-sections -fdata-sections and -Wl,--gc-sections trick.

I'd like to have the garbage collection feature working for cogc code. However, it looks like this can't be because code using "static _COGMEM" won't compile. I'm pretty sure this is a bug in the compiler. I'm fully linking the cogc code when I compile. There's probably an unhandled case with _COGMEM and -fdata-sections.

To reproduce just compile any cogc file into an CMM/LMM application that has "static _COGMEM" vars using -fdata-sections.

Comments

  • KyeKye Posts: 2,200
    edited 2015-01-05 19:51
    Another problem, but, less serious...

    I compile all SimpleLibraries and link with them all, where all the SimpleLibraries are put into archives. One of the SimpleLibraries has a .cogc module. I compile this and link it fully and then archive it. I've noticed that even though it is unused it still shows up in all .elf images. There's nothing referencing it and I've already passed the -Wl,--gc-sections option. But, yet, it still ends up in the final executable. Does this have anything to do with a fix for .cog sections not being pulled out of a library unless they define a symbol different from the __load_start_***? The linker just seems to pull this in if it finds it in a library.

    I can't just not compile and link against the library if it's unused because I have no way of determining what libraries are used. The linker should really not include the file if it's unused.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-06 03:32
    The linker shouldn't pull in the cogc code unless the main program references that new symbol. Maybe you could post an example of this behavior?
Sign In or Register to comment.