ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.73k stars 415 forks source link

ponyc/src/libponyrt/lang/except_try_catch.ll:9:49: error: expected '{' in function body #4536

Closed bistace closed 2 weeks ago

bistace commented 2 weeks ago

Hello,

as the OS version is too old (Centos 7.9.2009) at my workplace to install the precompiled binaries of ponyc, I tried to build it from source. Here is what I did:

git clone --recursive https://github.com/ponylang/ponyc
cd ponyc
CC=gcc CXX=g++ make libs build_flags='-j 12'
CC=gcc CXX=g++ make configure
CC=gcc CXX=g++ make build

Everything runs fine until the make build command, where I encounter this error:

[  1%] Generating ../../except_try_catch.o
/usr/bin/llc: *full_path hidden for security reasons*/ponyc/src/libponyrt/lang/except_try_catch.ll:9:49: error: expected '{' in function body
define i1 @pony_try(void (i8*)* %fun, i8* %ctx) personality i32 (...)* @ponyint_personality_v0 {
                                                ^
gmake[3]: *** [except_try_catch.o] Erreur 1

Here are the different versions of my build tools:

> gcc --version
gcc (GCC) 12.2.0 20220819
> g++ --version
g++ (GCC) 12.2.0 20220819
> cmake --version
cmake version 3.31.0

Could you please help me solve this problem?

SeanTAllen commented 2 weeks ago

Hi @bistace, are there centos docker images available where we can recreate the problem? that would help a great deal.

SeanTAllen commented 2 weeks ago

It looks like an llc from your system is being used rather than the one from the included as part of the LLVM version we are building. I'm surprised to see /usr/bin/llc as the path.

I would expect to see that the llc from build/libs/bin was being used.

Can you run llc --version and drop the output in a comment?

@chalcolith Do you have any idea how /usr/bin/llc could end up being used?

bistace commented 2 weeks ago

I will try to come up with a dockerfile (there is the centos:7.9.2009 base image on dockerhub)that you can use for testing but that will take a bit of time.

Here is the output of llc --version:

LLVM (http://llvm.org/):
  LLVM version 3.4.2
  Optimized build.
  Built Nov  1 2018 (15:06:24).
  Default target: x86_64-redhat-linux-gnu
  Host CPU: x86-64

  Registered Targets:
    aarch64  - AArch64 (ARM 64-bit target)
    arm      - ARM
    cpp      - C++ backend
    hexagon  - Hexagon
    mips     - Mips
    mips64   - Mips64 [experimental]
    mips64el - Mips64el [experimental]
    mipsel   - Mipsel
    msp430   - MSP430 [experimental]
    nvptx    - NVIDIA PTX 32-bit
    nvptx64  - NVIDIA PTX 64-bit
    ppc32    - PowerPC 32
    ppc64    - PowerPC 64
    ppc64le  - PowerPC 64 LE
    r600     - AMD GPUs HD2XXX-HD6XXX
    sparc    - Sparc
    sparcv9  - Sparc V9
    systemz  - SystemZ
    thumb    - Thumb
    x86      - 32-bit X86: Pentium-Pro and above
    x86-64   - 64-bit X86: EM64T and AMD64
    xcore    - XCore

There is indeed a llc executable in build/libs/bin, here is the output of build/libs/bin/llc --version:

LLVM (http://llvm.org/):
  LLVM version 15.0.7
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: icelake-server

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_32 - AArch64 (little endian ILP32)
    aarch64_be - AArch64 (big endian)
    arm        - ARM
    arm64      - ARM64 (little endian)
    arm64_32   - ARM64 (little endian ILP32)
    armeb      - ARM (big endian)
    riscv32    - 32-bit RISC-V
    riscv64    - 64-bit RISC-V
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64
SeanTAllen commented 2 weeks ago

Ok so the error itself is definitely from the version of llc that is being used. The file in question is an LLVM ir file and the syntax changes from time to time. Thus the error. We are at LLVM 15 as you can.

What is unclear to me is why the external version of llc is being used. I can't see a reason in the build system for that to happen. Hopefully @chalcolith has some ideas.

chalcolith commented 2 weeks ago

I think I have a fix; @bistace can you try my branch issue_4536_llc_path, please? Turns out that we weren't actually finding our custom llc correctly, and it's been working by accident all along.

chalcolith commented 2 weeks ago

If I understand the documentation for find_file correctly, I think it's that HINTS gets searched before PATH, and then PATHS gets searched. So if there was a system llc, it would pick that up first, then fall back to what was in PATHS. My PR uses HINTS so that gets searched before PATH.

bistace commented 2 weeks ago

I did a full rebuild just to be sure and yes, it works! Thanks a lot for your reactivity in solving this problem!

SeanTAllen commented 2 weeks ago

Awesome. Glad to hear @bistace. The fix will be merged to main soon. I'm going to close this now.

Thank you for reporting.

chalcolith commented 2 weeks ago

Merged.