Sunday, October 10, 2021

Re: lang/gcc/11 fix dlang fibers, unbreak powerpc64

On 10/10/2021 10:25 PM, Brian Callahan wrote:
> Hi George --
>
> On 10/10/2021 10:17 PM, George Koehler wrote:
>> Hello,
>>
>> This diff unbreaks lang/gcc/11 on powerpc64, adds dlang to powerpc64,
>> and changes D's fibers on all archs; ok to commit?
>>
>> gcc 11 was broken in powerpc64 bulks,
>> http://build-failures.rhaalovely.net/powerpc64/2021-09-27/lang/gcc/11,-c++.log
>>
>> Unbreak by adding gnu-user.h (patch-gcc_config_gcc). Also add
>> PFRAG.powerpc64-main, to be like other archs; this PFRAG is still
>> missing in gcc 8. The rest of this diff is for the D programming
>> language, with parts for powerpc64, 32-bit powerpc, and all archs.
>>
>> Add powerpc64 to ONLY_FOR_ARCHS-dlang. Add enough PPC64 code to
>> libphobos to complete the build. (I might be the 1st person to try D
>> on powerpc64.) This PPC64 code is trivial, except the code for fibers
>> (https://tour.dlang.org/tour/en/multithreading/fibers), where I wrote
>> some powerpc64 asm. I found 2 other problems with fibers:
>>
>> 1. The fiber crashed SIGSEGV, because it didn't pass MAP_STACK to
>> mmap(2). The fix is easy, and affects all archs.
>>
>> 2. The existing code for 32-bit powerpc was wrong; it saved the
>> link register at 8(%r1), should be 4(%r1), and allowed signal
>> handlers to clobber the values saved below %r1. I change
>> almost every line of 32-bit asm as I add the 64-bit asm.
>>
>> The attachment "dfiber.d" is my fiber example. I can run it on macppc
>> and powerpc64, and you should be able to run it on any dlang arch,
>>
>> $ egdc -o dfiber dfiber.d
>> $ ./dfiber
>> adder(1, 1, 1)()
>> 1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753
>>
>> But on macppc, egdc works only with ld.bfd,
>>
>> $ ln -s /usr/bin/ld.bfd ld
>> $ PATH=$PWD:$PATH
>> $ egdc -o dfiber dfiber.d
>>
>> Bump REVISION-dlang for libphobos. Don't bump REVISION, because
>> the other changes (patch-gcc_config_gcc, and %%powerpc64%% in
>> PLIST-main) affect only powerpc64, which was broken.
>>
>> --George
>>
>
> I don't have a powerpc64 machine, but I will definitely test out the
> fibers fix and get back to you--thanks!
>
> ~Brian

ok bcallah@ on the MI libphobos part. Thank you very much for fixing!

The way GDC works is that code is submitted and merged into the D
upstream repos and then synced into GDC periodically. The repo you'll
want to submit your fixes to is this one:
https://github.com/dlang/druntime

The old 32-bit PowerPC code you found might have been for Mac OS X. You
may very well be the first person to try GDC on powerpc64 (and probably
the first person to try GDC on macppc since Apple shipped PowerPC
computers).

~Brian

No comments:

Post a Comment