LLVM problem with running GLFW.jl


#1

Hi, I have Julia 0.5.0 and I’m trying to get the GLFW package to work.
This is what happens:

[ko@wiley ~]$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |  x86_64-unknown-freebsd11.0

julia> import GLFW

julia> GLFW.CreateWindow(800, 600, "InexactError")
: CommandLine Error: Option 'track-memory' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
[ko@wiley ~]$ 

I installed the glfw library in its own, outside of Julia, and all the tests work fine.
The above problem seems to be with the call to function CreateWindow(…) in glfw3.jl.

I don’t understand enough about Julia’s internals to figure this out, but I have lots of other packages installed and all work fine. Thanks for any suggestions.


#2

@juliohm recently reported a similar issue to OpenCL.jl:

@jameson might this be the issues that the mesa drivers are dynamically loading LLVM?


#3

If @vchuravy is right, maybe this is the solution:


#4

This issue could be the same thing, if so setting GALLIUM_DRIVER="softpipe" might help (though it slows down the driver, no doubt).


#5

Yes, that looks like the same issue. As Keno noted https://github.com/JuliaGL/GLFW.jl/issues/96#issuecomment-265580404, complain to your distro that they are linking their graphics libraries incorrectly.


#6

Thanks to everyone for their help. I did as suggested

For a fix, try linkinkg LLVM statically. So when building Julia, insert this line override USE_LLVM_SHLIB = 0 into Make.user

and indeed I have a libjulia.so that does not reference libllvm:

[ko@wiley ~]$ ldd /opt/julia/0.5.0/lib/libjulia.so
/opt/julia/0.5.0/lib/libjulia.so:
	libz.so.6 => /lib/libz.so.6 (0x8026b1000)
	libm.so.5 => /lib/libm.so.5 (0x8028c8000)
	libelf.so.2 => /lib/libelf.so.2 (0x802af3000)
	libkvm.so.7 => /lib/libkvm.so.7 (0x802d0a000)
	librt.so.1 => /usr/lib/librt.so.1 (0x802f18000)
	libc++.so.1 => /usr/lib/libc++.so.1 (0x80311d000)
	libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x8033dc000)
	libgcc_s.so.1 => /usr/local/lib/gcc6/libgcc_s.so.1 (0x8035fa000)
	libc.so.7 => /lib/libc.so.7 (0x800823000)
	libthr.so.3 => /lib/libthr.so.3 (0x803810000)
[ko@wiley ~]$ 

Unfortunately the problem remains the same:’

julia> using GLFW

julia> GLFW.CreateWindow(800, 600, "InexactError")
: CommandLine Error: Option 'track-memory' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
[ko@wiley ~]$ 

Am I missing something?


#7

I looked in the source for ‘track-memory’, and the only place I see it in the build is in

deps/srccache/llvm-3.7.1/lib/Support/Timer.cpp


#8

What graphics driver are you using? If it is based on Gallium 3D, you can set the environment variable like this:

export GALLIUM_DRIVER="softpipe"

before launching Julia to disable its LLVM code path, that should at least eliminate if this is still related to the 3D driver.


#9

I am not using Gallium, just Mesa-based OpenGL. But I tried your suggestion anyhow, and it didn’t help.


#10

Have you actually tried updating the video driver or switching to the proprietary driver?
The defaults in linux are sometimes fairly terrible.


#11

I certainly don’t understand enough of what’s going on, but wouldn’t the fact that GLFW works fine when built outside of Julia indicate that whatever drivers are being used are ok?

The graphics driver is xf86-video-ati-7.5.0, and the hardware is a Radeon HD 8570 chip. (Also, I am runing FreeBDS 11, not Linux.)

Anyhow, can you suggest some way to debug this?


#12

The bug goes away if you build Julia with clang on FreeBSD, instead of with gcc as recommended in the platform-specific instructions. I don’t understand the underlying reason, but that’s ok.

There is one residual problem, with ModernGL/src/ModernGL.jl, line 29: change is_linux() to is_unix(). Then Pkg.test(“GLFW”) passes.


#13

The bug goes away if you build Julia with clang on FreeBSD, instead of with gcc as recommended in the platform-specific instructions.

Yes, Julia should be built with Clang on FreeBSD. The requirement to install GCC is for gfortran, which isn’t installed by default on modern versions of FreeBSD.

There is one residual problem, with ModernGL/src/ModernGL.jl, line 29: change is_linux() to is_unix(). Then Pkg.test(“GLFW”) passes.

Nice observation! I imagine the package maintainers would be quite grateful if you would be willing to submit a PR for that change. :slight_smile:


#14

Thanks, I just did that.