Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

When Complier property is present in c_cpp_properties.json a file name null.d is created #1206

Closed
adiazulay opened this issue Feb 20, 2021 · 8 comments · Fixed by #1208
Closed

Comments

@adiazulay
Copy link
Contributor

I ran into this testing on MacOS. @iFreilicht any idea what might be causing this?

@adiazulay adiazulay changed the title When Complier arg is present in c_cpp_properties.json a file name null.d is created When Complier property is present in c_cpp_properties.json a file name null.d is created Feb 20, 2021
@iFreilicht
Copy link

No, but I can reproduce this on Linux. What contents does the file have on your machine? On mine it reads:

null.o: /dev/null

@iFreilicht
Copy link

iFreilicht commented Feb 22, 2021

So it seems this file is generated only when the project is loaded.
If you delete it, then it won't reappear until you reload the window, no matter what you do. Even then, that's not 100% reproducible.
The only sure way to get this bug is to close the workspace and open the project again.

EDIT1:

I tried to debug this, but the file gets created during very early initialization where all breakpoints are deactivated. It happens even before the automated IntelliSense configuration rebuild that happens every time you load an Arduino project.

No idea how to debug this now without breakpoints, any pointers would be welcome :)

EDIT2:

I tested a few different setups and I can't pin this down at all. Even close+open as described above doesn't reliably trigger the bug.

Now, after testing this on a few different examples, I can't reproduce it at all.

I guess we could always check for this file and just delete it as a hot-fix, but that seems like a very bad solution.

What really baffles me is that this file looks like a very rudimentary makefile for some null.o file that requires /dev/null as a dependency. .d is commonly used as a file ending for directories, but I have no idea why any part of this extension would try to create one.

@adiazulay
Copy link
Contributor Author

null.d is the same on MacOS

The file is created even with the Arduino extension disabled, so I think this is actually a bug with IntelliSense

@iFreilicht
Copy link

Huh, that is super weird. It could also be related to the C/C++ extension and the long c_cpp_properties.json, as I've never seen this happen in any Rust or Python workspace.

@adiazulay
Copy link
Contributor Author

So I narrowed it down to specifically the -MMD complier arg that's causing the issue.

Is it strictly necessary to include all complier args in c_cpp_properties.json?

@iFreilicht
Copy link

Huh, I stumbled across that as well, should've dug deeper. We could leave out -MMD specifically. The idea of the extension was to mirror the environment of the Arduino IDE as closely as possible, but it seems people have always built fine without it. The only other ticket even mentioning this flag is #765 and even there it only appeared as something copied over from elsewhere.

Let's try it without -MMD, and if the examples build properly, we'll leave it out for good.

@adiazulay
Copy link
Contributor Author

adiazulay commented Mar 1, 2021

I just checked the documentation on -MMD creates make file dependencies, so it makes sense that it's creating a file a .d file. It looks like during the library detection part of the build Arduino does pass this argument -o /dev/null

Detecting libraries used...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard /var/folders/s2/ysnhxk596f53fn4bhktx7wth0000gn/T/arduino_build_369495/sketch/Blink.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE

I think it's fine to remove it since it seems that everything is working fine without it, we should document this in case it needs to be added back in at some point.

@adiazulay
Copy link
Contributor Author

@iFreilicht #1208 should fix this. It's a bit brute force, but it works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants