'In VSCODE, if I make clean, the debugger no longer works. If I remove make clean, debugger works but sometimes get bad builds due to clock skew

I am programming in C in VSCODE with a remote dev container to a Toradex Colibri iMX6 target, I guess this is also called cross-compiling...

I have often noticed that when I do F5 (start debugging) or CTRL-F5 (run without debugging) I often get old code, and have to manually remove .o files and re-build.

I sometimes get a message "clock skew detected" as well, which I suspect may be the culprit.

In the meantime, I tried to pass an argument in tasks.json to always make clean

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build_debug",
            "command": "make",
            "type": "shell",
            "args": [  "clean"   ],
            "problemMatcher": {
                "base": "$gcc"
            },
            "options": {
                "env": {
                    "CFLAGS": "-g -LINUX",
                    "CXXFLAGS": "-g"
                }
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },

Makefile

DEPS = EmeraBlockEnergyBox.h spidev.h
OBJ = EmeraBlockEnergyBox.o 

# -g3 adds debugging information 0 - lowest, 3 highest


# This pattern rule says:
# "all object file targets depend on their associated .c file counterparts + the list of dependencies
# The command is to compile with the default compiler
%.o : %.c $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS)
    @echo Finished compiling all .c and .h files
    @echo

# A rule for how to compile each file
# $(CC) means: "use the C compiler"
# -o means: 
# $@ means the target 
# $^ means the prerequisite list $(OBJ)
# $(CFLAGS): Extra flags to give to the C compiler
EmeraBlockEnergyBox: $(OBJ)
    $(CC) -o $@ $^ $(CFLAGS)
    @echo Finished linking. $(OBJ)
 
# this creates a directory -p supresses error message if the folder already exists
# then it copies the executable to the directory
# if (WORKDIR) is empty, this code has no effect and the output is in the current dir
install: EmeraBlockEnergyBox
    @echo installing...
    mkdir -p $(WORKDIR)
    cp EmeraBlockEnergyBox $(WORKDIR)/
    @echo done.
    @echo

# since clean: has no prerequisites, it will always run
# deletes object files
# deletes the binary executable file
clean:
    rm -f *.o
    rm -f EmeraBlockEnergyBox
    @echo temp files deleted
    @echo done cleaning.
    @echo

Is there a preferred way to enforce a clean make? Is there some way I can fix the clock skew problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source