[GHC] #10170: Find versioned versions of LLVM tools

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.11 (LLVM) | Operating System: Unknown/Multiple Keywords: | Type of failure: None/Unknown Architecture: | Blocked By: Unknown/Multiple | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Since it has become more widely know that the LLVM developers often make breaking changes to the IR language between releases, some Linu distributions (eg Debain and hence Ubuntu) have started doing multi- version LLVM installs. For instance on Debian, the llvm-3.6 programs are installed in `/usr/lib/llvm-3.6/bin` as `llc` and `opt`. I propose that the `configure.ac` and `aclocal.m4` configuration goop be modified to look for `llc` and `opt` in these versioned `/usr/lib/llvm-X.Y` locations. I'm also willing to do the hard yards on implementing this if people think its a good idea. This can be seen as a step along the way to more stringent LLVM versioning requirements. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools
-------------------------------------+-------------------------------------
Reporter: erikd | Owner: erikd
Type: bug | Status: new
Priority: normal | Milestone: 7.12.1
Component: Compiler (LLVM) | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by thomie):
This should already work. If it doesn't, than that's indeed a bug. See
commit 1dfab7a8ace5f09f00f8fb695932b4324e88b822
{{{
Author: Thomas Miedema

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by erikd): @thomie It doesn't work now, because on my machine it picks `/usr/bin/llc` (which is actually a symlink to `/usr/lib/llvm-3.5/bin/llc`) before it picks `/usr/lib/llvm-3.6/bin/llc`. I can't remove llvm-3.5 because I have other tools that rely on it. If people think its a good idea, I would make the configure script check for a specific version of the llvm tools (currently 3.6 because thats all that seems to work currently). With this versioned check, when we move to another version of LLVM there should be one single change to configure.ac to make it check for the new version. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): Sounds good, to me at least. Hopefully it allows you to delete that `FIND_LLVM` macro. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): On my Debian system there is also `/usr/bin/llc-3.x` which is a symlink to `/usr/lib/llvm-3.x/bin/llc`. If GHC requires LLVM 3.6, for instance, wouldn't it be best to look for `llc-3.6` in the `$PATH`, rather than specifically `/usr/lib/llvm-3.6/bin/llc`? Then it would also work if the user installed `llc-3.6` other than through their package manager (e.g., in `~/bin`). Maybe this is what you were suggesting in comment:2, not sure. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by erikd): @rwbarton Yes, it should look for a versioned `/usr/lib/llc-X.Y` but also accept `/usr/lib/llvm-3.6/bin/llc`. More importantly configure should fail if whatever version of `llc` it finds isn't the currently blessed version. @thomie Unfortunately, I think that `FIND_LLVM` macro will need to grow, not disappear. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by erikd): Nope, it turns out that on Debian, the `/usr/bin/llc-3.6` symlink is managed by the `llvm-3.6` package. Its the `/usr/bin/llc` symlink that is managed by the Debian `alternatives` system. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton):
More importantly configure should fail if whatever version of llc it finds isn't the currently blessed version.
Right.
Yes, it should look for a versioned `/usr/lib/llc-X.Y` but also accept `/usr/lib/llvm-3.6/bin/llc`
Let me rephrase what I meant. Hard-coding knowledge of the directory `/usr/lib/llvm-3.6/bin` into ghc's autoconf is wrong because (in my estimation) the fact that `llc-3.6` is a symlink to `/usr/lib/llvm-3.6/bin/llc` is an implementation detail of the Debian `llvm-3.6` package and the executable may be (and is) located elsewhere on other distributions. The public interface of `llvm-3.6` (on Debian and hopefully on other distributions) is that it provides `llc-3.6` on the standard `$PATH`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie):
I think that FIND_LLVM macro will need to grow, not disappear.
In `configure.ac`, can't you just replace: {{{ FIND_LLVM_PROG([LLC], [llc], [llc]) }}} With: {{{ FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([LLC], [llc], [llc-3.6]) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): I thought the plan was to ship llvm with ghc; wouldn’t that make this obsolete? (Distro packagers can still explicitly tell ghc to use a system installed llvm of the right version using --with-llc etc.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): We need llvm 3.6 now, for running the full testsuite. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by erikd): @thomie That would work for some cases, but imo, if `llc-3.6` does not exist, the configure script should still check to see if `llc` is the required version. @rwbarton I agree about not looking for `/usr/lib/llvm-3.6/bin/llc`. That was a silly idea. @nomeata That may be true, but we still need to fix this for people compiling from git. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by erikd): I've been doing some hacking on this and here is my current solution (for now `X.Y` is `3.6`): * The configure script should check for `llc-X.Y` and `opt-X.Y` *before* it checks for plain `llc` and `opt`. * Only check for plain `llc` and `opt` if the explicitly versioned ones are not found. * If it finds plain `llc` and `opt` check that the version is `X.Y`. The above currently works, but causes other problems in this check: {{{ checking whether bootstrap compiler is affected by bug 9439... You are using a new version of LLVM that hasn't been tested yet! We will try though... /usr/bin/opt-3.6: /tmp/ghc12163_0/ghc12163_2.ll:7:6: error: unexpected type in metadata definition !0 = metadata !{metadata !"top", i8* null} ^ failed to compile }}} The problem here is that this checks the bootstrap compiler bug using the detected `LlcCmd` (which now *must* be `llc-3.6`) which doesn't support he LLVM IR syntax above. I think is in-correct. The bootstrap compiler should already have the location of the `llc` and `opt` it was compiled for in its `settings` file (these have been present in that file since ghc 7.6 but they are not present in eg 7.4.2). Its the llc version in the settings file which should be checked for bug #9439, not the one detected by the configure script. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): That's easy to fix. Revert this change I made in 1dfab7a8ace5f09f00f8fb695932b4324e88b822: {{{ \--- a/configure.ac +++ b/configure.ac @@ -508,7 +508,7 @@ then echo "main = putStrLn \"%function\"" > conftestghc.hs # Check whether LLVM backend is default for this platform - "${WithGhc}" conftestghc.hs 2>&1 >/dev/null + "${WithGhc}" -pgmlc="${LlcCmd}" -pgmlo="${OptCmd}" conftestghc.hs 2>&1 >/dev/null res=`./conftestghc` if test "x$res" = "x%object" then @@ -525,7 +525,7 @@ then # -fllvm is not the default, but set a flag so the Makefile can check # -for it in the build flags later on - "${WithGhc}" -fforce-recomp -fllvm conftestghc.hs 2>&1 >/dev/null + "${WithGhc}" -fforce-recomp -pgmlc="${LlcCmd}" -pgmlo="${OptCmd}" -fllvm conftestghc.hs 2>&1 >/dev/null if test $? = 0 then res=`./conftestghc` }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: D745 -------------------------------------+------------------------------------- Changes (by erikd): * differential: => D745 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D745 -------------------------------------+------------------------------------- Changes (by rwbarton): * differential: D745 => Phab:D745 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools
-------------------------------------+-------------------------------------
Reporter: erikd | Owner: erikd
Type: bug | Status: new
Priority: normal | Milestone: 7.12.1
Component: Compiler (LLVM) | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions: Phab:D745
-------------------------------------+-------------------------------------
Comment (by Erik de Castro Lopo

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: closed Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D745 -------------------------------------+------------------------------------- Changes (by erikd): * status: new => closed * resolution: => fixed Comment: Since this patch is all about llvm-3.6, this is a 7.11+ specific patch and hence does not need to be backported to 7.10. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D745 Wiki Page: | -------------------------------------+------------------------------------- Comment (by jberryman): Hi, this seems to have regressed. Should I open a new ticket? I'd like for ghc to look for versioned llvm executables in the PATH and prefer those over the unversioned names (if they exist). If #10074 is stalled this change seems sufficient to me. As it stands using multiple ghc versions with fllvm side by side is pretty inconvenient (or else I haven't figured out the trick). {{{ $ echo $PATH /home/me/Code/NOT_MY_CODE/spack/bin:/usr/lib/llvm-6.0/bin:/home/me/.cargo/bin:/usr/local/go/bin:/home/me/.rbenv/shims:/home/me/.rbenv/bin:/home/me/.play-2.2.2:/home/me/.node/bin:/usr/local/node/bin:/home/me/.local/bin:/home/me/.cabal/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/me/.gem/ruby/2.2.0/bin:/home/me/.go/bin $ which opt /usr/lib/llvm-6.0/bin/opt $ ghc --make -fforce-recomp -fllvm hello.hs -o hello_llvm [1 of 1] Compiling Main ( hello.hs, hello.o ) Linking hello_llvm ... $ export PATH=/home/me/.cargo/bin:/usr/local/go/bin:/home/me/.rbenv/shims:/home/me/.rbenv/bin:/home/me/.play-2.2.2:/home/me/.node/bin:/usr/local/node/bin:/home/me/.local/bin:/home/me/.cabal/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/me/.gem/ruby/2.2.0/bin:/home/me/.go/bin $ which opt opt not found $ which opt-6.0 1 ↵ /usr/bin/opt-6.0 $ ghc --make -fforce-recomp -fllvm hello.hs -o hello_llvm [1 of 1] Compiling Main ( hello.hs, hello.o ) <no location info>: error: Warning: Couldn't figure out LLVM version! Make sure you have installed LLVM 6.0 ghc: could not execute: opt }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10170: Find versioned versions of LLVM tools -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler (LLVM) | Version: 7.11 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D745 Wiki Page: | -------------------------------------+------------------------------------- Comment (by jberryman): Oh hm, it's not clear if this ticket was also (like #7661) supposed to be about the ghc build system. I care about this as a user of ghc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10170#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC