codon icon indicating copy to clipboard operation
codon copied to clipboard

llvm example fib.ll not working on ubuntu

Open johncblacker opened this issue 2 years ago • 6 comments

I installed the llvm-runtime on my wsl2 liinux machine and tried the fib example -> fib.ll; however, it failed to run with the following output: fib.ll:6:41: warning: ptr type is only supported in -opaque-pointers mode @._stdout = private unnamed_addr global ptr null ^ lli: lli: fib.ll:6:41: error: expected type @._stdout = private unnamed_addr global ptr null

Is there something I'm doing wrong? Admittedly, I haven't read the docs, just tried the example as shown in the README. ^

johncblacker avatar Jul 18 '23 11:07 johncblacker

Hi @johncblacker, Codon uses LLVM 15 which has opaque pointers enabled by default. I'm guessing you're probably using an older LLVM version that's still using typed pointers.

arshajii avatar Jul 18 '23 12:07 arshajii

I built llvm from the exaloop repository...shouldn't that work?

johncblacker avatar Jul 18 '23 19:07 johncblacker

OK, let's take a step back, if you don't mind? I built llvm from the exaloop repository. So, then I perform these steps: 1.) llc fib.ll # supposed to compile the ll to fib.s 2.) as fib.s # assemble/link to a.out? 3.) chmod +x a.out 4.) ./a.out # errors cannot execute binary file.

If I do this: 5.) ld -o fib a.out 6.) I get these errors: ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000 ld: a.out: in function main': fib.py:(.text+0xe): undefined reference to seq_init' ld: fib.py:(.text+0x13): undefined reference to seq_stdout' ld: fib.py:(.text+0x4a): undefined reference to seq_str_int' ld: fib.py:(.text+0x58): undefined reference to seq_print_full' ld: fib.py:(.text+0x6a): undefined reference to seq_print_full' ld: fib.py:(.text+0x95): undefined reference to seq_print_full' ld: a.out:(.eh_frame+0x13): undefined reference to seq_personality'

Clearly I'm out of my league here and am not understanding how to take the fib.ll file and turn it into an executable on ubuntu... Can you help?

johncblacker avatar Jul 18 '23 19:07 johncblacker

I'm using the one from the exaloop repository.

⁣Get BlueMail for Android ​

On Jul 18, 2023, 8:50 AM, at 8:50 AM, "A. R. Shajii" @.***> wrote:

Hi @johncblacker, Codon uses LLVM 15 which has opaque pointers enabled by default. I'm guessing you're probably using an older LLVM version that's still using typed pointers.

-- Reply to this email directly or view it on GitHub: https://github.com/exaloop/codon/issues/425#issuecomment-1640154425 You are receiving this because you were mentioned.

Message ID: @.***>

johncblacker avatar Jul 19 '23 11:07 johncblacker

Did you build the tools as well (DLLVM_BUILD_TOOLS=ON)? By default it is OFF.

If which llc points to a directory that is not part of our LLVM, you will also need to set PATH or manually point to proper llc (e.g., /path/to/exaloop/llvm/bin/llc ...).

inumanag avatar Jul 26 '23 13:07 inumanag

I have the same question.

Elfsong avatar Jun 30 '24 14:06 Elfsong