Closed kas1e closed 10 months ago
I was able to reproduce it with a native build with newlib as clib. But the generated archive file isn't total empty for me. It has 8 bytes. Does your archive even have some bytes, or is it completely empty?
@migthymax I can't say for now, maybe i also had 8 bytes (not at home, can't check), but what is for sure, is that ready .a didn't contain necessary files in, this is what you have as well..
IMHO the way to fix it is to track what amiga specific changes done in the patches in original binutils from adtools repo (IMHO those patches should have amiga specific changes making it works)
I tracked it down for compiling binutils native using newlib as clib. Still need to be checked if that is teh case too for clib2/clib4 as clib. The root cause is that the ar creates a temp file and writes everything into that, when its finished it copies all the content of the temp file to the destination archive file. That's the method _simplecopy in binutils/rename.c. The method works on a file descriptor which is duplicated with dup, but with that file descriptor the _simplecopy silently fails to copy the content. With the original file descriptor the _simplecopy fails with an error. Thus it seems that the dup method is buggy in newlib? The workaround is to reopen the temp file in _binutils/ar.c#writearchive like this:
#ifdef __amigaos4__
tmpfd = open (new_name, O_RDONLY | O_BINARY);
if (tmpfd < 0)
xexit (1);
#elif
tmpfd = dup (tmpfd);
#endif
So when i tried to use "ar" to pack up some objects into .a archive, it creates empty .a , without objects inside.
I.e. simple doing `ar crub libhello.a libhello.o" , create an emptu libhello.a , with no libhello.o inside. While adtool's version works fine, as well as cross-compiler build of our latest binutils.
So it probably something related to the handle of "paths" or so.