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

Can't build Crystal in release mode (LLVM >= 3.9) #3890

Closed
ysbaddaden opened this issue Jan 13, 2017 · 10 comments · Fixed by #3904
Closed

Can't build Crystal in release mode (LLVM >= 3.9) #3890

ysbaddaden opened this issue Jan 13, 2017 · 10 comments · Fixed by #3904
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Milestone

Comments

@ysbaddaden
Copy link
Contributor

Since #3831 we can't build Crystal in release mode with LLVM >= 3.9 (unless we pass --no-debug) because some calls are still missing a !dbg location. For example:

Module validation failed: inlinable function call in a function with debug info must have a !dbg location
  %146 = call i64 @__crystal_get_exception(%"struct.LibUnwind::Exception.154"* %145)
inlinable function call in a function with debug info must have a !dbg location
  call void @__crystal_raise(%"struct.LibUnwind::Exception.154"* %204)
inlinable function call in a function with debug info must have a !dbg location
  %1 = call %"String::Builder.168"* @"*String::Builder@IO#<<<String>:String::Builder"(%"String::Builder.168"* %0, %String* bitcast ({ i32, i32, i32, [10 x i8] }* @"'git init '" to %String*))
inlinable function call in a function with debug info must have a !dbg location
  %6 = call %"String::Builder.168"* @"*String::Builder@IO#<<<String>:String::Builder"(%"String::Builder.168"* %1, %String* %5)
inlinable function call in a function with debug info must have a !dbg location
  %24 = call i1 @"*Regex#===<String>:Bool"(%Regex* %22, %String* %23, %"Regex::MatchData"** %"$~")

I'm trying to investigate, but this ain't easy to track.

@mverzilli mverzilli added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Jan 13, 2017
@mverzilli mverzilli added this to the Next milestone Jan 13, 2017
@mverzilli
Copy link

Thanks for the heads up Julien. @ggiraldez maybe you can contribute an additional pair of eyes to this? :)

@ysbaddaden
Copy link
Contributor Author

I reproduced and fixed one: missing a location on StringInterpolation.

@ysbaddaden
Copy link
Contributor Author

I found most of them. Only one left.

@soveran
Copy link

soveran commented Mar 29, 2017

@ysbaddaden I still get this problem with Crystal 0.21.1, is that normal?

@ysbaddaden
Copy link
Contributor Author

@soveran to build crystal? or do you hit this error in a project?

We still have the error pop up. Can you try the latest master? If it doesn't pass, please reduce/report the issue.

@soveran
Copy link

soveran commented Mar 29, 2017

@ysbaddaden I compiled Crystal from master without issues, then tried to compile toro.cr and got the gdb error. The workaround of passing --no-debug works.

@ysbaddaden
Copy link
Contributor Author

Can you report the issue, with a way to reproduce or (hopefully) a reduced example?

@soveran
Copy link

soveran commented Apr 10, 2017

Here's a somewhat reduced example:

require "http/server"

module Example
  abstract class Router
    def self.call(context : HTTP::Server::Context)
      context.response.content_type = "text/plain"
      context.response.print "hello world"
    end

    def self.run(*args)
      server = HTTP::Server.new(*args) do |context|
        call(context)
      end

      Signal::INT.trap do
        server.close
        exit
      end

      puts "#{name} - Listening on port #{server.port}"
      server.listen
    end
  end
end

class Demo < Example::Router
end

Demo.run(8080)

It runs fine when passed --no-debug, but fails otherwise with the following error:

Module validation failed: !dbg attachment points at wrong subprogram for function
!4 = distinct !DISubprogram(name: "run", linkageName: "run", scope: !5, file: !5, line: 10, type: !6, isLocal: true, isDefinition: true, scopeLine: 10, isOptimized: false, unit: !0, variables: !2)
void (i32)* @"*Demo@Example::Router::run<Int32>:Nil"
  %1 = alloca %"->", !dbg !10
!10 = !DILocation(line: 8, column: 7, scope: !11)
!11 = distinct !DISubprogram(name: "call", linkageName: "call", scope: !5, file: !5, line: 5, type: !6, isLocal: true, isDefinition: true, scopeLine: 5, isOptimized: false, unit: !0, variables: !2)
!11 = distinct !DISubprogram(name: "call", linkageName: "call", scope: !5, file: !5, line: 5, type: !6, isLocal: true, isDefinition: true, scopeLine: 5, isOptimized: false, unit: !0, variables: !2)

0x102c8bc13: *raise<String>:NoReturn at ??
0x103c5cc6b: *Crystal::CodeGenVisitor#finish:Nil at ??
0x103b8853e: *Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil) at ??
0x10442e1b4: *Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result at ??
0x1044d5219: *Crystal::Command#run_command<Bool>:Nil at ??
0x102ceb229: *Crystal::Command#run:(Bool | Crystal::Compiler::Result | IO::FileDescriptor | Nil) at ??
0x102cb599d: main at ??

Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

@asterite
Copy link
Member

@soveran That error trace is familiar, I fixed it a couple of days ago here . I tried it with a compiled compiler from master and now it works fine :-)

@soveran
Copy link

soveran commented Apr 10, 2017

@asterite Excellent, it works with master :-) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants