qatlang / qat

Closer to your machine's heart. Envisioned to be a Superfast, modern systems language for efficient & maintainable code. @AldrinMathew
https://qat.dev
6 stars 0 forks source link

No output #6

Open Ivo-Balbaert opened 1 year ago

Ivo-Balbaert commented 1 year ago

When running: D:\Qat\qat_v0.6.1-alpha_windows_amd64>qat run main.qat

with main.qat:

main() [
    say "Hello, World!".
]

I see not output from say. Any idea what might go wrong here?

aldrinmathew commented 1 year ago

@Ivo-Balbaert This was a bug in the 0.6.1 version. A few versions before that, when running built executables worked, the compiler assumed only one executable to run. After that, the system was changed to support multiple executables, however, the actual step of running was commented out. This should be fixed in the next release. I will be pinging here when the next release happens.

aldrinmathew commented 1 year ago

Thanks for showing interest, pointing this out and contributing to the project. I appreciate your feedback and effort.

aldrinmathew commented 1 year ago

The issue has been fixed in the latest release 0.7.0 available for Windows and Linux

Ivo-Balbaert commented 1 year ago

D:\Qat\qat_v0.7.0_windows_amd64>qat -version

D:\Qat\qat_v0.7.0_windows_amd64>qat -v

D:\Qat\qat_v0.7.0_windows_amd64>qat run main.qat

D:\Qat\qat_v0.7.0_windows_amd64>

aldrinmathew commented 1 year ago

@Ivo-Balbaert I have found the issue. There is a function the compiler uses to search for executables. In posix systems, which command is used. In windows, SearchPath is used which is not providing the correct result in the tests I did recently. The compiler log is saying that it cannot find clang on path in the debug builds. The reason I stated previously was valid, but already resolved. So now that I think about it, this has also been a problem from the beginning, which is why the compilation is not successful now.

qat version is the command to use to see the version of the compiler. I will also include another popular command used for the same purpose in other executables, in the next release.

Ivo-Balbaert commented 1 year ago

Thanks for looking into this!

aldrinmathew commented 1 year ago

@Ivo-Balbaert The SearchPath issue has been solved by using where command in windows. But there are more problems in the Windows compiler. Compiling & linking the LLVM files with clang, causes the linker to throw the following error:

C:/msys64/mingw64/bin/ld: C:/msys64/mingw64/lib\libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main':
C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'

This is fixed by using lld by adding -fuse-ld=lld to the compilation command.

However, at this point, running the built executable causes segfaults. I looked into it. I removed say "Hello, World!". and compiled again, and there is no error whatsoever. say uses printf under the hood which is properly linked in POSIX systems, but turns out, not so much in a windows system. I updated the compiler to use __mingw_vprintf instead in windows, but no change in the result.

I will look more into this and see how I can properly link C runtime. Manually passing -Lc doesn't work either.