@trac-glaubitz @glaubitz How did you get it to work without the actual implementation for the arch? I assume GHC never even had it for Hitachi.
barracuda156 (b7efdb24) at 26 Jan 00:18
ci: Disable HLint job due to excessive runtime
... and 24 more commits
@trommler Thank you for replying. The code is there in ghc
8.x.x (where I took it from), but in ghc
9.2.2 new syntax is used:
pprImm :: Platform -> Imm -> SDoc
pprImm platform = \case
ImmInt i -> int i
ImmInteger i -> integer i
ImmCLbl l -> pdoc platform l
ImmIndex l i -> pdoc platform l <> char '+' <> int i
ImmLit s -> s
ImmFloat f -> float $ fromRational f
ImmDouble d -> double $ fromRational d
ImmConstantSum a b -> pprImm platform a <> char '+' <> pprImm platform b
ImmConstantDiff a b -> pprImm platform a <> char '-' <> lparen <> pprImm platform b <> rparen
LO (ImmInt i) -> pprImm platform (LO (ImmInteger (toInteger i)))
LO (ImmInteger i) -> pprImm platform (ImmInteger (toInteger lo16))
where
lo16 = fromInteger (i .&. 0xffff) :: Int16
LO i -> pprImm platform i <> text "@l"
HI i -> pprImm platform i <> text "@h"
HA (ImmInt i) -> pprImm platform (HA (ImmInteger (toInteger i)))
HA (ImmInteger i) -> pprImm platform (ImmInteger ha16)
where
ha16 = if lo16 >= 0x8000 then hi16+1 else hi16
hi16 = (i `shiftR` 16)
lo16 = i .&. 0xffff
HA i -> pprImm platform i <> text "@ha"
HIGHERA i -> pprImm platform i <> text "@highera"
HIGHESTA i -> pprImm platform i <> text "@highesta"
I think I just need to rewrite the piece above which includes Darwin PPC to match the style of newer version (which has PPC but without Darwin added).
@trommler @bgamari I have made patches to revert the earlier removal of Darwin PPC support: 374e4470
I will appreciate some advice. Immediate issues:
– patch-ppc-Ppr.diff
should be changed in the following section to match new syntax, but how to do it correctly?
@@ -253,18 +293,42 @@
where
lo16 = fromInteger (i .&. 0xffff) :: Int16
- LO i -> pprImm platform i <> text "@l"
- HI i -> pprImm platform i <> text "@h"
- HA (ImmInt i) -> pprImm platform (HA (ImmInteger (toInteger i)))
- HA (ImmInteger i) -> pprImm platform (ImmInteger ha16)
- where
- ha16 = if lo16 >= 0x8000 then hi16+1 else hi16
- hi16 = (i `shiftR` 16)
- lo16 = i .&. 0xffff
-
- HA i -> pprImm platform i <> text "@ha"
- HIGHERA i -> pprImm platform i <> text "@highera"
- HIGHESTA i -> pprImm platform i <> text "@highesta"
+pprImm (LO i)
+ = sdocWithPlatform $ \platform ->
+ if platformOS platform == OSDarwin
+ then hcat [ text "lo16(", pprImm i, rparen ]
+ else pprImm i <> text "@l"
+
+pprImm (HI i)
+ = sdocWithPlatform $ \platform ->
+ if platformOS platform == OSDarwin
+ then hcat [ text "hi16(", pprImm i, rparen ]
+ else pprImm i <> text "@h"
+
+pprImm (HA (ImmInt i)) = pprImm (HA (ImmInteger (toInteger i)))
+pprImm (HA (ImmInteger i)) = pprImm (ImmInteger ha16)
+ where
+ ha16 = if lo16 >= 0x8000 then hi16+1 else hi16
+ hi16 = (i `shiftR` 16)
+ lo16 = i .&. 0xffff
+
+pprImm (HA i)
+ = sdocWithPlatform $ \platform ->
+ if platformOS platform == OSDarwin
+ then hcat [ text "ha16(", pprImm i, rparen ]
+ else pprImm i <> text "@ha"
+
+pprImm (HIGHERA i)
+ = sdocWithPlatform $ \platform ->
+ if platformOS platform == OSDarwin
+ then panic "PPC.pprImm: highera not implemented on Darwin"
+ else pprImm i <> text "@highera"
+
+pprImm (HIGHESTA i)
+ = sdocWithPlatform $ \platform ->
+ if platformOS platform == OSDarwin
+ then panic "PPC.pprImm: highesta not implemented on Darwin"
+ else pprImm i <> text "@highesta"
patch-PPC_Darwin.diff
is in fact an added back file, does it integrate as-is?
I am unsure if llvm-targets
file is something essential, but I do not understand special syntax it uses (in addition to standard triples).
I will look through in more detail into portions of pre-8.6.x code that may be ppc-relevant and see if something extra can/has to be restored. In the meanwhile, any suggestions are greatly appreciated.
P. S. As far as I understand, I need to cross-compile on x86_64 first in any case to build ghc-boot
for a native ppc compiler. I am thinking to do it on 10.6.8 which supports compilation for Intel and PowerPC both out-of-the-box. Are there any important but non-obvious points to consider?PPC_patches_v1.zip
@trommler Thank you very much for reply! This is very informative. I will follow your suggestion and try to fix a recent version then.
Once I have some results, I will open a new ticket and hopefully you may give some further advice.
(Sorry for a delay, been occupied with other projects. I am committed to getting ghc
fixed for PowerPC, it is just a matter of time.)
@mpickering Thank you, I will try.
What surprised me was consistency: regardless of which compiler I used to start with (7.0.1 or 7.0.4), which proceeded with (7.6.2 or 7.6.3) and which tried to build (7.7, 7.8.4 or 7.10.3), it was always the same kind of failure – either on ghc-prim or float.
P. S. I tried also on 10.6.8 Rosetta, but that appears hopelessly broken:
@bgamari If you or someone could give me a quick advice on the error I’m facing, that would be very helpful.
I have tried building 7.7, 7.8.x and 7.10.3 (using 7.6.2 and 7.6.3), however I am stuck every time on the same failure: ghc-stage1: internal error: evacuate(static): strange closure type
.
Initially I was getting it with building ghc-prim
, then I tweaked settings in a variety of ways and the best I was able to get is building stage0 and stage1 completely and the same error happens when building items in libraries/base/GHC
, specifically Float
, but some other too.
I cannot figure out why this happens, and while I have found a similar error reported here, that was fixed in 7.10, but for me 7.10 still failed in identical way. Report here: #8976 (closed)
I literally spent hours on this, and I dunno what to try further.
@bgamari Thank you for responding!
I can do the testing on my end, and see if reversion works. Before that I need to solve the current issue of building some later version of ghc
(ghc-stage1: internal error: evacuate(static): strange closure type
), I will work on that.
Do you know by chance which was the last version of ghc
to support PPC in principle? (UPD. Apparently, PPC support was removed between 8.6.5 and 8.8.1.)
And if PPC support was removed at once (i.e. here) or in stages, this being the last clean-up?
P. S. The latest [semi-]official binaries for powerpc-apple-darwin
existing are of 7.0.1 and 7.0.4. But I compared the PPC-relevant code which was removed in this commit, and it is present in similar form in 7.8.4, for instance, and even in 8.6.5. Moreover, it seemed to me that some parts could have been actually added at some point (I may be wrong here). There is a huge gap between the last ready-made compiler for PPC and a point when PPC support was removed from the code base. It looks somewhat surprising to me: it was maintained for quite a long time, but I could not find any actual builds for PPC.
@kencu Thank you for joining in. Yes, PPC interest is from my side, I did not imply that I act on behalf of Macports here. If I can fix ghc
for PPC, we may probably commit that to Macports however. Provided you and other won’t object.
@maeder Did you try building anything beyond 7.0.1 for PPC? I want to fix ghc for PPC. Track record here: https://trac.macports.org/ticket/64698 But I will really appreciate any advice.
Yes, there is an interest. As of now, I was able to build ghc 7.6.3 for PPC, however there is some problem with it: basic functionality is there, but it fails to build 7.8.1 (or even rebuild itself) after stage0: https://trac.macports.org/ticket/64698
What would it take to bring it back? I am not asking someone to do that for me, of course, I want to do it myself.
I have bootstrapped ghc 7.0.1
and used it to build ghc 7.6.3
, however resulting compiler, while apparently functional, failed to build ghc 7.8.x
and even to rebuild itself.
I describe the problem here: https://trac.macports.org/ticket/64698