# LLVM problem with running GLFW.jl

**URL:** https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110
**Category:** General Usage
**Created:** [December 23, 2016, 1:38am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110 "2016-12-23T01:38:00Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)
#### Post date: [December 23, 2016, 1:38am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/1 "2016-12-23T01:38:00Z")

</div>

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

```nohighlight
[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.

---

<div class="post-metadata">

### Author: ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)
#### Post date: [December 23, 2016, 1:39am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/2 "2016-12-23T01:39:57Z")

</div>

@juliohm recently reported a similar issue to _OpenCL.jl_:

> <https://github.com/JuliaGPU/OpenCL.jl/issues/125>
>
> Whenever I try to use \`OpenCL.jl\`, including its test suite, I get the following… error:
> 
> \`\`\`julia
> using OpenCL
> cl.create\_some\_context()
> \`\`\`
> \>: CommandLine Error: Option 'help-list' registered more than once!
> LLVM ERROR: inconsistency in registered CommandLine options
> 
> Currently, I cannot use my GPU. Tried to checkout the master branch, but the problem is still there. Below are more details about the environment:
> 
> \>Julia Version 0.5.1-pre+31
> Commit 6a1e339ac\* (2016-11-17 17:50 UTC)
> Platform Info:
> System: Linux (x86\_64-pc-linux-gnu)
> CPU: Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
> WORD\_SIZE: 64
> BLAS: libopenblas (USE64BITINT DYNAMIC\_ARCH NO\_AFFINITY Haswell)
> LAPACK: libopenblas64\_
> LIBM: libopenlibm
> LLVM: libLLVM-3.7.1 (ORCJIT, broadwell)
> 
> \> - OpenCL 0.5.0

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

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [December 23, 2016, 10:22am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/3 "2016-12-23T10:22:22Z")

</div>

If @vchuravy is right, maybe this is the solution:  
[https://github.com/JuliaGL/GLFW.jl/issues/96](https://github.com/JuliaGL/GLFW.jl/issues/96)

---

<div class="post-metadata">

### Author: ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)
#### Post date: [December 23, 2016, 10:33am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/4 "2016-12-23T10:33:57Z")

</div>

This [issue](https://github.com/JuliaLang/julia/issues/19606) could be the same thing, if so setting `GALLIUM_DRIVER="softpipe"` might help (though it slows down the driver, no doubt).

---

<div class="post-metadata">

### Author: ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)
#### Post date: [December 23, 2016, 3:47pm UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/5 "2016-12-23T15:47:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)
#### Post date: [December 24, 2016, 12:19am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/6 "2016-12-24T00:19:19Z")

</div>

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:

```julia
[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
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?

---

<div class="post-metadata">

### Author: ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)
#### Post date: [December 26, 2016, 4:34pm UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/7 "2016-12-26T16:34:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)
#### Post date: [December 26, 2016, 6:00pm UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/8 "2016-12-26T18:00:02Z")

</div>

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

```bash
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.

---

<div class="post-metadata">

### Author: ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)
#### Post date: [December 27, 2016, 1:16am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/9 "2016-12-27T01:16:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [December 30, 2016, 6:36pm UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/10 "2016-12-30T18:36:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)
#### Post date: [December 31, 2016, 12:46am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/11 "2016-12-31T00:46:03Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)
#### Post date: [January 17, 2017, 4:09pm UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/12 "2017-01-17T16:09:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ararslan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ararslan/32/3825_2.png) [@ararslan](https://discourse.julialang.org/u/ararslan)
#### Post date: [January 18, 2017, 5:42am UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/13 "2017-01-18T05:42:13Z")

</div>

> 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. 🙂

---

<div class="post-metadata">

### Author: ![ko56](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ko56/32/2684_2.png) [@ko56](https://discourse.julialang.org/u/ko56)
#### Post date: [January 18, 2017, 4:38pm UTC](https://discourse.julialang.org/t/llvm-problem-with-running-glfw-jl/1110/14 "2017-01-18T16:38:47Z")

</div>

Thanks, I just did that.
