Menu

How not to have unused code linked?

Help
Guillaume
2004-05-16
3 days ago
  • Guillaume

    Guillaume - 2004-05-16

    "Dead code" removal works with SDCC at compile-time, but not during the link phase: if some functions are defined but never called, they still get linked. Is there any way to avoid this?

     
  • Maurizio Spagni

    Maurizio Spagni - 3 days ago

    This is usually called "smart linking" and works at function level.
    That is: if a function is defined but never called, then the linker removes it from the final object.
    It is very similar to what happens when you link libraries: you don't get the whole library, only the function you use.

    With my great surprise, I just discovered, like you did, that the sdcc linker doesn't perform the smart linking.
    Introducing it would be a great enhancement, IMHO.

    I was then thinking to convert my files to library modules, but I'm unable to find the documentation for sdar.exe and, furthermore, the Win 32 bit version of sdar included in sdcc-4.5.0 can't work because the zlib1.dll is missing...

     
    • Philipp Klaus Krause

      You might want to try current SDCC 4.6.0 (though the linking feature you want is not there yet, so you'll still have to use modules for 4.6.0) as the zlib1.dll issue should be fixed now.
      AFAIR, @janko-5 was considering looking into this feature for 4.7.0, but I haven't heard from him in a while.

       

      Last edit: Philipp Klaus Krause 3 days ago
  • Maurizio Spagni

    Maurizio Spagni - 3 days ago

    Sorry, but I can't find any SDCC 4.6.0. for win 32.
    The latest seems to be 4.5.0 (2025-01-28) here.

     

Log in to post a comment.

Auth0 Logo