Bug 239193 - lang/ghc: fix build on powerpc64 elfv1
Summary: lang/ghc: fix build on powerpc64 elfv1
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-haskell (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-13 22:16 UTC by Piotr Kubaj
Modified: 2019-08-01 18:59 UTC (History)
4 users (show)

See Also:
arrowd: maintainer-feedback+


Attachments
patch (1.02 KB, patch)
2019-07-19 15:13 UTC, Piotr Kubaj
arrowd: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer freebsd_triage 2019-07-13 22:16:07 UTC
1. Dtrace currently doesn't work on powerpc64. I'm not sure whether it works on CURRENT, but enabling it on 12 causes assertion errors from base. Consider following patch:
Index: Makefile
===================================================================
--- Makefile    (revision 506459)
+++ Makefile    (working copy)
@@ -95,6 +95,10 @@
 LLVM_VERSION=          60
 .endif

+.if ${ARCH} == powerpc64 && ${OSVERSION} < 1300000
+CONFIGURE_ARGS+=       --enable-dtrace=0
+.endif
+
 .if ${ARCH} == amd64 || ${ARCH} == i386
 BOOT_GHC_VERSION=      8.4.3
 .else

2. https://svnweb.freebsd.org/ports/head/lang/ghc/files/patch-ppc64?r1=494562&r2=506142 is another breakage on powerpc64 elfv1. Reverting to previous version of patch-ppc64 works it around:
/wrkdirs/usr/ports/lang/ghc/work/ghc-8.6.5/rts/Schedule.c:451:0: error:
     undefined reference to `StgRun'
    |
451 |         r = StgRun((StgFunPtr) stg_returnToStackTop, &cap->r);
    | ^
/usr/local/bin/ld: rts/dist/build/libHSrts_thr-ghc8.6.5.so: hidden symbol `StgRun' isn't defined
/usr/local/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
`gcc8' failed in phase `Linker'. (Exit code: 1)
/usr/local/bin/ld: rts/dist/build/Schedule.l_dyn_o: in function `schedule':
/usr/local/bin/ld: rts/dist/build/Schedule.debug_dyn_o: in function `schedule':


/wrkdirs/usr/ports/lang/ghc/work/ghc-8.6.5/rts/Schedule.c:451:0: error:
     undefined reference to `StgRun'
    |
451 |         r = StgRun((StgFunPtr) stg_returnToStackTop, &cap->r);
    | ^
/wrkdirs/usr/ports/lang/ghc/work/ghc-8.6.5/rts/Schedule.c:451:0: error:
     undefined reference to `StgRun'


Could the current patch-ppc64 be applied only for elfv2 systems and for elfv1 the old patch be kept?
Comment 1 Piotr Kubaj freebsd_committer freebsd_triage 2019-07-13 22:16:58 UTC
Just to explain more no. 2 - ELF_V1 doesn't seem to be properly defined.
Comment 2 Mikael Urankar freebsd_committer freebsd_triage 2019-07-14 08:36:55 UTC
(In reply to Piotr Kubaj from comment #1)
> Just to explain more no. 2 - ELF_V1 doesn't seem to be properly defined.

Are you sure elf_v1 is not passed as a compiler flag (it's the case for elfv2), can you put some code in libraries/ghci/GHCi/InfoTable.hsc and look where the build fails?

#if defined(ELF_V1)
#error "ELF_V1 system"
...
#if defined(ELF_V2)
#error "ELF_V2 system"

if you don't get an error then we should put #if defined(_CALL_ELF) && (_CALL_ELF == 1) instead.
Comment 3 Mikael Urankar freebsd_committer freebsd_triage 2019-07-14 08:41:26 UTC
(In reply to mikael.urankar from comment #2)
> elfv2), can you put some code in libraries/ghci/GHCi/InfoTable.hsc

I meant rts/StgCRun.c
Comment 4 Piotr Kubaj freebsd_committer freebsd_triage 2019-07-16 09:44:22 UTC
(In reply to mikael.urankar from comment #3)
Putting error doesn't break the build.

-+#if defined(ELF_V1)
++#if defined(_CALL_ELF) && (_CALL_ELF == 1)
^^ This allows to build it.
Comment 5 Mikael Urankar freebsd_committer freebsd_triage 2019-07-16 09:54:03 UTC
(In reply to Piotr Kubaj from comment #4)
> (In reply to mikael.urankar from comment #3)
> Putting error doesn't break the build.
> 
> -+#if defined(ELF_V1)
> ++#if defined(_CALL_ELF) && (_CALL_ELF == 1)
> ^^ This allows to build it.

Ok, can you commit the fix?
Comment 6 Piotr Kubaj freebsd_committer freebsd_triage 2019-07-16 10:03:17 UTC
(In reply to mikael.urankar from comment #5)
Not until I have both of following:
1. Maintainer approval.
2. Then also mentor approval.

Note that dtrace fix is also necessary.
Comment 7 Gleb Popov freebsd_committer freebsd_triage 2019-07-16 13:27:31 UTC
If Mikaёl is fine with this patch, so do I.
Comment 8 Mikael Urankar freebsd_committer freebsd_triage 2019-07-16 13:29:59 UTC
(In reply to Gleb Popov from comment #7)
> If Mikaёl is fine with this patch, so do I.

It's fine for me.
Comment 9 Mikael Urankar freebsd_committer freebsd_triage 2019-07-16 16:17:56 UTC
(In reply to Piotr Kubaj from comment #4)
> (In reply to mikael.urankar from comment #3)
> Putting error doesn't break the build.
> 
> -+#if defined(ELF_V1)
> ++#if defined(_CALL_ELF) && (_CALL_ELF == 1)
> ^^ This allows to build it.

can you do the same for ELF_V2? : #if defined(_CALL_ELF) && (_CALL_ELF == 2)
Comment 10 Piotr Kubaj freebsd_committer freebsd_triage 2019-07-19 15:13:10 UTC
Created attachment 205890 [details]
patch

OK?
Comment 11 Mikael Urankar freebsd_committer freebsd_triage 2019-07-19 15:17:36 UTC
(In reply to Piotr Kubaj from comment #10)
> Created attachment 205890 [details]
> patch
> 
> OK?

yes
Comment 12 Gleb Popov freebsd_committer freebsd_triage 2019-07-19 15:19:36 UTC
Comment on attachment 205890 [details]
patch

You're free to commit, then. Thanks!
Comment 13 Gleb Popov freebsd_committer freebsd_triage 2019-07-31 18:20:59 UTC
What's the status of this?
Comment 14 Piotr Kubaj freebsd_committer freebsd_triage 2019-07-31 18:24:06 UTC
(In reply to Gleb Popov from comment #13)
Waiting for mentor's review:
https://reviews.freebsd.org/D20995
Comment 15 commit-hook freebsd_committer freebsd_triage 2019-08-01 18:59:03 UTC
A commit references this bug:

Author: pkubaj
Date: Thu Aug  1 18:58:15 UTC 2019
New revision: 507820
URL: https://svnweb.freebsd.org/changeset/ports/507820

Log:
  lang/ghc: fix build on powerpc64 elfv1

  Dtrace doesn't seem to work on elfv1 powerpc64 (at least on 12.0-RELEASE).

  Also properly detect when running on elfv1 and elfv2.

  PR:		239193
  Approved by:	arrowd (maintainer), tcberner (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20995

Changes:
  head/lang/ghc/Makefile
  head/lang/ghc/files/patch-ppc64