Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug Travis macOS #108

Closed
wants to merge 2 commits into from
Closed

Debug Travis macOS #108

wants to merge 2 commits into from

Conversation

maleadt
Copy link
Owner

@maleadt maleadt commented Jun 27, 2018

No description provided.

@maleadt
Copy link
Owner Author

maleadt commented Jun 27, 2018

The failing test:

@testset "loops" begin
    program = """
    def fib(x) {
        var a = 1, b = 1
        for i = 3, i < x, 1.0 {
            var c = a + b
            a = b
            b = c
        }
        b
    }

    def entry() {
        fib(10)
    }
    """

    LLVM.Context() do ctx
        m = Kaleidoscope.generate_IR(program, ctx)
        Kaleidoscope.optimize!(m)
        mktemp() do path, io
            Kaleidoscope.write_objectfile(m, path)
        end
        println(m)
        v = Kaleidoscope.run(m, "entry")
        @test v == 55.0
    end
end

Generated module looks sane:

; ModuleID = 'KaleidoscopeModule'
source_filename = "KaleidoscopeModule"
target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
define double @fib(double %x) {
entry:
  br label %loop
loop:                                             ; preds = %loop, %entry
  %i6 = phi double [ %nextvar, %loop ], [ 3.000000e+00, %entry ]
  %b3 = phi double [ %addtmp, %loop ], [ 1.000000e+00, %entry ]
  %a2 = phi double [ %b3, %loop ], [ 1.000000e+00, %entry ]
  %addtmp = fadd double %a2, %b3
  %cmptmp = fcmp olt double %i6, %x
  %nextvar = fadd double %i6, 1.000000e+00
  br i1 %cmptmp, label %loop, label %afterloop
afterloop:                                        ; preds = %loop
  ret double %addtmp
}
define double @entry() {
entry:
  %calltmp = call double @fib(double 1.000000e+01)
  ret double %calltmp
}
; Function Attrs: nounwind
declare void @llvm.stackprotector(i8*, i8**) #0
attributes #0 = { nounwind }

@maleadt
Copy link
Owner Author

maleadt commented Nov 13, 2018

Huh, can reproduce with binary releases of Julia.

@maleadt
Copy link
Owner Author

maleadt commented Nov 13, 2018

So the difference between a locally-built Julia/LLVM and the binary one is the datalayout...

  • binary Julia: e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128
  • built Julia: e-m:o-i64:64-f80:128-n8:16:32:64-S128

Not sure how that differs between different LLVM builds.

@maleadt
Copy link
Owner Author

maleadt commented Nov 13, 2018

According to https://github.com/ghc/ghc/blob/master/llvm-targets these are respectively the 32 and 64 bit macOS target...

,("i386-apple-darwin", ("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128", "yonah", ""))
,("x86_64-apple-darwin", ("e-m:o-i64:64-f80:128-n8:16:32:64-S128", "core2", ""))

@maleadt
Copy link
Owner Author

maleadt commented Nov 13, 2018

Triple is wrong.

Binary:

$ julia -e "using InteractiveUtils; versioninfo(); println(unsafe_string(ccall(:LLVMGetDefaultTargetTriple, Cstring, ())))"
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-4308U CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
Environment:
  JULIA_DEPOT_PATH = /Users/julia/tbesard/depot
  JULIA_PKG_DEVDIR = /Users/julia/tbesard/dev

i386-apple-darwin15.6.0

Built:

$ ~/Julia/julia-1.0/julia -e "using InteractiveUtils; versioninfo(); println(unsafe_string(ccall(:LLVMGetDefaultTargetTriple, Cstring, ())))"
Julia Version 1.0.3-pre.0
Commit 4f6c8c8 (2018-11-09 04:07 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin15.6.0)
  CPU: Intel(R) Core(TM) i5-4308U CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
Environment:
  JULIA_DEPOT_PATH = /Users/julia/tbesard/depot
  JULIA_PKG_DEVDIR = /Users/julia/tbesard/dev

x86_64-apple-darwin15.6.0

getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produce code for.

Well, it's not wrong. So we can't rely on the default triple being well suited for the local host.

@maleadt
Copy link
Owner Author

maleadt commented Nov 13, 2018

On the other hand: https://llvm.org/docs/tutorial/LangImpl08.html

LLVM provides sys::getDefaultTargetTriple, which returns the target triple of the current machine.

It's set by CMake (LLVM_DEFAULT_TARGET_TRIPLE) though so that can't work.

@maleadt maleadt closed this Nov 13, 2018
@maleadt maleadt deleted the tb/debug_travis branch September 17, 2019 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant