lfortran icon indicating copy to clipboard operation
lfortran copied to clipboard

LFortran with LSP leaves around empty lfortran-language-server.log

Open certik opened this issue 6 months ago • 8 comments

fortran/examples(main)$ ls
asr.f90  chat_01.f90  cmdline.f90  expr2.f90  project1  project2  project3
lfortran/examples(main)$ lfortran expr2.f90
25
lfortran/examples(main)$ ls
asr.f90      cmdline.f90  expr2.out    lfortran-language-server.log  project2
chat_01.f90  expr2.f90    expr2.tmp.o  project1                      project3

The LSP log should only be emitted when LSP is used, and probably also only when a command line option is present.

certik avatar May 20 '25 03:05 certik

The LSP log should only be emitted when LSP is used

Is there a very specific flag in LFortran which indicates we want to use LSP specific options?

when a command line option is present

Is there already a command line option to indicate that?

gxyd avatar Jun 09 '25 12:06 gxyd

Right now LSP should only be used when lfortran server is used.

We can add a specific option under lfortran server to emit or not emit the log file.

TODO:

  • Figure out why is LSP code being run in the first place by default ---- no LSP should run by default
  • Remove any LSP calls, which should avoid creating the log file

Optionally we can make it configurable, but that's minor. We can keep the log file in lfortran server mode for now.

certik avatar Jun 09 '25 13:06 certik

  • Figure out why is LSP code being run in the first place by default ---- no LSP should run by default

I built LFortran in debug mode with -DWITH_LSP=no (as it currently is in our build1.sh), and on execution of program with LFortran, I don't see any generation of lfortran-language-server.log file.

It's only when I use -DWITH_LSP=yes, I see generation of lfortran-language-server.log file, which I think you are suggesting shouldn't happen either.

gxyd avatar Jun 09 '25 13:06 gxyd

So, I'm not sure why this issue blocks us from making a release of LFortran, if the log-file lfortran-language-server.log isn't created unless -DWITH_LSP=yes is explicitly specified.

gxyd avatar Jun 09 '25 13:06 gxyd

The reason this issue is a blocker is because the conda package builds LFortran with -DWITH_LSP=yes and thus it creates this log file for EVERY compilation. Which is insane and must be fixed in the next release and we must release soon.

certik avatar Jun 09 '25 13:06 certik

The reason this issue is a blocker is because the conda package builds LFortran with -DWITH_LSP=yes and thus it creates this log file for EVERY compilation. Which is insane and must be fixed in the next release and we must release soon.

Understood.

I'm trying to fix it here: https://github.com/lfortran/lfortran/pull/7658, but I don't know how to run the lfortran language server locally on my machine yet, I'll try to figure that out.

gxyd avatar Jun 10 '25 09:06 gxyd

Current status:

  • The log file is not created by default, unless the option --enable-logging is provided
  • The main issue is thus fixed

However there is still a bug that LSP code is being run in regular compilation, thus slowing everything down. No LSP code should run in default compilation. So we still need to investigate why it happens and fix it.

certik avatar Jun 14 '25 21:06 certik

LSP code is being run in regular compilation, thus slowing everything down. No LSP code should run in default compilation. So we still need to investigate why it happens and fix it.

I'm sorry, can you clarify what you mean by regular compilation? Does that mean a build of LFortran using -DWITH_LSP=yes or -DWITH_LSP=no?

gxyd avatar Jun 20 '25 13:06 gxyd