Bug 236346 - fix build of some haskell ports with base GNU ld
Summary: fix build of some haskell ports with base GNU ld
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-03-07 06:52 UTC by Piotr Kubaj
Modified: 2019-03-21 17:40 UTC (History)
5 users (show)

See Also:


Attachments
patch (6.49 KB, patch)
2019-03-07 06:52 UTC, Piotr Kubaj
no flags Details | Diff
v2 (7.79 KB, patch)
2019-03-07 08:02 UTC, Piotr Kubaj
no flags Details | Diff
v3 (1.32 KB, patch)
2019-03-21 05:49 UTC, Piotr Kubaj
no flags 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-03-07 06:52:54 UTC
Created attachment 202671 [details]
patch

GCC architectures currently use GNU ld 2.17 (no lld). Linking some hs- ports fails, because of too large TOC. In case of C or C++ programs, you can usually add -mminimal-toc to CFLAGS or CXXFLAGS to mitigate it, but I didn't find a similar option for GHC.

Thus, use GNU ld from ports to fix build.

Tested on powerpc64 and amd64.

Hardware sponsored by IntegriCloud.
Comment 1 Piotr Kubaj freebsd_committer freebsd_triage 2019-03-07 08:02:30 UTC
Created attachment 202674 [details]
v2

Fix some more ports.

Add support to define some options only for some architectures to bsd.cabal.options.mk. This is needed to use integer-gmp and SSE only on amd64 and i386.
Comment 2 Mikael Urankar freebsd_committer freebsd_triage 2019-03-07 12:30:00 UTC
I don't have these errors on ppc64, ghc is supposed to use binutils:ld on ppc64, what's the result of grep "ld command" /usr/local/lib/ghc-8.6.4/settings?
Comment 3 Piotr Kubaj freebsd_committer freebsd_triage 2019-03-14 14:39:31 UTC
(In reply to mikael.urankar from comment #2)
root@talos:$~$ grep "ld command" /usr/local/lib/ghc-8.6.3/settings
 ("ld command", "/usr/local/bin/ld"),

But some ports still need USE_BINUTILS anyway.

E.g. another failing port:
root@talos:$/usr/ports/devel/hs-free$ make -V LD
ld
Comment 4 Mikael Urankar freebsd_committer freebsd_triage 2019-03-14 17:30:32 UTC
(In reply to Piotr Kubaj from comment #3)
Ok, I'm seeing that too with DYNAMIC option on (I turned it off to do some quick test and forgot to update my option)

I think we can use devel/binutils by default on ppc64 since it's kind of mandatory on ppc64:

Index: bsd.cabal.mk
===================================================================
--- bsd.cabal.mk        (revision 495702)
+++ bsd.cabal.mk        (working copy)
@@ -54,7 +54,7 @@
 
 CABAL_LIBDIR=          ${PREFIX}/lib/cabal/ghc-${GHC_VERSION}
 CABAL_LIBSUBDIR=       ${PACKAGE}
-CABAL_ARCH=            ${ARCH:S/amd64/x86_64/:C/armv.*/arm/}
+CABAL_ARCH=            ${ARCH:S/amd64/x86_64/:C/armv.*/arm/:S/powerpc64/ppc64/}
 CABAL_ARCHSUBDIR=      ${CABAL_ARCH}-freebsd-ghc-${GHC_VERSION}
 CABAL_LIBDIR_REL=      ${CABAL_LIBDIR:S,^${PREFIX}/,,}
 
@@ -93,6 +93,9 @@
 BUILD_DEPENDS+=        ghc>=${GHC_VERSION}:lang/ghc
 .endif
 
+.if ${ARCH} == powerpc64
+USE_BINUTILS= yes
+.endif
 
 CONFIGURE_ARGS+=       --with-gcc=${CC} --with-ld=${LD} --with-ar=${AR}
Comment 5 Mikael Urankar freebsd_committer freebsd_triage 2019-03-14 17:40:28 UTC
(In reply to mikael.urankar from comment #4)
Only the CABAL_ARCH part is needed.
Comment 6 Piotr Kubaj freebsd_committer freebsd_triage 2019-03-15 15:29:24 UTC
I have the default configuration with DYNAMIC off, though:
root@talos:$~$ pkg options ghc
ghc - BOOT: off
ghc - DOCS: off
ghc - DYNAMIC: off
ghc - GMP: off
ghc - PROFILE: off
Comment 7 Mikael Urankar freebsd_committer freebsd_triage 2019-03-20 13:26:33 UTC
(In reply to Piotr Kubaj from comment #6)
I confirm the issue with all options off, it's fixed by adding these lines to bsd.cabal.mk

+.if ${ARCH} == powerpc64
+USE_BINUTILS= yes
+.endif
Comment 8 Piotr Kubaj freebsd_committer freebsd_triage 2019-03-21 01:31:00 UTC
(In reply to mikael.urankar from comment #7)
Thanks for confirming it.

@haskell
Can you commit this patch to bsd.cabal.mk and the part with SSE2?
Comment 9 Tobias C. Berner freebsd_committer freebsd_triage 2019-03-21 05:36:22 UTC
(In reply to Piotr Kubaj from comment #8)
Thanks, for this.

Could you create a unified diff for the whole change?
Comment 10 Piotr Kubaj freebsd_committer freebsd_triage 2019-03-21 05:49:35 UTC
Created attachment 203021 [details]
v3

Sure, attached.
Comment 11 Gleb Popov freebsd_committer freebsd_triage 2019-03-21 05:59:04 UTC
(In reply to Piotr Kubaj from comment #10)

There is already .if ${ARCH} == powerpc64 block on 134 line. Please add USE_BINUTILS knob there.

Other than that, the patch looks OK.
Comment 12 Piotr Kubaj freebsd_committer freebsd_triage 2019-03-21 06:05:16 UTC
(In reply to Gleb Popov from comment #11)
There is, but not in bsd.cabal.mk, only in bsd.ghc.mk. I tested that adding USE_BINUTILS to bsd.ghc.mk doesn't change LD of hs-* ports.
Comment 13 Gleb Popov freebsd_committer freebsd_triage 2019-03-21 06:15:27 UTC
Oh, you're right. I'm OK with the patch, then.
Comment 14 commit-hook freebsd_committer freebsd_triage 2019-03-21 17:38:59 UTC
A commit references this bug:

Author: arrowd
Date: Thu Mar 21 17:38:11 UTC 2019
New revision: 496481
URL: https://svnweb.freebsd.org/changeset/ports/496481

Log:
  bsd.cabal.mk: Add USE_BINUTILS for powerpc64 arch and add support for FLAGS_DEFAULT_${ARCH} variables.

  PR:		236346
  Submitted by:	 Piotr Kubaj <pkubaj@anongoth.pl>
  Reviewed by:	Mikael Urankar <mikael.urankar@gmail.com>
  Approved by:	tcberner (mentor)

Changes:
  head/devel/hs-hashable/Makefile
  head/lang/ghc/bsd.cabal.mk
  head/lang/ghc/bsd.cabal.options.mk
Comment 15 Gleb Popov freebsd_committer freebsd_triage 2019-03-21 17:40:46 UTC
Thanks everyone for your input.