llvm-hs / llvm-hs/llvm-hs-examples
Problems running examples in NixOS
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 72
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
First of all: greetings, and thank you for such magnifical software.
I am having trouble running some of the examples. I am currently using NixOS (channel release 20.3 stable).
I can run the first example without a problem (i.e. cabal run basic) but not the rest.
To reproduce this problem one should use the shell.nix from the llvm-hs repo (llvm-9 branch) and run:
╭─hhefesto@Olimpo ~/src/llvm-hs ‹llvm-9›
╰─$ nix-shell shell.nix
╭─hhefesto@Olimpo ~/src/llvm-hs ‹llvm-9›
╰─$ cd ../llvm-hs-examples ghc-shell-for-packages
╭─hhefesto@Olimpo ~/src/llvm-hs-examples ‹master›
╰─$ cabal run basic ghc-shell-for-packages
Up to date
; ModuleID = 'basic'
source_filename = "<string>"
define i32 @add(i32 %a, i32 %b) {
entry:
%result = add i32 %a, %b
ret i32 %result
}
╭─hhefesto@Olimpo ~/src/llvm-hs-examples ‹master›
╰─$ cabal run orc ghc-shell-for-packages
Up to date
; ModuleID = 'basic'
source_filename = "<string>"
define i32 @add() {
entry:
ret i32 42
}
JITSymbolError ""
Eager JIT Result:
()
╭─hhefesto@Olimpo ~/src/llvm-hs-examples ‹master›
╰─$ cabal run arith ghc-shell-for-packages
Up to date
*** Expression ***
\x -> sin(3.141592653589793 * x / 2.0) * (1.0 + sqrt(x)) * (1.0 + sqrt(x))
*** LLVM IR ***
; ModuleID = 'arith.ll'
source_filename = "<string>"
declare double @llvm.sin.f64(double)
declare double @llvm.sqrt.f64(double)
define double @f(double %x_0) {
%x_1 = fmul double 0x400921FB54442D18, %x_0
%x_2 = fdiv double %x_1, 2.000000e+00
%x_3 = call double @llvm.sin.f64(double %x_2)
%x_4 = call double @llvm.sqrt.f64(double %x_0)
%x_5 = fadd double 1.000000e+00, %x_4
%x_6 = call double @llvm.sqrt.f64(double %x_0)
%x_7 = fadd double 1.000000e+00, %x_6
%x_8 = fmul double %x_5, %x_7
%x_9 = fmul double %x_3, %x_8
ret double %x_9
}
arith: zdllvmzmhszm9zi0zi1zm96887f153c504d115c8590f781d2d454ad5394458a40a98d753cc870a382f8c1zdLLVMziInternalziFFIziOrcJITzdllvmzzmhszzm9zzi0zzi1zzm96887f153c504d115c8590f781d2d454ad5394458a40a98d753cc870a382f8c1zuLLVMzziInternalzziFFIzziOrcJITzuwrapGetSymbolResolver: uncaught exception
╭─hhefesto@Olimpo ~/src/llvm-hs-examples ‹master›
╰─$ cabal run irbuilder ghc-shell-for-packages
Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
- examples-1.0.0.0 (exe:irbuilder) (first run)
Configuring executable 'irbuilder' for examples-1.0.0.0..
Preprocessing executable 'irbuilder' for examples-1.0.0.0..
Building executable 'irbuilder' for examples-1.0.0.0..
[1 of 1] Compiling Main ( irbuilder/Main.hs, /home/hhefesto/src/llvm-hs-examples/dist-newstyle/build/x86_64-linux/ghc-8.8.1/examples-1.0.0.0/x/irbuilder/build/irbuilder/irbuilder-tmp/Main.o )
Linking /home/hhefesto/src/llvm-hs-examples/dist-newstyle/build/x86_64-linux/ghc-8.8.1/examples-1.0.0.0/x/irbuilder/build/irbuilder/irbuilder ...
Module {moduleName = "exampleModule", moduleSourceFileName = "<string>", moduleDataLayout = Nothing, moduleTargetTriple = Nothing, moduleDefinitions = [GlobalDefinition (Function {linkage = External, visibility = Default, dllStorageClass = Nothing, callingConvention = C, returnAttributes = [], returnType = IntegerType {typeBits = 32}, name = Name "f", parameters = ([Parameter (IntegerType {typeBits = 32}) (Name "a_0") []],False), functionAttributes = [], section = Nothing, comdat = Nothing, alignment = 0, garbageCollectorName = Nothing, prefix = Nothing, basicBlocks = [BasicBlock (Name "entry_0") [UnName 0 := ICmp {iPredicate = EQ, operand0 = LocalReference (IntegerType {typeBits = 32}) (Name "a_0"), operand1 = ConstantOperand (Int {integerBits = 32, integerValue = 0}), metadata = []}] (Do (CondBr {condition = LocalReference (IntegerType {typeBits = 1}) (UnName 0), trueDest = UnName 1, falseDest = Name "if.else_0", metadata' = []})),BasicBlock (UnName 1) [UnName 2 := Add {nsw = False, nuw = False, operand0 = LocalReference (IntegerType {typeBits = 32}) (Name "a_0"), operand1 = ConstantOperand (Int {integerBits = 32, integerValue = 0}), metadata = []}] (Do (Br {dest = Name "if.exit_0", metadata' = []})),BasicBlock (Name "if.else_0") [UnName 3 := Add {nsw = False, nuw = False, operand0 = LocalReference (IntegerType {typeBits = 32}) (Name "a_0"), operand1 = ConstantOperand (Int {integerBits = 32, integerValue = 0}), metadata = []}] (Do (Br {dest = Name "if.exit_0", metadata' = []})),BasicBlock (Name "if.exit_0") [UnName 4 := Phi {type' = IntegerType {typeBits = 32}, incomingValues = [(LocalReference (IntegerType {typeBits = 32}) (UnName 2),UnName 1),(LocalReference (IntegerType {typeBits = 32}) (UnName 3),Name "if.else_0")], metadata = []}] (Do (Ret {returnOperand = Just (LocalReference (IntegerType {typeBits = 32}) (UnName 4)), metadata' = []}))], personalityFunction = Nothing, metadata = []}),GlobalDefinition (Function {linkage = External, visibility = Default, dllStorageClass = Nothing, callingConvention = C, returnAttributes = [], returnType = IntegerType {typeBits = 32}, name = Name "plus", parameters = ([Parameter (IntegerType {typeBits = 32}) (Name "x_0") [],Parameter (IntegerType {typeBits = 32}) (Name "y_0") []],False), functionAttributes = [], section = Nothing, comdat = Nothing, alignment = 0, garbageCollectorName = Nothing, prefix = Nothing, basicBlocks = [BasicBlock (Name "entry2_0") [UnName 0 := Add {nsw = False, nuw = False, operand0 = LocalReference (IntegerType {typeBits = 32}) (Name "x_0"), operand1 = LocalReference (IntegerType {typeBits = 32}) (Name "y_0"), metadata = []}] (Do (Ret {returnOperand = Just (LocalReference (IntegerType {typeBits = 32}) (UnName 0)), metadata' = []}))], personalityFunction = Nothing, metadata = []})]}
Some maybe usefull extra information is that I'm using the master branch from this repo (llvm-hs-examples).
Cheers,
Daniel Herrera
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with shell.nix from the llvm-hs llvm-9 branch and reproduce the reported behavior by running the basic, orc, arith, and irbuilder examples in llvm-hs-examples. Trace why orc and arith fail under NixOS while the other examples run, and confirm that the affected examples complete successfully or that the limitation is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, nixos
- Domain
- compilers, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100