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

LLVM errors since upgrading from llvm 13 to 14 #12589

Closed
biqqles opened this issue Oct 10, 2022 · 6 comments · Fixed by #13319
Closed

LLVM errors since upgrading from llvm 13 to 14 #12589

biqqles opened this issue Oct 10, 2022 · 6 comments · Fixed by #13319
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen

Comments

@biqqles
Copy link

biqqles commented Oct 10, 2022

I package crystal for Solus, and since updating to LLVM 14 we get the following errors. Previously, with LLVM 13, all compiler specs passed and the interpreter worked. Both I and the LLVM maintainer are at a loss. I don't even know for sure if crystal is at fault here but no other packages have issues since the upgrade.

The compiler to all intents and purposes works fine (at least it can bootstrap itself), only the tests and interpreter fail. From #11905 I know that LLVM 14.0 should be supported.

$ make -j8 compiler_spec CRYSTAL_CONFIG_TARGET=x86_64-linux-gnu
Using /usr/bin/llvm-config [version= 14.0.6]
CRYSTAL_CONFIG_BUILD_COMMIT="" CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal/src' SOURCE_DATE_EPOCH="1665087238" ./bin/crystal build -D strict_multi_assign --release --link-flags="-Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions -Wl,--sort-common" -Dwithout_interpreter  --exclude-warnings spec/std --exclude-warnings spec/compiler --exclude-warnings spec/primitives -o .build/compiler_spec spec/compiler_spec.cr
/snip
compiler_spec: /home/build/YPKG/root/llvm/build/llvm-project-14.0.6.src/llvm/include/llvm/IR/DataLayout.h:653: uint64_t llvm::StructLayout::getElementOffset(unsigned int) const: Assertion `Idx < NumElements && "Invalid element idx!"' failed.
make: *** [Makefile:92: compiler_spec] Aborted (core dumped)
$ crystal i
crystal: /home/build/YPKG/root/llvm/build/llvm-project-14.0.6.src/llvm/include/llvm/Support/Casting.h:269: typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = llvm::StructType, Y = llvm::Type]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Aborted (core dumped)
@biqqles biqqles added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Oct 10, 2022
@straight-shoota
Copy link
Member

Can you include the output of crystal --version, please?

I understand this is with a self-built compiler binary, linked against LLVM 14 and building the compiler specs with LLVM 14 as well. Correct? Which version of the Crystal are the compiler and the source?

@biqqles
Copy link
Author

biqqles commented Oct 10, 2022

$ crystal --version
Crystal 1.5.0 (2022-07-06)

LLVM: 14.0.6
Default target: x86_64-unknown-linux-gnu

Yes, what you said is correct. In the above errors I was building 1.6.0 with 1.5.0. The same errors arose when building 1.5.0 using the prebuilt distribution, as well as building 1.6.0 with itself.

@beta-ziliani
Copy link
Member

What's the closest target for Solus? I'm asking to try to reproduce the issue (on macOS it works well).

@straight-shoota
Copy link
Member

straight-shoota commented Oct 12, 2022

It's a Linux distribution with glibc and supports only amd64 architecture, so the target triple is x86_64-linux-gnu (as mentioned in above comment).

But I can't reproduce the error on my machine (same target) with the same LLVM version. I'm using the package from linuxbrew.
So it might be related to the particular libllvm build perhaps?

@biqqles
Copy link
Author

biqqles commented Oct 12, 2022

I will attempt to build using a prebuilt llvm.

@HertzDevil
Copy link
Contributor

HertzDevil commented Apr 14, 2023

This is the backtrace I could obtain for the interpreter failure:

(lldb) bt
* thread #1, name = 'crystal', stop reason = signal SIGABRT
  * frame #0: 0x00007ffff79f9ccc libc.so.6`___lldb_unnamed_symbol3516 + 268
    frame #1: 0x00007ffff79aaef2 libc.so.6`raise + 18
    frame #2: 0x00007ffff7995472 libc.so.6`abort + 211
    frame #3: 0x00007ffff7995395 libc.so.6`___lldb_unnamed_symbol3060 + 15
    frame #4: 0x00007ffff79a3df2 libc.so.6`__assert_fail + 66
    frame #5: 0x000055555a6d9241 crystal`decltype(Val=0x000055555dc20c70) llvm::cast<llvm::StructType, llvm::Type>(llvm::Type*) at Casting.h:579:3
    frame #6: 0x000055555c121993 crystal`llvm::StructType* llvm::unwrap<llvm::StructType>(P=0x000055555dc20c70) at Type.h:532:1
    frame #7: 0x000055555c121817 crystal`::LLVMOffsetOfElement(TD=0x000055555dc1d890, StructTy=0x000055555dc20c70, Element=0) at Target.cpp:140:39
    frame #8: 0x000055555a120832 crystal`offset_of_element at target_data.cr:28:5
    frame #9: 0x000055555a0fa1a3 crystal`offset_of at llvm_typer.cr:573:7
    frame #10: 0x00005555591bbaed crystal`offset_of at codegen.cr:109:7
    frame #11: 0x0000555559e739d4 crystal`offset_of at context.cr:323:5
    frame #12: 0x000055555a156cae crystal`compile_pointerof_ivar at compiler.cr:1537:16
...

This is due to #13317.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:codegen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants