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

Configuring Linux Kernel - make dry-run fails #174

Closed
PBHDK opened this issue May 19, 2021 · 8 comments
Closed

Configuring Linux Kernel - make dry-run fails #174

PBHDK opened this issue May 19, 2021 · 8 comments

Comments

@PBHDK
Copy link

PBHDK commented May 19, 2021

Hi all,

I'm currently trying to set up a Linux kernel dev environment in VS Code on my Linux VM and I have been struggling to get intelliSense running.

First, this issue in the C/C++ extension's repo brought me here. However, I have been struggling to set up makefile-tools with the linux kernel.

I generated a default configuration as per docs/repositories.md with distclean defconfig clean and then called Makefile: Configure in VS Code.

Logs tell me that the configuration succeeds with the make dry-run command is failing though because it is missing some rules. I am also getting include squiggles, telling me that header files cannot be opened.

From what I have been reading, Linux kernel should be compatible with Makefile-tools, so I was wondering what I was doing wrong?

Any suggestions? Many thanks!

@andreeis
Copy link
Contributor

andreeis commented May 19, 2021

Here are some steps to give us extra information to look at:

  • set the following in your .vscode/settings.json:
"makefile.loggingLevel": "Debug",
"C_Cpp.loggingLevel": "Debug",
"makefile.extensionLog": ".vscode/extension.log"
  • reload your project in VSCode or simply run again either of the commands "Makefile: Configure" or "Makefile: Clean configure" from the palette
  • open one C or C++ source file that exhibits the squiggles (and let us know the name of the source file and the header with the complaint)
  • run the command "C/C++: Log Diagnostics"
  • share with us the content of the "C/C++ Diagnostics" and "C/C++" output channels
  • share with us the files: .vscode/dryrun.log and .vscode/extension.log.

@PBHDK
Copy link
Author

PBHDK commented May 19, 2021

I have attached the requested files (with redacted username - it's related to uni and shouldn't be public).

After activating debug-level logging and clean rebuilding, I wasn't able to reproduce the squiggles in the header, but was only getting "language modes specified are incompatible". Probably related to this? https://github.com/microsoft/vscode-makefile-tools/issues/156

c_cpp_diag_output.log
c_cpp_output.log
dryrun.log
extensionLog.log

@andreeis
Copy link
Contributor

Thanks. I'll look into those log files shortly. Since you're saying that you don't reproduce the squiggle anymore, let me also explain that if you open a header file in VSCode without opening first a source file that is meant to include that header, the header will make the CppTools extension (the one responsible with the real IntelliSense calculations) to invoke some heuristics that pick various defaults (and which many times may result in squiggles). Currently, we track information and compute IntelliSense only for source files (c, cpp... etc) and any headers included by a translation unit will inherit its IntelliSense configuration.

Where were the original squiggles that you saw? In a header or in a c/cpp source file?

@PBHDK
Copy link
Author

PBHDK commented May 20, 2021

Ah, that's good to know, thanks! The original squiggles were in a C source file.

@andreeis
Copy link
Contributor

I looked at the files and l only noticed extract-cert.c and iomem.c, right? Was there any other with squiggles that you'd like to zoom in?
extract-cert.c looks that is included in the dryrun, I didn't spot any problems with parsing its compilation line. Let me know if I'm missing anything. Any problems with extract-cert.c now?
iomem.c I see that is not present in the dry-run. You need to figure out what target to include so that iomem.c appears with a gcc compilation line in .vscode/dryrun.log. Once it appears it will have IntelliSense. But I see that the extension knew about it from the cache, so at some point it did build it. Maybe when you used a different target or.... did you need to remove --always-make from the setting "makefile.dryrunSwitches"? If you did, then after every reload of your project you will lose IntelliSense for any source files that are seen by make as "up-to-date". Without --always-make (which sometimes needs to be removed, I know) --dry-run won't see it and the extension won't know about it.
If you removed --always-make, maybe you can fix something else in the build system so that you can add --always-make back. The usual problem I've seen is that make never ends its execution and writes into dryrun.log indefinitely when --dry-run and --always-make are together and when configuring targets are setup a particular way.

If you can't easily and safely add --always-make back, you can also produce a full clean build log of whole linux kernel and pass it to the extension via "makefile.buildLog". This will prevent make from being invoked. Make sure to refresh this full clean build log every time there is a change in how source files are compiled, to operate on last actual IntelliSense information.

Or load linux kernel in VSCode after you cleaned the whole repository (make clean distClean) so that all source files are seen by ---dry-run even without --always-make.

Let us know how any of this works.

@PBHDK
Copy link
Author

PBHDK commented May 27, 2021

Thank you so much for taking the time! I don't think it's an issue with a specific file, but rather that I'm just doing something wrong. And no, I did not remove --always-make.

For other reasons, I had to reorganise my repo, which lead to me more or less cleaning everything out. I ran make CC=clang-11 distclean defconfig clean, I passed CC=clang-11 to makefile tools in setting.json and I am able to build the kernel through makefile tools, which is great! (I need clang for what I'm doing)

However, I'm still getting language modes specified are incompatible after compilation. The c/c++ config isn't updating either (wrong C standard for example), which I am finding suspicious.

Also, I have been noticing this although .config is clearly present (after running make CC=clang-11 distclean defconfig clean):

The make dry-run command failed.
IntelliSense may work only partially or not at all.


*** Configuration file ".config" not found!


*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").


Makefile:701: include/config/auto.conf.cmd: No such file or directory
make: *** [Makefile:710: .config] Error 1
make: Failed to remake makefile 'include/config/auto.conf.cmd'.
make: Failed to remake makefile 'include/config/auto.conf'.

Do you maybe have a take on the last two points?

@andreeis
Copy link
Contributor

andreeis commented Jun 8, 2021

@PBHDK, I have seen those errors and always tried to do something that would result in a make which doesn't complain about that. I did run menuconfig or xconfig. I don't have experience about what is the right way to configure linux kernel. I only tried various things until I got a configuration that would produce compiler commands for the extension to parse (instead of useless output about not having .config and running make config commands) and then only focused on bugs that I identified as belonging to the Makefile Tools extension. I don't know what is the best way for your scenario to create the linux kernel .config file. As soon as you have that figured out, when you have a make --dry-run output that produces compilations, then if IntelliSense has any issues we can investigate what Makefile Tools does wrong.

@PBHDK
Copy link
Author

PBHDK commented Jun 15, 2021

Many thanks for getting back to me on this, @andreeis !

I now managed to get intellisensing the manual way through the c/ c++ extension. That will do for now, I guess.

Once I have more time, I'll try to get Makefile Tools running with my project again. Once I have, I'd also love to contribute something like "How to: Setting up the linux kernel project in VS Code". Again, once I have more time.

Will close this issue for. Many thanks again for your help!

@PBHDK PBHDK closed this as completed Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants