www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Building LDC for FreeBSD PowerPC64

reply Curtis Hamilton <clhamilto gmail.com> writes:
I was wondering if there has been any success in building LDC on FreeBSD
PowerPC64?

I've been unsuccessful in building LDC on FreeBSD 13 on my Power9
Blackbird.   The results usually end with "relocation R_PPC64_TOC16_DS out
of range" errors when linking LDC2.

Any ideas?
Dec 09 2021
parent reply Brian Callahan <bcallah openbsd.org> writes:
On Thursday, 9 December 2021 at 16:10:37 UTC, Curtis Hamilton 
wrote:
 I was wondering if there has been any success in building LDC 
 on FreeBSD PowerPC64?

 I've been unsuccessful in building LDC on FreeBSD 13 on my 
 Power9 Blackbird.   The results usually end with "relocation 
 R_PPC64_TOC16_DS out of range" errors when linking LDC2.

 Any ideas?
Probably wants -mcmodel=medium (alternatively, -mcmodel=large).
Dec 09 2021
parent reply Curtis Hamilton <clhamilto gmail.com> writes:
Thanks for the response, but I had tried that and it didn't work.  Below is
the full error output:

: && /usr/bin/c++ -DDMDV2 -O3 -DNDEBUG  obj/ldc2.o -o bin/ldc2
 lib/libldc.a  -lLLVM-10  -L/usr/local/llvm10/lib  -Wl,--export-dynamic
 -L/usr/xports/tmp/lts-build/lib  -lphobos2-ldc  -ldruntime-ldc  -lpthread
 -lm  -m64 && :
ld: error: ti_ushort.d:(function ldc.dso_ctor.2rt8typeinfo9ti_ushort:
.text+0x1E): relocation R_PPC64_TOC16_DS out of range: 35408 is not in
[-32768, 32767]
ld: error: ti_uint.d:(function ldc.dso_ctor.2rt8typeinfo7ti_uint:
.text+0x1E): relocation R_PPC64_TOC16_DS out of range: 35312 is not in
[-32768, 32767]
ld: error: utf.d:(function _D2rt4util3utf7toUTF32FxAaZAyw:
.text._D2rt4util3utf7toUTF32FxAaZAyw+0x1E): relocation R_PPC64_TOC16_DS out
of range: 35800 is not in [-32768, 32767]
ld: error: ti_real.d:(function ldc.dso_ctor.2rt8typeinfo7ti_real:
.text+0x1E): relocation R_PPC64_TOC16_DS out of range: 35160 is not in
[-32768, 32767]
ld: error: ti_ireal.d:(function ldc.dso_ctor.2rt8typeinfo8ti_ireal:
.text+0xA): relocation R_PPC64_TOC16_DS out of range: 35040 is not in
[-32768, 32767]
ld: error: ti_wchar.d:(function ldc.dso_ctor.2rt8typeinfo8ti_wchar:
.text+0x1E): relocation R_PPC64_TOC16_DS out of range: 35512 is not in
[-32768, 32767]
ld: error: ti_double.d:(function
_D2rt8typeinfo9ti_double10TypeInfo_d8toStringMxFNaNbNfZAya:
.text._D2rt8typeinfo9ti_double10TypeInfo_d8toStringMxFNaNbNfZAya+0xA):
relocation R_PPC64_TOC16_DS out of range: 34744 is not in [-32768, 32767]
ld: error: random.d:(function ldc.dso_ctor.2rt4util6random: .text+0x1E):
relocation R_PPC64_TOC16_DS out of range: 35632 is not in [-32768, 32767]
ld: error: ti_creal.d:(function
_D2rt8typeinfo8ti_creal10TypeInfo_c4initMxFNaNbNiNeZAxv:
.text._D2rt8typeinfo8ti_creal10TypeInfo_c4initMxFNaNbNiNeZAxv+0xA):
relocation R_PPC64_TOC16_DS out of range: 34640 is not in [-32768, 32767]
ld: error: utf.d:(function ldc.dso_ctor.2rt4util3utf: .text+0x1E):
relocation R_PPC64_TOC16_DS out of range: 35816 is not in [-32768, 32767]
ld: error: ti_float.d:(function
_D2rt4util8typeinfo15__T8FloatingTfZ6hashOfFNaNbNefZm:
.text._D2rt4util8typeinfo15__T8FloatingTfZ6hashOfFNaNbNefZm+0xA):
relocation R_PPC64_TOC16_DS out of range: 34832 is not in [-32768, 32767]
ld: error: utf.d:(function _D2rt4util3utf6decodeFxAwKmZw:
.text._D2rt4util3utf6decodeFxAwKmZw+0x5A): relocation R_PPC64_TOC16_DS out
of range: 35776 is not in [-32768, 32767]
ld: error: ti_Ashort.d:(function
_D2rt8typeinfo9ti_Ashort11TypeInfo_As8toStringMxFNaNbNfZAya:
.text._D2rt8typeinfo9ti_Ashort11TypeInfo_As8toStringMxFNaNbNfZAya+0xA):
relocation R_PPC64_TOC16_DS out of range: 34280 is not in [-32768, 32767]
ld: error: ti_ushort.d:(function ldc.dso_ctor.2rt8typeinfo9ti_ushort:
.text+0x3E): relocation R_PPC64_TOC16_DS out of range: 35416 is not in
[-32768, 32767]
ld: error: ti_ireal.d:(function ldc.dso_ctor.2rt8typeinfo8ti_ireal:
.text+0x3E): relocation R_PPC64_TOC16_DS out of range: 35048 is not in
[-32768, 32767]
ld: error: ti_short.d:(function
_D2rt8typeinfo8ti_short10TypeInfo_s8toStringMxFNaNbNfZAya:
.text._D2rt8typeinfo8ti_short10TypeInfo_s8toStringMxFNaNbNfZAya+0xA):
relocation R_PPC64_TOC16_DS out of range: 35200 is not in [-32768, 32767]
ld: error: ti_uint.d:(function ldc.dso_ctor.2rt8typeinfo7ti_uint:
.text+0x3E): relocation R_PPC64_TOC16_DS out of range: 35320 is not in
[-32768, 32767]
ld: error: utf.d:(function _D2rt4util3utf7toUTF32FxAuZAyw:
.text._D2rt4util3utf7toUTF32FxAuZAyw+0x1E): relocation R_PPC64_TOC16_DS out
of range: 35800 is not in [-32768, 32767]
ld: error: ti_real.d:(function ldc.dso_ctor.2rt8typeinfo7ti_real:
.text+0x3E): relocation R_PPC64_TOC16_DS out of range: 35168 is not in
[-32768, 32767]
ld: error: utf.d:(function ldc.dso_ctor.2rt4util3utf: .text+0x3E):
relocation R_PPC64_TOC16_DS out of range: 35824 is not in [-32768, 32767]
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see
all errors)
c++: error: linker command failed with exit code 1 (use -v to see
invocation)
ninja: build stopped: subcommand failed.


On Thu, Dec 9, 2021 at 5:40 PM Brian Callahan via digitalmars-d-ldc <
digitalmars-d-ldc puremagic.com> wrote:

 On Thursday, 9 December 2021 at 16:10:37 UTC, Curtis Hamilton
 wrote:
 I was wondering if there has been any success in building LDC
 on FreeBSD PowerPC64?

 I've been unsuccessful in building LDC on FreeBSD 13 on my
 Power9 Blackbird.   The results usually end with "relocation
 R_PPC64_TOC16_DS out of range" errors when linking LDC2.

 Any ideas?
Probably wants -mcmodel=medium (alternatively, -mcmodel=large).
Dec 09 2021
parent reply kinke <noone nowhere.com> writes:
Which D host compiler are you using?
Dec 09 2021
next sibling parent Curtis Hamilton <clhamilto gmail.com> writes:
I=E2=80=99m using ltsmaster.

On Thu, Dec 9, 2021 at 10:00 PM kinke via digitalmars-d-ldc <
digitalmars-d-ldc puremagic.com> wrote:

 Which D host compiler are you using?
Dec 09 2021
prev sibling parent reply Curtis Hamilton <clhamilto gmail.com> writes:
Unfortunately I=E2=80=99ve not been successful in using LDC-0.17.6 or ltsma=
ster to
bootstrap and build a newer LDC release.

But I have managed to build LDC-1.23 using GDC as the host D compiler.
However, the resulting build errors when building itself or other D Lang
package. Below is the error message.  Any ideas?


(/usr/local/llvm10/lib/libLLVM-10.so+0x1f93248)


(/usr/local/llvm10/lib/libLLVM-10.so+0x1f90970)


/usr/src/lib/libthr/thread/thr_sig.c:303:3

ninja: build stopped: subcommand failed.

On Fri, Dec 10, 2021 at 12:22 AM Curtis Hamilton <clhamilto gmail.com>
wrote:

 I=E2=80=99m using ltsmaster.

 On Thu, Dec 9, 2021 at 10:00 PM kinke via digitalmars-d-ldc <
 digitalmars-d-ldc puremagic.com> wrote:

 Which D host compiler are you using?
Dec 10 2021
parent reply kinke <noone nowhere.com> writes:
On Saturday, 11 December 2021 at 05:15:33 UTC, Curtis Hamilton 
wrote:
 Unfortunately I’ve not been successful in using LDC-0.17.6 or 
 ltsmaster to bootstrap and build a newer LDC release.

 But I have managed to build LDC-1.23 using GDC as the host D 
 compiler.
Yeah, gdc is the suggested bootstrap way. - So you got that LDC to successfully build druntime and Phobos? I wouldn't have thought you'd get that far ;) - there's a number of (old) reported PowerPC issues on GitHub.
Dec 11 2021
next sibling parent reply Curtis Hamilton <clhamilto gmail.com> writes:
On Sat, Dec 11, 2021 at 6:55 PM kinke via digitalmars-d-ldc <
digitalmars-d-ldc puremagic.com> wrote:

 On Saturday, 11 December 2021 at 05:15:33 UTC, Curtis Hamilton
 wrote:
 Unfortunately I=E2=80=99ve not been successful in using LDC-0.17.6 or
 ltsmaster to bootstrap and build a newer LDC release.

 But I have managed to build LDC-1.23 using GDC as the host D
 compiler.
Yeah, gdc is the suggested bootstrap way. - So you got that LDC to successfully build druntime and Phobos? I wouldn't have thought you'd get that far ;) - there's a number of (old) reported PowerPC issues on GitHub.
Yes, I=E2=80=99ve been successful in getting LDC to build using GDC as the = host D. In fact, the resulting build seems to be working well. I did have to make a few changes to the code to get everything working. First, PowerPC64 uses elfv2 vice elfv1 on FreeBSD 13, so that needed to be changed in =E2=80=9Cdriver/target machine.cop=E2=80=9D. I also had to upda= te =E2=80=9Cdruntime/src/core/sys/freebsd/config.d=E2=80=9D for FreeBSD 13. M= ost recent druntime has been updated. Lastly, I needed to apply the patch from dbankov-vmware https://github.com/dbankov-vmware/ldc/tree/fix-for-3795 that allows LDC to build using static =E2=80=9Cphobos=E2=80=9D which lets = LDC to be independent of GDC. regards
Dec 16 2021
parent reply Johan <j j.nl> writes:
On Thursday, 16 December 2021 at 14:55:52 UTC, Curtis Hamilton 
wrote:
 On Sat, Dec 11, 2021 at 6:55 PM kinke via digitalmars-d-ldc < 
 digitalmars-d-ldc puremagic.com> wrote:

 On Saturday, 11 December 2021 at 05:15:33 UTC, Curtis Hamilton 
 wrote:
 Unfortunately I’ve not been successful in using LDC-0.17.6 
 or ltsmaster to bootstrap and build a newer LDC release.

 But I have managed to build LDC-1.23 using GDC as the host D 
 compiler.
Yeah, gdc is the suggested bootstrap way. - So you got that LDC to successfully build druntime and Phobos? I wouldn't have thought you'd get that far ;) - there's a number of (old) reported PowerPC issues on GitHub.
Yes, I’ve been successful in getting LDC to build using GDC as the host D. In fact, the resulting build seems to be working well. I did have to make a few changes to the code to get everything working.
Good news :) Would you be so kind to submit the required changes as PRs on Github? Thanks! Johan
Dec 17 2021
parent reply Curtis Hamilton <clhamilto gmail.com> writes:
Will do!  However, I've been to run all the tests.  The
druntime-test-runner apps fails to build with the below error.  Any
suggestions?

Error: template `core.internal.dassert._d_assert_fail` cannot deduce
function from argument types `!("!", bool)(bool)`, candidates are:
core/internal/dassert.d(8):        `_d_assert_fail(string comp, A, B)(auto
ref scope const A a, auto ref scope const B b)`

On Fri, Dec 17, 2021 at 8:15 AM Johan via digitalmars-d-ldc <
digitalmars-d-ldc puremagic.com> wrote:

 On Thursday, 16 December 2021 at 14:55:52 UTC, Curtis Hamilton
 wrote:
 On Sat, Dec 11, 2021 at 6:55 PM kinke via digitalmars-d-ldc <
 digitalmars-d-ldc puremagic.com> wrote:

 On Saturday, 11 December 2021 at 05:15:33 UTC, Curtis Hamilton
 wrote:
 Unfortunately I=E2=80=99ve not been successful in using LDC-0.17.6
 or ltsmaster to bootstrap and build a newer LDC release.

 But I have managed to build LDC-1.23 using GDC as the host D
 compiler.
Yeah, gdc is the suggested bootstrap way. - So you got that LDC to successfully build druntime and Phobos? I wouldn't have thought you'd get that far ;) - there's a number of (old) reported PowerPC issues on GitHub.
Yes, I=E2=80=99ve been successful in getting LDC to build using GDC as the host D. In fact, the resulting build seems to be working well. I did have to make a few changes to the code to get everything working.
Good news :) Would you be so kind to submit the required changes as PRs on Github? Thanks! Johan
Dec 17 2021
parent reply Johan <j j.nl> writes:
On Friday, 17 December 2021 at 15:38:09 UTC, Curtis Hamilton 
wrote:
 Will do!  However, I've been to run all the tests.  The 
 druntime-test-runner apps fails to build with the below error.  
 Any suggestions?

 Error: template `core.internal.dassert._d_assert_fail` cannot 
 deduce
 function from argument types `!("!", bool)(bool)`, candidates 
 are:
 core/internal/dassert.d(8):        `_d_assert_fail(string comp, 
 A, B)(auto
 ref scope const A a, auto ref scope const B b)`
Perhaps your druntime submodule is out-of-date: `git submodule update --init` For LDC 1.23 (which I read is what you are using), line 8 contains `_d_assert_fail` with only one parameter. The one of your error message is on line 16. https://github.com/ldc-developers/druntime/blob/ldc-v1.23.0/src/core/internal/dassert.d For submitting the PR, please use LDC `master`. Thanks, Johan
Dec 18 2021
parent reply Curtis Hamilton <clhamilto gmail.com> writes:
--000000000000e2d35105d374a540
Content-Type: text/plain; charset="UTF-8"

Thanks for the feedback.  I updated the druntime and got a new error.

FAILED: runtime/objects-unittest/core/simd.o
cd /usr/xports/tmp/ldc-1.23.0-src/runtime/druntime/src &&
/usr/xports/tmp/build-ldc-1.23.0/bin/ldc2 -c --output-o -conf= -w -de
-dip1000 -O3 -release -d-version=CoreUnittest -unittest
-checkaction=context -preview=fieldwise
-I/usr/xports/tmp/ldc-1.23.0-src/runtime/druntime/src
-of=/usr/xports/tmp/build-ldc-1.23.0/runtime/objects-unittest/core/simd.o
core/simd.d
Wrong types for attribute: inalloca nest noalias nocapture nonnull readnone
readonly signext sret zeroext byval dereferenceable(1)
dereferenceable_or_null(1)
  %11 = call signext <16 x i8>
 _D3ldc4simd__T13loadUnalignedTNhG16gZQxFNaNbNiNexPNhQuZQz(<16 x i8>* %10)

in function
_D4core4simd18__unittest_L615_C5FNaNbNiZ__T4testTNhG16gZQnMFNaNbNiZv
LLVM ERROR: Broken function found, compilation aborted!

In fact it's the same error I get when I build and test the current master (
https://github.com/ldc-developers/ldc.git).  However, if I remove (comment
out) the two " system" unittest in core/simd.d, I'm able to build
"druntime-test-runner" and other test apps and complete the unittests with
50 failures out of 1688.  I've attached the failed test log.

On Sat, Dec 18, 2021 at 7:35 AM Johan via digitalmars-d-ldc <
digitalmars-d-ldc puremagic.com> wrote:

 On Friday, 17 December 2021 at 15:38:09 UTC, Curtis Hamilton
 wrote:
 Will do!  However, I've been to run all the tests.  The
 druntime-test-runner apps fails to build with the below error.
 Any suggestions?

 Error: template `core.internal.dassert._d_assert_fail` cannot
 deduce
 function from argument types `!("!", bool)(bool)`, candidates
 are:
 core/internal/dassert.d(8):        `_d_assert_fail(string comp,
 A, B)(auto
 ref scope const A a, auto ref scope const B b)`
Perhaps your druntime submodule is out-of-date: `git submodule update --init` For LDC 1.23 (which I read is what you are using), line 8 contains `_d_assert_fail` with only one parameter. The one of your error message is on line 16. https://github.com/ldc-developers/druntime/blob/ldc-v1.23.0/src/core/internal/dassert.d For submitting the PR, please use LDC `master`. Thanks, Johan
--000000000000e2d35105d374a540 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Thanks for the feedback.=C2=A0 I updated the druntime= and got a new error.</div><div><br></div><div>FAILED: runtime/objects-unit= test/core/simd.o <br>cd /usr/xports/tmp/ldc-1.23.0-src/runtime/druntime/src= &amp;&amp; /usr/xports/tmp/build-ldc-1.23.0/bin/ldc2 -c --output-o -conf= =3D -w -de -dip1000 -O3 -release -d-version=3DCoreUnittest -unittest -check= action=3Dcontext -preview=3Dfieldwise -I/usr/xports/tmp/ldc-1.23.0-src/runt= ime/druntime/src -of=3D/usr/xports/tmp/build-ldc-1.23.0/runtime/objects-uni= ttest/core/simd.o core/simd.d<br>Wrong types for attribute: inalloca nest n= oalias nocapture nonnull readnone readonly signext sret zeroext byval deref= erenceable(1) dereferenceable_or_null(1)<br>=C2=A0 %11 =3D call signext &lt= ;16 x i8&gt; _D3ldc4simd__T13loadUnalignedTNhG16gZQxFNaNbNiNexPNhQuZQz(&lt= iZ__T4testTNhG16gZQnMFNaNbNiZv<br>LLVM ERROR: Broken function found, compil= et when I build and test the current master (<a href=3D"https://github.com/= ldc-developers/ldc.git">https://github.com/ldc-developers/ldc.git</a>).=C2= =A0 However, if I remove (comment out) the two &quot; system&quot; unittest= other test apps and complete the unittests with 50 failures out of 1688.= =3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, Dec 18, 2021= at 7:35 AM Johan via digitalmars-d-ldc &lt;<a href=3D"mailto:digitalmars-d= -ldc puremagic.com">digitalmars-d-ldc puremagic.com</a>&gt; wrote:<br></div=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border=
-left:1px solid rgb(204,204,204);padding-left:1ex">On Friday, 17 December 2= 021 at 15:38:09 UTC, Curtis Hamilton <br> wrote:<br> <br> &gt; druntime-test-runner apps fails to build with the below error.=C2=A0 <= br> &gt; Any suggestions?<br> &gt;<br> &gt; Error: template `core.internal.dassert._d_assert_fail` cannot <br> &gt; deduce<br> &gt; function from argument types `!(&quot;!&quot;, bool)(bool)`, candidate= s <br> &gt; are:<br> &gt; core/internal/dassert.d(8):=C2=A0 =C2=A0 =C2=A0 =C2=A0 `_d_assert_fail= (string comp, <br> &gt; A, B)(auto<br> &gt; ref scope const A a, auto ref scope const B b)`<br> <br> Perhaps your druntime submodule is out-of-date:<br> `git submodule update --init`<br> <br> For LDC 1.23 (which I read is what you are using), line 8 <br> contains `_d_assert_fail` with only one parameter. The one of <br> your error message is on line 16.<br> <a href=3D"https://github.com/ldc-developers/druntime/blob/ldc-v1.23.0/src/= core/internal/dassert.d" rel=3D"noreferrer" target=3D"_blank">https://githu= b.com/ldc-developers/druntime/blob/ldc-v1.23.0/src/core/internal/dassert.d<= /a><br> <br> For submitting the PR, please use LDC `master`.<br> <br> Thanks,<br> =C2=A0 Johan<br> <br> </blockquote></div> --000000000000e2d35105d374a540--
Dec 18 2021
parent Curtis Hamilton <clhamilto gmail.com> writes:
To follow up.

Using GDC, I used GCC 11.2.0, as bootstrap is the only way to build LDC on
powerpc64.  The resulting LDC can not be used to build itself, for some
reason. However it can be used to build dub and other dlang libraries and
tools.  I highly recommend only building dub (devel/dub) from the freebsd
ports.  Then use dub to build everything else, including itself, outside
ports.


prevents the building of unit-test "druntime-test-runner".  Reversing this
PR allows all tests to be run, with approximately 50 failed tests.  No
research has been done on these failures.

These results are for big endian powerpc64.  I've had mixed results on
powerpc64le, but I don't think they're exclusively related to LDC.  I think
I corrupted my powerpc64le install when I did a source upgrade from the
freebsd 13 beta version to the freebsd 13 release version.  A lot of
previously working apps are no longer working.  I'm going to do a clean
re-install of freebsd/powerpc64le and rebuild everything before trying
again.

On Fri, Jan 7, 2022 at 3:40 AM Carlton Flores via digitalmars-d-ldc <
digitalmars-d-ldc puremagic.com> wrote:

 any update on this build ?
 https://www.surveyzop.com/talktowendys/
 https://www.surveyzop.com/restaurant-survey/
Jan 07 2022
prev sibling parent Curtis Hamilton <clhamilto gmail.com> writes:
On Thu, Dec 16, 2021 at 9:55 AM Curtis Hamilton <clhamilto gmail.com> wrote=
:

 On Sat, Dec 11, 2021 at 6:55 PM kinke via digitalmars-d-ldc <
 digitalmars-d-ldc puremagic.com> wrote:

 On Saturday, 11 December 2021 at 05:15:33 UTC, Curtis Hamilton
 wrote:
 Unfortunately I=E2=80=99ve not been successful in using LDC-0.17.6 or
 ltsmaster to bootstrap and build a newer LDC release.

 But I have managed to build LDC-1.23 using GDC as the host D
 compiler.
Yeah, gdc is the suggested bootstrap way. - So you got that LDC to successfully build druntime and Phobos? I wouldn't have thought you'd get that far ;) - there's a number of (old) reported PowerPC issues on GitHub.
Yes, I=E2=80=99ve been successful in getting LDC to build using GDC as th=
e host
 D.  In fact, the resulting build seems to be working well.  I did have to
 make a few changes to the code to get everything working.

 First, PowerPC64 uses elfv2 vice elfv1 on FreeBSD 13, so that needed to b=
e
 changed in =E2=80=9Cdriver/target machine.cop=E2=80=9D.  I also had to up=
date
 =E2=80=9Cdruntime/src/core/sys/freebsd/config.d=E2=80=9D for FreeBSD 13. =
Most recent
 druntime has been updated.

 Lastly, I needed to apply the patch from  dbankov-vmware
 https://github.com/dbankov-vmware/ldc/tree/fix-for-3795
  that allows LDC to build using static =E2=80=9Cphobos=E2=80=9D which let=
s LDC to be
 independent of GDC.

 regards
I hate autocorrection, the file should be =E2=80=9Cdriver/targetmachine.cpp= =E2=80=9D=E2=80=A6.
Dec 16 2021