Bug 246125

Summary: math/blis: fix build on GCC architectures
Product: Ports & Packages Reporter: Piotr Kubaj <pkubaj>
Component: Individual Port(s)Assignee: Johannes M Dieterich <jmd>
Status: Closed FIXED    
Severity: Affects Only Me CC: jmd
Priority: --- Flags: jmd: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch pkubaj: maintainer-approval? (jmd)

Description Piotr Kubaj freebsd_committer 2020-05-02 15:12:34 UTC
Created attachment 214032 [details]
patch

LLVM doesn't work on GCC architectures.
Comment 1 Piotr Kubaj freebsd_committer 2020-05-02 15:13:18 UTC
Error:
ld: error: crtstuff.c:(.text+0x16): relocation R_PPC64_TOC16_DS out of range: -32824 is not in [-32768, 32767]
ld: error: crtstuff.c:(.text+0x2E): relocation R_PPC64_TOC16_DS out of range: -32816 is not in [-32768, 32767]
ld: error: crtstuff.c:(.text+0x3A): relocation R_PPC64_TOC16_DS out of range: -32808 is not in [-32768, 32767]
ld: error: crtstuff.c:(.text+0x40): call lacks nop, can't restore toc
ld: error: crtstuff.c:(.text+0x4A): relocation R_PPC64_TOC16_DS out of range: -32800 is not in [-32768, 32767]
ld: error: crtstuff.c:(.text+0xC2): relocation R_PPC64_TOC16_DS out of range: -32792 is not in [-32768, 32767]
ld: error: crtstuff.c:(.text+0xDA): relocation R_PPC64_TOC16_DS out of range: -32784 is not in [-32768, 32767]
ld: error: crtstuff.c:(.text+0x12): relocation R_PPC64_TOC16_DS out of range: -32776 is not in [-32768, 32767]
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 2 Johannes M Dieterich freebsd_committer 2020-05-02 20:02:25 UTC
Patch looks good to me, thanks!

Functionality question: on ppc64, the port currently uses the generic source code kernels (mostly for lack of HW on my side). While these kernels should not be atrociously slow, there are faster assembly microkernels available for power7 and power9. Would you be interested in that? Would you be willing to test that? As I said, I have no ppc64 HW accessible so am hesitant to enable them.
Comment 3 Piotr Kubaj freebsd_committer 2020-05-02 20:42:12 UTC
I already tested that. The problem is that power7 is currently disabled:
configure:   amd64 (zen2 zen generic)
configure:   bgq (bgq)
configure:   cortexa15 (cortexa15)
configure:   cortexa53 (cortexa53)
configure:   cortexa57 (cortexa57)
configure:   cortexa9 (cortexa9)
configure:   generic (generic)
configure:   intel64 (penryn generic)
configure:   penryn (penryn)
configure:   power9 (power9)
configure:   thunderx2 (thunderx2)
configure:   x86_64 (penryn zen2 zen generic)
configure:   zen (zen)
configure:   zen2 (zen2)

Is power7 kernel broken, or just disabled by accident? I couldn't find any info on that.

And for power9, here clang won't even build it:
config/power9/make_defs.mk:73: *** gcc/xlc is required for this configuration..  Stop.
After setting it to build with gcc9:
gmake[1]: Entering directory '/wrkdirs/usr/ports/math/blis/work/blis-0.7.0'
Compiling obj/power9/config/power9/bli_cntx_init_power9.o ('power9' CFLAGS for config code)
config/power9/bli_cntx_init_power9.c: In function 'bli_cntx_init_power9':
config/power9/bli_cntx_init_power9.c:71:2: warning: implicit declaration of function 'bli_cntx_init_power9_ref'; did you mean 'bli_cntx_init_power9'? [-Wimplicit-function-declaration]
   71 |  bli_cntx_init_power9_ref( cntx );
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
      |  bli_cntx_init_power9
config/power9/bli_cntx_init_power9.c:84:40: error: 'bli_dgemm_power9_asm_12x6' undeclared (first use in this function)
   84 |    BLIS_GEMM_UKR,       BLIS_DOUBLE,   bli_dgemm_power9_asm_12x6,     FALSE,
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
gmake[1]: *** [Makefile:574: obj/power9/config/power9/bli_cntx_init_power9.o] Error 1
gmake[1]: Leaving directory '/wrkdirs/usr/ports/math/blis/work/blis-0.7.0'
*** Error code 1

Upstream issue at https://github.com/flame/blis/issues/398
Comment 4 Johannes M Dieterich freebsd_committer 2020-05-02 20:51:42 UTC
I see. Thanks for trying - I've subscribed to notifications on that issue.
Comment 5 commit-hook freebsd_committer 2020-05-02 23:19:08 UTC
A commit references this bug:

Author: pkubaj
Date: Sat May  2 23:19:03 UTC 2020
New revision: 533711
URL: https://svnweb.freebsd.org/changeset/ports/533711

Log:
  math/blis: fix build on GCC architectures

  Use GCC on GCC architectures, LLVM causes errors:
  ld: error: crtstuff.c:(.text+0x16): relocation R_PPC64_TOC16_DS out of range: -32824 is not in [-32768, 32767]
  ld: error: crtstuff.c:(.text+0x2E): relocation R_PPC64_TOC16_DS out of range: -32816 is not in [-32768, 32767]
  ld: error: crtstuff.c:(.text+0x3A): relocation R_PPC64_TOC16_DS out of range: -32808 is not in [-32768, 32767]
  ld: error: crtstuff.c:(.text+0x40): call lacks nop, can't restore toc
  ld: error: crtstuff.c:(.text+0x4A): relocation R_PPC64_TOC16_DS out of range: -32800 is not in [-32768, 32767]
  ld: error: crtstuff.c:(.text+0xC2): relocation R_PPC64_TOC16_DS out of range: -32792 is not in [-32768, 32767]
  ld: error: crtstuff.c:(.text+0xDA): relocation R_PPC64_TOC16_DS out of range: -32784 is not in [-32768, 32767]
  ld: error: crtstuff.c:(.text+0x12): relocation R_PPC64_TOC16_DS out of range: -32776 is not in [-32768, 32767]
  clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

  PR:		246125
  Approved by:	jmd (maintainer)

Changes:
  head/math/blis/Makefile