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

Compiler Backend Fatal Issues #463

Closed
Kasherpete opened this issue Nov 23, 2023 · 19 comments
Closed

Compiler Backend Fatal Issues #463

Kasherpete opened this issue Nov 23, 2023 · 19 comments
Assignees

Comments

@Kasherpete
Copy link

Hello, when attempting to compile my project, it returns a fatal issue when O1 or greater is present (Oz works fine). It is a single 800 line long C file, without any external files or dependencies, and it seems like it crashes after compilation and before linking. My repository is here, feel free to git clone it and try it out for yourself. I will paste the output here:

keagan@keagan-MS-7309:~/CEdev/examples/hello_world$ make
fatal error: error in backend: unable to legalize instruction: %918:_(s48) = G_LSHR %916:_, %919:_(s8) (in function: main)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/keagan/CEdev/bin/ez80-clang -S -mllvm -profile-guided-section-prefix=false -Wall -Wextra -O3 /home/keagan/CEdev/examples/hello_world/obj/lto.bc -o /home/keagan/CEdev/examples/hello_world/obj/lto.src
1.	Code generation
2.	Running pass 'Function Pass Manager' on module '/home/keagan/CEdev/examples/hello_world/obj/lto.bc'.
3.	Running pass 'Legalizer' on function '@main'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x23)[0x1770c83]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x176ebae]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm3sys15CleanupOnSignalEm+0xdd)[0x17701ad]
/home/keagan/CEdev/bin/ez80-clang[0x16f428a]
/home/keagan/CEdev/bin/ez80-clang[0x16f422b]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm3sys7Process4ExitEib+0x27)[0x176b027]
/home/keagan/CEdev/bin/ez80-clang[0x9baff2]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm18report_fatal_errorERKNS_5TwineEb+0x128)[0x16f7f38]
/home/keagan/CEdev/bin/ez80-clang[0x23a7fb4]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm18reportGISelFailureERNS_15MachineFunctionERKNS_16TargetPassConfigERNS_32MachineOptimizationRemarkEmitterEPKcNS_9StringRefERKNS_12MachineInstrE+0x2fd)[0x23a82dd]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm9Legalizer20runOnMachineFunctionERNS_15MachineFunctionE+0x355)[0x2350335]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0x10e)[0xd57c7e]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x39d)[0x110e6fd]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x33)[0x1114373]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x3cf)[0x110ed3f]
/home/keagan/CEdev/bin/ez80-clang(_ZN5clang17EmitBackendOutputERNS_17DiagnosticsEngineERKNS_19HeaderSearchOptionsERKNS_14CodeGenOptionsERKNS_13TargetOptionsERKNS_11LangOptionsEN4llvm9StringRefEPNSE_6ModuleENS_13BackendActionESt10unique_ptrINSE_17raw_pwrite_streamESt14default_deleteISK_EE+0x1bf4)[0x19fa3c4]
/home/keagan/CEdev/bin/ez80-clang(_ZN5clang13CodeGenAction13ExecuteActionEv+0x75e)[0x2621d6e]
/home/keagan/CEdev/bin/ez80-clang(_ZN5clang14FrontendAction7ExecuteEv+0x57)[0x2051a37]
/home/keagan/CEdev/bin/ez80-clang(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x346)[0x1fcb826]
/home/keagan/CEdev/bin/ez80-clang(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x27b)[0x20f635b]
/home/keagan/CEdev/bin/ez80-clang(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0xad8)[0x9baca8]
/home/keagan/CEdev/bin/ez80-clang[0x9b8ddb]
/home/keagan/CEdev/bin/ez80-clang[0x1e53232]
/home/keagan/CEdev/bin/ez80-clang(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xdd)[0x16f420d]
/home/keagan/CEdev/bin/ez80-clang(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x134)[0x1e52d64]
/home/keagan/CEdev/bin/ez80-clang(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x1a4)[0x1e188c4]
/home/keagan/CEdev/bin/ez80-clang(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x77)[0x1e18d57]
/home/keagan/CEdev/bin/ez80-clang(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x188)[0x1e354d8]
/home/keagan/CEdev/bin/ez80-clang(main+0x2737)[0x9b84e7]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7f0db8d7dd90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7f0db8d7de40]
/home/keagan/CEdev/bin/ez80-clang(_start+0x2e)[0x9b5ade]
ez80-clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 15.0.0 (https://github.com/jacobly0/llvm-project fcc1b7e50dd53a82c7aa1da469c572fbe23d2b54)
Target: ez80
Thread model: posix
InstalledDir: /home/keagan/CEdev/bin
ez80-clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
make: *** [/home/keagan/CEdev/meta/makefile.mk:331: obj/lto.src] Error 1

This started happening when I added a small, completely unrelated piece of code earlier today, I can point it out if needed. I tried on both latest normal release and nightly to no avail.

NOTE: Yes this is in the hello world example directory, I just started my project there and never bothered to move it.

@mateoconlechuga
Copy link
Member

Thanks! Will look into it.

@mateoconlechuga
Copy link
Member

Cannot reproduce with the latest nightly available here: https://github.com/CE-Programming/toolchain/releases/tag/nightly

@mateoconlechuga mateoconlechuga added the cantrepro Unable to reproduce. label Nov 23, 2023
@mateoconlechuga mateoconlechuga self-assigned this Nov 23, 2023
@mateoconlechuga
Copy link
Member

Can repro now - maybe tell me that you decided to revert everything in your repo or provide a git hash next time please.

@mateoconlechuga mateoconlechuga added bug compiler and removed cantrepro Unable to reproduce. labels Nov 23, 2023
@mateoconlechuga
Copy link
Member

Opened an issue for the compiler: jacobly0/llvm-project#41

@adriweb
Copy link
Member

adriweb commented Nov 23, 2023

The nightly toolchain just wasn't pulling the "correct" compiler build (due to one of the CI thing failing (the old mac build can be fixed or removed @jacobly0 :P)
I can confirm the latest compiler works fine.

@Kasherpete try downloading the latest compiler build (ez80-clang) directly from the actions: https://github.com/jacobly0/llvm-project/actions/runs/6888394104

@adriweb adriweb closed this as completed Nov 23, 2023
@mateoconlechuga
Copy link
Member

Reopening because this is a toolchain issue, not a compiler issue.

@Kasherpete
Copy link
Author

Just saw all this, thanks for the time! So is this issue resolved with the latest compiler but the toolchain is not pulling the latest compiler, if I'm reading correctly?

@Kasherpete
Copy link
Author

@Kasherpete try downloading the latest compiler build (ez80-clang) directly from the actions: https://github.com/jacobly0/llvm-project/actions/runs/6888394104

Got it, thanks! I'll drag/drop into CEdev/bin, grant exe perms and see if that works.

@Kasherpete
Copy link
Author

Hey I just wanted to say that this worked, thank you so much!

@adriweb
Copy link
Member

adriweb commented Dec 4, 2023

well it's still not quite solved CI-wise (toolchain needs to get the latest binary of the compiler, which should probably be uploaded as a nightly release anyway)

@Chandler-Kluser
Copy link

Actually I have built it from source and it is not solved

/home/chandler/CEDev/examples $ make
make -C hello_world/ 
make[1]: Entrando no diretório '/home/chandler/CEDev/examples/hello_world'

/home/chandler/CEDev/examples/hello_world/obj/lto.bc:1:2: error: expected top-level entity
        section .text,"ax",@progbits
        ^
1 error generated.
make[1]: *** [/home/chandler/CEDev/meta/makefile.mk:331: obj/lto.src] Error 1
make[1]: Saindo do diretório '/home/chandler/CEDev/examples/hello_world'

make: *** [makefile:10: hello_world/makefile] Error 2

@mateoconlechuga
Copy link
Member

mateoconlechuga commented Feb 8, 2024

@Chandler-Kluser please stop posting in non-related issues. Open a new issue, no clue why you are building from source, read the getting started guide here: https://ce-programming.github.io/toolchain/static/getting-started.html

Your issue appears to be because you are not following any directions and hacking things together.

@Chandler-Kluser
Copy link

Chandler-Kluser commented Feb 8, 2024

I am building it from source because it is the most important part of FOSS, right?

If it cannot be compiled and everyone must use a release, you should think about maintaining a public repository

@adriweb
Copy link
Member

adriweb commented Feb 8, 2024

It can obviously be compiled, as the releases are built by the CI already, for convenience and transparency, as you can see in the GitHub Actions logs. Not sure what you're complaining about 🙄.

@mateoconlechuga
Copy link
Member

mateoconlechuga commented Feb 8, 2024

@mateoconlechuga
Copy link
Member

Closing because I believe the toolchain now pulls in the correct compiler

@Chandler-Kluser
Copy link

Actually I have built it from source and it is not solved

/home/chandler/CEDev/examples $ make
make -C hello_world/ 
make[1]: Entrando no diretório '/home/chandler/CEDev/examples/hello_world'

/home/chandler/CEDev/examples/hello_world/obj/lto.bc:1:2: error: expected top-level entity
        section .text,"ax",@progbits
        ^
1 error generated.
make[1]: *** [/home/chandler/CEDev/meta/makefile.mk:331: obj/lto.src] Error 1
make[1]: Saindo do diretório '/home/chandler/CEDev/examples/hello_world'

make: *** [makefile:10: hello_world/makefile] Error 2

I am still getting the same error:

/home/chandler/toolchain/examples $ make
make -C hello_world/ 
make[1]: Entering directory '/home/chandler/SSD2/repositories/toolchain/examples/hello_world'
[lto opt] obj/lto.bc
/home/chandler/SSD2/repositories/toolchain/examples/hello_world/obj/lto.bc:1:2: error: expected top-level entity
        section .text,"ax",@progbits
        ^
1 error generated.
make[1]: *** [/home/chandler/CEDev/meta/makefile.mk:331: obj/lto.src] Error 1
make[1]: Leaving directory '/home/chandler/SSD2/repositories/toolchain/examples/hello_world'
make: *** [makefile:10: hello_world/makefile] Error 2
ls -l /home/chandler/CEDev/bin/
total 1348
-rwxr-xr-x 1 chandler chandler 866424 Feb 10  2024 cedev-config
-rwxr-xr-x 1 chandler chandler  40296 Feb 10  2024 convbin
-rwxr-xr-x 1 chandler chandler  61696 Feb 10  2024 convfont
-rwxr-xr-x 1 chandler chandler 392264 Feb 10  2024 convimg
lrwxrwxrwx 1 chandler chandler     61 Oct  8 15:30 ez80-clang -> /home/chandler/llvm-project/build/bin/clang
lrwxrwxrwx 1 chandler chandler     59 Oct  8 15:37 ez80-link -> /home/chandler/llvm-project/build/bin/llc
lrwxrwxrwx 1 chandler chandler     46 Feb  7  2024 fasmg -> /home/chandler/Documentos/fasmg/core/fasmg.x64
$ ez80-clang --version
clang version 15.0.0 (https://github.com/jacobly0/llvm-project.git 005a99ce2569373524bd881207aa4a1e98a2b238)
Target: ez80
Thread model: posix
InstalledDir: /usr/bin

@mateoconlechuga
Copy link
Member

Not a toolchain issue, something is wrong with your configuration.

@mateoconlechuga
Copy link
Member

Additionally @Chandler-Kluser, open a new issue, you have hijacked this one with unrelated thing.

@CE-Programming CE-Programming locked as off-topic and limited conversation to collaborators Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants