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

LLVMDIBuilder missing from NuGet library #57

Closed
morganbr opened this issue Sep 27, 2017 · 17 comments
Closed

LLVMDIBuilder missing from NuGet library #57

morganbr opened this issue Sep 27, 2017 · 17 comments
Labels

Comments

@morganbr
Copy link

Calls into DIBuilder, such as LLVM.NewDIBuilder fail because they're not exposed from the build of libLLVM in the matched NuGet package. This appears to be the case in both 3.9.1 and 5.0.

@mjsabby mjsabby added the bug label Sep 27, 2017
@mjsabby
Copy link
Contributor

mjsabby commented Sep 27, 2017

Yup, they are not officially part of the bindings so we have to make a special addition which looks like in the last builds got clobbered.

I'll get to this tomorrow. I'll do it for 4.0 and 5.0.

@ice1000
Copy link
Contributor

ice1000 commented Oct 15, 2017

I'll get to this tomorrow.

Cough cough 😜

@morganbr
Copy link
Author

@mjsabby , might you have any suggestions on workarounds? We're starting to generate more complex code using LLVMSharp in https://github.com/dotnet/corert and it might be nice to start generating debug data before too much longer.

@mjsabby
Copy link
Contributor

mjsabby commented Nov 10, 2017

@morganbr sorry for the delay. Do you have a platform where you'd like this sooner? Like maybe windows?

@morganbr
Copy link
Author

@mjsabby, for CoreRT, we're currently using 3.9.1 on Windows. If 5.0 on Windows works with Emscripten, we could try that too.

@morganbr
Copy link
Author

@mjsabby, is there anything we could do to help out with this?

@ice1000
Copy link
Contributor

ice1000 commented Dec 14, 2017

😭 I want a write access, so I can update the LLVM demos

@morganbr
Copy link
Author

@mjsabby, is the change needed here to just add the functions to the .def file and then rebuild libllvm.dll? If so, I'm happy to add a bunch of functions to the .def file.

@mjsabby
Copy link
Contributor

mjsabby commented Apr 23, 2018

@morganbr a little bit more than that, but essentially yes. The problem is DIBuilder changes need to be pushed into this branch.

Also, do you still need it for LLVM 4.0?

@kaby76
Copy link

kaby76 commented Apr 23, 2018

DIBuilder was changed in the last month on the master branch of LLVM, and it's still being changed as of yesterday. Those changes came out after version 6.0 of LLVM. I don't see them being merged into the Jul '18 release 6.0.1, but probably the Sep '18 release v7.0. However, I did try out the line debug information API parts, and it works. There is now a way to create "context" for LLVMDIBuilderCreateDebugLocation, i.e., using LLVMDIBuilderCreateFunction, DIBuilderCreateSubroutineType, LLVMDIBuilderCreateLexicalBlock. There is, of course, no doc or examples on how to use that API, and so took a lot of trial and error to figure it out. I haven't tried out the variable API.

@morganbr
Copy link
Author

@mjsabby, it looks like Emscripten just released a 5.0 version, so we could probably move to that if we needed to, but we're still currently using 4.0.

@mjsabby
Copy link
Contributor

mjsabby commented May 18, 2018

@morganbr I've started in earnest with 5.0 so if you could move there I'll be done there sooner.

@morganbr
Copy link
Author

@mjsabby, I tested the 6.0.0-beta1 libllvm DIBuilder with llvmsharp 5.0.0 (Emscripten just shipped a LLVM 6 version, so I'm trying with that). The functions are there, but every function other than LLVM.NewDIBuilder hits an access violation. Is there a combination of libllvm and llvmsharp that should work?

@mjsabby
Copy link
Contributor

mjsabby commented Jul 2, 2018

@morganbr can you tell me what DIBuilder functions you need? I'll verify them as I rebuild the final nuget package.

@morganbr
Copy link
Author

morganbr commented Jul 5, 2018

@mjsabby, I don't have the complete list since I haven't been able to build the functionality, but my best guesses would be something like this tutorial. We'd really like to at least have source line mapping work, eventually followed by local variable inspection. If you'd like me to play with a pre-release version, let me know and I'll give it a shot.

Needed for all debug info:

  • NewDIBuilder
  • DIBuilderFinalize
  • DIBuilderCreateCompilerUnit
  • DIBuilderDestroy (?)

Source line mapping:

  • DIBuilderCreateFunction
  • DIBuilderCreateFile
  • DIBuilderCreateLexicalBlock
  • DIBuilderCreateBasicType
  • DIBuilderCreatePointerType
  • DIBuilderCreateStructType
  • DIBuilderCreateArrayType
  • DIBuilderCreateSubroutineType
  • SetCurrentDebugLocation
  • SetCurrentDebugLocation2

Local variables:

  • DIBuilderCreateLocalVariable
  • DIBuilderInsertDeclareAtEnd
  • DIBuilderInsertValueAtEnd

@mjsabby
Copy link
Contributor

mjsabby commented Jul 7, 2018

@morganbr Yeah these functions aren't available in the LLVM 6.0 upstream and I was trying to accommodate them myself, but that's not going well as LLVM moves way too quickly.

However, most of these are available in the latest unreleased LLVM, so I'll work on making an LLVM-7.0.0-pre1 package or something that has all these from upstream.

Is that even useful? I'm not sure how you integrate with emscripten. Do you need to use the same LLVM version as emscripten? Or as long as there are no changes to the LLVM IR, either encoded as bitcode or semantics etc. you can tolerate the changes?

@morganbr
Copy link
Author

@mjsabby, I dug further into those functions. Everything we need is in 6.0 and the changes you already merged to match the 6.0 surface area probably fix the problems we're hitting. I think if you did a release of the llvmSharp package as-is (tied to the preview 6.0 libllvm), it would work for us.

The way to think about emscripten is that it's the WebAssembly LLVM linker. It can generally tolerate versions of LLVM bitcode older than it is, but not newer ones.

@mjsabby mjsabby closed this as completed May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants