• AVR Freaks

LockedBug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking)

Author
nathanwiebe
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2009/03/30 21:00:04
  • Location: 0
  • Status: offline
2015/08/26 07:43:40 (permalink)
0

Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking)

Forgive me if this should be a bug report rather than a forum post, but I'm curious if others think this is a bug or not.  I am building a project in XC32 v1.40.  At this point, it includes little more than FreeRTOS and the lua script engine.  When I carve out lua, the project links, but with the lua source included, the link fails.  The lua source is ANSI C, but it does hit some of the lesser-used standard lib functions that are not especially common on micro code (e.g. setjmp, longjmp, ...).  I have successfully built and run the lua script engine on a number of past versions of XC32, but it seems that this version has a bug in the standard libraries that results in link failure due to a symbol that is defined twice in libc.a (symbol '_atexitptr').  Here is the relevant linker error:
 
c:/program files (x86)/microchip/xc32/v1.40/bin/bin/../../lib/gcc/pic32mx/4.8.3/../../../../pic32mx/lib\libc.a(stdclean_full.o):(.bss+0x0): multiple definition of `_atexitptr'
c:/program files (x86)/microchip/xc32/v1.40/bin/bin/../../lib/gcc/pic32mx/4.8.3/../../../../pic32mx/lib\libc.a(stdclean_simple.o):(.bss+0x0): first defined here
c:\program files (x86)\microchip\xc32\v1.40\bin\bin\gcc\pic32mx\4.8.3\..\..\..\..\bin/xc32-ld.exe: Link terminated due to previous error(s).
 
It would seem to me that stdclean_full.o and stdclean_simple.o are mutually exclusive alternatives, but they are both being linked in.  Google's got nothing on atexitptr in the context of MIPS gcc.  I guess I could start carving clib calls out of the lua source, starting with the most obscure, to see what is triggering the issue, but that doesn't get me running.
 
Any thoughts on if this is a bug, and/or how I can work around it?  Can this file (libc.a) be fixed and rebuilt manually?
#1

12 Replies Related Threads

    andersm
    Super Member
    • Total Posts : 2844
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/08/26 08:40:47 (permalink)
    +1 (1)
    I'm fairly sure the problematic symbols are related to atexit(). Since an embedded system should never exit, it should be safe to remove all calls to the function.
    #2
    nathanwiebe
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2009/03/30 21:00:04
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/08/26 12:13:02 (permalink)
    0
    Andersm: Thanks for the suggestion.  And that's what I thought too (the exit() function), but removing references to it does not fix the error.  And conversely, I added references to exit() to the version without the lua engine, and it built and ran fine.
    #3
    Swaroop Bekal
    Senior Member
    • Total Posts : 158
    • Reward points : 0
    • Joined: 2007/07/26 22:53:07
    • Location: Microchip Technology
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/08/30 20:27:41 (permalink)
    +3 (3)
    I can confirm that this is a bug which is seen when a project uses exit() along with particular stdio functions which pulls buf.o from libc.a
     
    This would be fixed in the next XC32 release.
    #4
    nathanwiebe
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2009/03/30 21:00:04
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/08/31 23:45:39 (permalink)
    0
    Swaroop: Thanks for letting me know!  I appreciate that.
    #5
    dave@dumaexotics.com
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2013/06/21 07:13:19
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/09/09 09:13:46 (permalink)
    0
    When is the next XC32 release?  I am dead in the water until this bug is fixed..
    #6
    nathanwiebe
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2009/03/30 21:00:04
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/09/09 10:07:51 (permalink)
    +1 (1)
    Just to get you going until the new XC32 comes out...
     
    If you are comfortable editing libc.a in a text editor (one that is not sensitive to line endings), you can rename the symbol name for the conflicting instances of _atexitptr (to something with the same length like _atexitpts).  It's a dirty hack, but it got me going again.  Depending on which processor we are talking (I did it for PIC32MZ2048ECM100 and PIC32MZ2048EFM064), there are 4 or 5 references in the libc.a file.  I experimented with renaming the first half of them until it linked, and I have been running fine since.
    #7
    dave@dumaexotics.com
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2013/06/21 07:13:19
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/09/09 11:40:52 (permalink)
    0
    Thanks nathan..  I tried that and now I get this link error..
     
    /Applications/microchip/xc32/v1.40/bin/bin/../../lib/gcc/pic32mx/4.8.3/../../../../pic32mx/lib/libc.a(stdclean_full.o):(.bss+0x0): multiple definition of `_atexitpts'
    /Applications/microchip/xc32/v1.40/bin/bin/../../lib/gcc/pic32mx/4.8.3/../../../../pic32mx/lib/libc.a(stdclean_simple.o):(.bss+0x0): first defined here
     
    When you say on a per processor basis what are you saying?  I only found libc.a in one place..
    #8
    nathanwiebe
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2009/03/30 21:00:04
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/09/09 11:51:20 (permalink)
    +1 (1)
    There is "/pic32mx/lib/libc.a" for the 32MZ EC family, but there is also "/pic32mx/lib/fpu64/libc.a" for the 32MZ EF family.  In one there were 4 references, and in the other there were 5, if I remember correctly.  I would just post the patched files, but I don't feel comfortable posting a file with licensing restrictions on this public forum.  But if you send me an email, we can, um, discuss it further ;)
     
    My email is "nathan at [my handle].org"  (Replace my handle with my handle on this forum)
    #9
    andersm
    Super Member
    • Total Posts : 2844
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/09/09 12:30:39 (permalink)
    0
    You can try doing it a bit safer than by hex editing:
    1. Make a backup copy of libc.a
    2. Copy the library to a new temporary folder
    3. Extract the object file from the archive: xc32-ar x libc.a stdclean_simple.o
    4. Delete the duplicate symbol: xc32-strip -N _atexitptr stdclean_simple.o
    5. Update the object file in the archive: xc32-ar r libc.a stdclean_simple.o
    6. Replace the library in the compiler installation folder
    #10
    nathanwiebe
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2009/03/30 21:00:04
    • Location: 0
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/09/09 15:57:53 (permalink)
    0
    Nice!
    #11
    Skysurfer
    Super Member
    • Total Posts : 195
    • Reward points : 0
    • Joined: 2013/07/24 12:12:39
    • Location: Utah
    • Status: offline
    Re: Bug in XC32 standard libraries? (stdclean_full.o and stdclean_simple.o both linking) 2015/09/09 16:19:15 (permalink)
    0
    Thanks Andersm.... I'll put that one in my quiver :-)
    #12
    Jump to:
    © 2020 APG vNext Commercial Version 4.5