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

Newlines not working correctly on Windows when calling .Dump() or .PrintToXX() #203

Open
dylanrafael05 opened this issue Oct 30, 2022 · 0 comments

Comments

@dylanrafael05
Copy link

dylanrafael05 commented Oct 30, 2022

Hey dev team! I've been using LLVMSharp to create my own programming language for a few days now, and am still learning the ropes so it is definitely possible that I have made a mistake or have otherwise messed up but I don't think that my code could result in an error like the one I am seeing.

The gist of what's happening is that calling LLVMModuleRef.Dump() appears to only place '\n' characters when attempting to create a new line, thus creating issues when trying to view the resulting dump on a windows computer.

For instance, calling .Dump() on a program which I have generated results in this formatting (cut off for brevity):

; ModuleID = '_test'
                    source_filename = "_test"

                                             define double @double(double %0) {
                                                                               _entry:
                                                                                        %x = alloca double, align 8
                                                                                                                     store ptr %x, double %0, align 8
              %1 = load double, ptr %x, align 8
                                                 %2 = fmul double %1, 2.000000e+00
                                                                                    ret double %2
                                                                                                 }

                                                                                                  define double @square(double %0) {     
                                                                                                                                    _entr
. . . 

To fix this, I am simply using .PrintToString() instead and appending a .ReplaceLineEndings(), but a fix in the library itself would be much better to work with.

Thank you for reading this!

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

No branches or pull requests

1 participant