Bug 231479 - lang/julia: build stuck while running libwhich -p libopenblasp.so using synth
Summary: lang/julia: build stuck while running libwhich -p libopenblasp.so using synth
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: Li-Wen Hsu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-19 14:19 UTC by Trond.Endrestol
Modified: 2018-09-23 10:12 UTC (History)
2 users (show)

See Also:
Trond.Endrestol: maintainer-feedback? (iblis.dif01)


Attachments
The last part of synth's build log (14.24 KB, text/plain)
2018-09-19 14:19 UTC, Trond.Endrestol
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trond.Endrestol 2018-09-19 14:19:06 UTC
Created attachment 197233 [details]
The last part of synth's build log

I'm using ports-mgmt/synth to build lang/julia on base/head r338733.
lang/julia is stuck while running /construction/xports/lang/julia/work/julia/usr/tools/libwhich -p libopenblasp.so.
synth is configured to run without any watchdogs and the entire build of lang/julia was close to 8 hours of running time before I intervened!
Only the last part synth's build log is attached due to size restrictions in BugZilla. Complete build log is available at https://ximalas.info/~trond/lang-julia-r338733/
I'm inclined to try the other julia ports.
Comment 1 Iblis Lin 2018-09-19 17:19:58 UTC
(In reply to Trond.Endrestol from comment #0)
Hi,
I didn't find any lines about `libwhich -p ...` in log.
Did I miss something?
Comment 2 Iblis Lin 2018-09-19 17:32:32 UTC
(In reply to Trond.Endrestol from comment #0)

weird, I'm on r338678, and my `synth test lang/julia` works.

└─[iblis@Arondight]% uname -a
FreeBSD Arondight 12.0-ALPHA6 FreeBSD 12.0-ALPHA6  r338678  amd64
Comment 3 Trond.Endrestol 2018-09-19 18:15:27 UTC
(In reply to Iblis Lin from comment #1)
It's a bit hidden in the build log, but very visible using top or sysutils/htop.

gmake[2]: *** [Makefile:177: /construction/xports/lang/julia/work/julia/usr/lib/julia/libopenblasp.so] Error 143
Comment 4 Trond.Endrestol 2018-09-19 18:18:42 UTC
(In reply to Iblis Lin from comment #2)
Maybe my setup is to blame as lang/julia07 exhibits the very same issue. I haven't changed anything, and the last successful build and install was on August 6th, julia-0.6.4_1. Thus, I'll try lang/julia06.
Comment 5 Trond.Endrestol 2018-09-19 18:53:20 UTC
(In reply to Trond.Endrestol from comment #4)
Building lang/julia06 does not show any problems. I'm using the default settings in all cases.
Comment 6 Trond.Endrestol 2018-09-19 18:58:07 UTC
(In reply to Trond.Endrestol from comment #5)
I have uploaded the build logs for lang/julia0{6,7} in case you want to examine those logs.
Comment 7 Trond.Endrestol 2018-09-22 09:56:57 UTC
I did some more investigations using gdb. Apparently, libwhich halts when reading the libopenblasp.so library installed in the chroot env. Running the same command on, say, /lib/libc.so.7 gives the desired result.

trond@freebsd-head-zfs:~>gdb /var/synth/builders/synth-live/SL02_work/xports/lang/julia/work/julia/usr/tools/libwhich
GNU gdb (GDB) 8.1.1 [GDB v8.1.1 for FreeBSD]
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd12.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /var/synth/builders/synth-live/SL02_work/xports/lang/julia/work/julia/usr/tools/libwhich...(no debugging symbols found)...done.
(gdb) set args -p /var/synth/builders/synth-live/SL02_localbase/lib/libopenblasp.so
(gdb) b main
Breakpoint 1 at 0x400c14
(gdb) r
Starting program: /var/synth/builders/synth-live/SL02_work/xports/lang/julia/work/julia/usr/tools/libwhich -p /var/synth/builders/synth-live/SL02_localbase/lib/libopenblasp.so

Breakpoint 1, 0x0000000000400c14 in main ()
(gdb) s
Single stepping until exit from function main,
which has no line number information.
0x0000000000400b60 in get_names ()
(gdb) 
Single stepping until exit from function get_names,
which has no line number information.
0x0000000000400c55 in main ()
(gdb) list
No symbol table is loaded.  Use the "file" command.
(gdb) n
Single stepping until exit from function main,
which has no line number information.
[New LWP 100898 of process 30266]
[New LWP 100899 of process 30266]
[New LWP 100900 of process 30266]

Nothing happens at all at this point, and you can't even Ctrl+C your way out of the debugger.
Comment 8 Trond.Endrestol 2018-09-22 10:06:09 UTC
These are the options I've chosen for math/openblas:

===> The following configuration options are available for openblas-0.2.20_3,1:
     AVX=off: Support Advanced Vector Extensions (AVX)
     AVX2=off: Support Advanced Vector Extensions 2 (AVX2)
     DYNAMIC_ARCH=on: Support multiple CPU types on i386 and amd64
     INTERFACE64=on: Use 8 byte integers on 64-bit architectures
     OPENMP=off: Use OpenMP for threading

These are the options I've chosen for lang/julia:

===> The following configuration options are available for julia-1.0.0:
     DEBUG=off: Build with debugging support
     DESKTOP=off: Install icon, .desktop and appdata files
     DOCS=on: Build and/or install documentation
     GPL_LIBS=off: Build with GPL lib: SUITESPARSE
     NATIVE=off: Build with native CPU JIT tuning
====> Math library implementation: you have to select exactly one of them
     SYSLIBM=on: Build with system libm
     OPENLIBM=off: Build with OpenLibm (math/openlibm)

And, these are the options I've chosen for lang/julia06:

===> The following configuration options are available for julia06-0.6.4_1:
     DEBUG=off: Build with debugging support
     DESKTOP=off: Install icon, .desktop and appdata files
     DOCS=on: Build and/or install documentation
     EXAMPLES=on: Build and/or install examples
     GPL_LIBS=off: Build with GPL libs: FFTW and SUITESPARSE
     NATIVE=off: Build with native CPU JIT tuning
====> Build self-shipped private depends
     ARPACK=off: Build self-shipped private arpack-ng
     LLVM=off: Build self-shipped private LLVM
====> Math library implementation: you have to select exactly one of them
     SYSLIBM=on: Build with system libm
     OPENLIBM=off: Build with OpenLibm (math/openlibm)

Is there anything else that might shed some light on the issue at hand?
Comment 9 Iblis Lin 2018-09-22 10:21:02 UTC
libwhich only presents in 0.7/1.0.

Maybe we can build julia without it.
Could you try this patch out?
and make sure your julia is functional.

diff --git a/lang/julia/files/patch-base_Makefile b/lang/julia/files/patch-base_Makefile
new file mode 100644
index 000000000000..f8bafef4f5b7
--- /dev/null
+++ b/lang/julia/files/patch-base_Makefile
@@ -0,0 +1,11 @@
+--- base/Makefile.orig 2018-09-20 04:08:53 UTC
++++ base/Makefile
+@@ -109,7 +109,7 @@ ifneq ($(OS), WINNT)
+ # put a symlink in the private libdir.
+ # System package managers may want to install these links manually,
+ # but if not, this will try to create the proper symlink to the right minor version.
+-all: symlink_system_libraries
++all:
+ SYMLINK_SYSTEM_LIBRARIES :=
+ 
+ # if it's a symlink, pick up the symlink target instead, for one level of indirection
Comment 10 Trond.Endrestol 2018-09-22 10:28:22 UTC
Grepping around for libwhich in the various Makefiles, pointed me to base/Makefile, line 153:

define symlink_system_library
symlink_$1: $$(build_private_libdir)/$1.$$(SHLIB_EXT)
$$(build_private_libdir)/$1.$$(SHLIB_EXT):
	REALPATH=`$$(call spawn,$$(build_depsbindir)/libwhich) -p $$(notdir $$@)` && \
	$$(call resolve_path,REALPATH) && \
	[ -e "$$$$REALPATH" ] && \
	([ ! -e "$$@" ] || rm "$$@") && \
	echo ln -sf "$$$$REALPATH" "$$@" && \
	ln -sf "$$$$REALPATH" "$$@"
ifneq ($2,)
ifneq ($$(USE_SYSTEM_$2),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_$1
endif
endif
endef

At line 177 of the same file, we find:

$(eval $(call symlink_system_library,$(LIBBLASNAME),BLAS))

By now, we know where libwhich is being called, and for some reason the libopenblasp.so file isn't what LLVM's libwhich expects, and the latter isn't robust enough to handle the unexpected.
Comment 11 Iblis Lin 2018-09-22 10:33:46 UTC
(In reply to Trond.Endrestol from comment #10)
yeah, my patch will disable those make targets.
Comment 12 Trond.Endrestol 2018-09-22 10:38:25 UTC
(In reply to Iblis Lin from comment #9)
I placed the patch in the files directory, and synth's running. We'll know shortly how this works out.
Comment 13 Trond.Endrestol 2018-09-22 12:06:03 UTC
(In reply to Trond.Endrestol from comment #12)
Looking good:
$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.0 (2018-08-08)
 _/ |\__'_|_|_|\__'_|  |  FreeBSD ports lang/julia build
|__/                   |

julia> 2+2
4

julia> ^D
$
Comment 14 Iblis Lin 2018-09-22 12:54:50 UTC
(In reply to Trond.Endrestol from comment #13)
Great!

How about the Pkg functions?

In the REPL, press `]` to enter the Pkg mode,
then issue `add OhMyREPL`.

└─[iblis@Arondight]% julia        
               _                                    
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |                             
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |  
  | | |_| | | | (_| |  |  Version 1.0.0 (2018-08-08)
 _/ |\__'_|_|_|\__'_|  |  FreeBSD ports lang/julia build
|__/             m     | [              
                      
(v1.0) pkg> add OhMyREPL
  Updating registry at `~/.julia/registries/General`               
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...                                 
 Installed BinaryProvider ─ v0.5.0                                                                             
  Updating `~/.julia/environments/v1.0/Project.toml`
  [b99e7846] ↑ BinaryProvider v0.4.2 ⇒ v0.5.0           
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [b99e7846] ↑ BinaryProvider v0.4.2 ⇒ v0.5.0
Comment 15 Trond.Endrestol 2018-09-22 13:38:05 UTC
(In reply to Iblis Lin from comment #14)
trond@freebsd-head-zfs:~>julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.0 (2018-08-08)
 _/ |\__'_|_|_|\__'_|  |  FreeBSD ports lang/julia build
|__/                   |

(v1.0) pkg> add OhMyREPL
   Cloning default registries into /home/trond/.julia/registries
   Cloning registry General from "https://github.com/JuliaRegistries/General.git"
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
 Installed Crayons ââ v1.0.0
 Installed Tokenize â v0.5.2
 Installed OhMyREPL â v0.3.0
  Updating `~/.julia/environments/v1.0/Project.toml`
  [5fb14364] + OhMyREPL v0.3.0
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [a8cc5b0e] + Crayons v1.0.0
  [5fb14364] + OhMyREPL v0.3.0
  [0796e94c] + Tokenize v0.5.2
  [2a0f44e3] + Base64 
  [ade2ca70] + Dates 
  [8ba89e20] + Distributed 
  [b77e0a4c] + InteractiveUtils 
  [76f85450] + LibGit2 
  [8f399da3] + Libdl 
  [37e2e46d] + LinearAlgebra 
  [56ddb016] + Logging 
  [d6f4376e] + Markdown 
  [44cfe95a] + Pkg 
  [de0858da] + Printf 
  [3fa0cd96] + REPL 
  [9a3f8284] + Random 
  [ea8e919c] + SHA 
  [9e88b42a] + Serialization 
  [6462fe0b] + Sockets 
  [8dfed614] + Test 
  [cf7118a7] + UUIDs 
  [4ec0a83e] + Unicode 

(v1.0) pkg>
Comment 16 Iblis Lin 2018-09-22 13:47:18 UTC
(In reply to Trond.Endrestol from comment #15)
(Y)
Comment 17 commit-hook freebsd_committer 2018-09-23 10:12:12 UTC
A commit references this bug:

Author: lwhsu
Date: Sun Sep 23 10:11:12 UTC 2018
New revision: 480477
URL: https://svnweb.freebsd.org/changeset/ports/480477

Log:
  - Remove using of libwhich from build process

  It doesn't affect julia work but may cause building proess hang

  PR:		231479
  Submitted by:	Iblis Lin <iblis@hs.ntnu.edu.tw> (maintainer)
  Reported by:	Trond.Endrestol@ximalas.info
  Obtained from:	https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231479#c9

Changes:
  head/lang/julia/Makefile
  head/lang/julia/files/patch-base_Makefile
  head/lang/julia07/Makefile
  head/lang/julia07/files/patch-base_Makefile