jwt27 / build-gcc

Shell scripts to build various gcc cross-compilers (primarily djgpp)
https://jw.h4ck.me/debian/
GNU General Public License v3.0
44 stars 9 forks source link

memalign() patch #5

Closed rouseabout closed 5 years ago

rouseabout commented 6 years ago

djlsr205 memalign is broken for large alignment values (e.g. 64).

Patch: https://aur.archlinux.org/cgit/aur.git/tree/nmemalign.patch?h=djgpp-djcrx

Discussion: http://www.delorie.com/archives/browse.cgi?p=djgpp/2017/12/29/16:26:58

Test case:

#include <stdio.h>
#include <malloc.h>
int main()
{
        for (int alignment = 1; alignment <= 64; alignment *= 2) {
                void * ptr = memalign(alignment, 1*1024*1024);
                printf("%d: %p\n", alignment, ptr);
                if (ptr)
                        free(ptr);
        }
        return 0;
}
jwt27 commented 5 years ago

Hey, thanks for the patch, and please excuse my slow response. I merged it in but the test case still returns zero for values 16 and 64, is that supposed to happen?

rouseabout commented 5 years ago

you are right, the patch above dos not fix the problem. i have switched to using another allocator: http://g.oswego.edu/dl/html/malloc.html

jwt27 commented 5 years ago

I just realized, any patches to djgpp sources won't have any effect since we're only downloading a precompiled libc.

The patch has been reverted for now. Maybe in a future update to the build scripts we could patch and compile djgpp sources ourselves, even the latest versions from cvs.

jwt27 commented 5 years ago

Okay, big update. We're now building libc from source on branch djgpp-cvs, and I added the memalign patch again. As the branch name implies, we can now also build the latest djgpp from CVS, where I think this issue has been fixed already.

jwt27 commented 5 years ago

Oh, looks like my force-pushing kept triggering a reference to this issue. I hope that didn't send out 7 emails. Anyway the test case works now for both 2.05 and cvs, so I'm closing this.

rouseabout commented 5 years ago

Thanks. Also works for me.

stsp commented 5 years ago

So is this project now the place for submitting djgpp patches, or is there an alive upstream anywhere? Can't find anything useful on delorie.com, but doing cvs up shows a few commits, so maybe there is some upstream after all. Does anyone know?

jwt27 commented 5 years ago

On 2019-08-02 12:04, Stas Sergeev wrote:

So is this project now the place for submitting djgpp patches, or is there an alive upstream anywhere? Can't find anything useful on delorie.com, but doing |cvs up| shows a few commits, so maybe there is some upstream after all. Does anyone know?

Best place to send patches would be the mailing list, either djgpp@delorie.com or maybe djgpp-workers@delorie.com.