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

Cannot run CLI #5

Open
markusmobius opened this issue Nov 8, 2022 · 2 comments
Open

Cannot run CLI #5

markusmobius opened this issue Nov 8, 2022 · 2 comments

Comments

@markusmobius
Copy link

markusmobius commented Nov 8, 2022

I am trying to run the helloworld example as suggested in the docs and keep getting the following error on Windows 11 (clang 14.0.6 - same with clang 15).

c:\github\Iril\Cli\bin\Debug\net6.0\publish>iril helloworld.c
iril: info: Parsing 1 files...
iril: info: Compiling...
iril: error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Iril.Compilation.EmitLoadFunction() in /home/runner/work/Iril/Iril/Iril/Compilation.cs:line 1891
   at Iril.Compilation.Compile() in /home/runner/work/Iril/Iril/Iril/Compilation.cs:line 279
   at Cli.Program.Main(String[] args) in /home/runner/work/Iril/Iril/Cli/Program.cs:line 147

The helloworld example compiles fine when running

clang helloworld.c

I am new to LLVM and probably do something obviously wrong - any help is much appreciated.

@memsom
Copy link

memsom commented Dec 16, 2022

I get the same, even if I compile a very simple program (literally a printf in a main function)

#include <stdio.h>     
                       
int main()             
{                      
  printf("hello \n");  
  return 0;            
}                      
D:\projects\tests\iril
λ iril --version
Krueger Systems IRIL 0.9.17.0

D:\projects\tests\iril
λ iril test.c
iril: info: Parsing 1 files...
iril: info: Compiling...
iril: error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Iril.Compilation.EmitLoadFunction() in /home/runner/work/Iril/Iril/Iril/Compilation.cs:line 1891
   at Iril.Compilation.Compile() in /home/runner/work/Iril/Iril/Iril/Compilation.cs:line 279
   at Cli.Program.Main(String[] args) in /home/runner/work/Iril/Iril/Cli/Program.cs:line 147

D:\projects\tests\iril
λ clang -S -emit-llvm test.c

D:\projects\tests\iril
λ ls
test.c  test.ll

D:\projects\tests\iril
λ iril test.ll
iril: info: Parsing 1 files...
iril: info: Compiling...
iril: error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Iril.Compilation.EmitLoadFunction() in /home/runner/work/Iril/Iril/Iril/Compilation.cs:line 1891
   at Iril.Compilation.Compile() in /home/runner/work/Iril/Iril/Iril/Compilation.cs:line 279
   at Cli.Program.Main(String[] args) in /home/runner/work/Iril/Iril/Cli/Program.cs:line 147

@memsom
Copy link

memsom commented Dec 16, 2022

Okay - update... in the latest code from the repo, this throws on this line in EmitLoadFunction:

mod.GetType (namespac + ".Globals").Methods.Add (md);

If I break that down, I get:

var type = mod.GetType (namespac + ".Globals");  // this is null
var methods = type.Methods; // crash here as type did not resolve, so `Methods` is null reference
methods.Add (md);  

If I get a chance I will see if I can work out more details, but that is why it is failing under Windows.

I don't know enough to know how this would be mapped correctly, but it does seem like there is no "test.Globals" type

image

The only other bit of info - it seems to be targeting a version of .Net 6 originally... I don;t have that installed, so I changed it to 7.0.101.... that might be the issue I guess?!

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

2 participants