How to clean and compile only my application, and not the toolchain

Hi. I’ve had a couple frustrating debug sessions that I ultimately resolved by cleaning, then compiling. I’d like to work that into my regular process before committing any changes to avoid these issues in the future. Unfortunately, when I run the Clean Application (local) and Compile Application (local) tasks, compilation time can now take upwards of ten minutes, which isn’t going to work for me. The compiler output looks to be recompiling both my code, and the particle code. How can I prevent the clean task from cleaning the particle stuff?

Also previously tested: running make -f $PARTICLE_MAKEFILE clean-user and make -f $PARTICLE_MAKEFILE compile-user from the command line. Compile still recompiled toolchain code.

Example snippet of compiler output:

Building target: ../build/target/platform/platform-12-m/libplatform.a
Invoking: ARM GCC Archiver
mkdir -p ../build/target/platform/platform-12-m/
C:/Users/<me>/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-gcc-ar -cr ../build/target/platform/platform-12-m/libplatform.a ../build/target/platform/platform-12-m/./MCU/nRF52840/src/hw_config.o ../build/target/platform/platform-12-m/./MCU/nRF52840/src/hw_ticks.o ../build/target/platform/platform-12-m/./MCU/nRF52840/src/flash_mal.o ../build/target/platform/platform-12-m/./MCU/nRF52840/src/hw_system_flags.o

make[3]: Leaving directory '/cygdrive/c/Users/<me>/.particle/toolchains/deviceOS/5.1.0/platform'
make -C ../../../wiring_globals 
make[3]: Entering directory '/cygdrive/c/Users/<me>/.particle/toolchains/deviceOS/5.1.0/wiring_globals'
Building cpp file: src/spark_wiring_gpio.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/wiring_globals/platform-12-m/src/
C:/Users/<me>/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-gcc -DMCU_DEVICE -DnRF52840 -DNRF52840_XXAA -DPLATFORM_THREADING=1 -DPLATFORM_ID=12 -DPLATFORM_NAME=argon -DPLATFORM_GEN=3 -DUSBD_VID_PARTICLE=0x2B04 -DUSBD_PID_DFU=0xD00C -DUSBD_PID_CDC=0xC00C -fno-builtin-puts -fno-builtin-printf -Wl,--wrap=puts -Wl,--wrap=printf -g3 -gdwarf-2 -Os -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DARM_CPU_CORTEX_M4 --specs=nano.specs -DSOFTDEVICE_PRESENT=1 -DS140 -D_WIZCHIP_=W5500 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DLFS_CONFIG=lfs_config.h -DPRODUCT_ID=12 -DPRODUCT_FIRMWARE_VERSION=65535 -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -DSYSTEM_VERSION_STRING=5.1.0 -DRELEASE_BUILD -Werror -Wextra <a million includes> -MD -MP -MF ../build/target/wiring_globals/platform-12-m/src/spark_wiring_gpio.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -fmessage-length=0 -Wno-error=deprecated-declarations -Wno-error=unused-parameter -Wno-deprecated-declarations  -Wimplicit-fallthrough=2 -Wno-expansion-to-defined -Wno-cast-function-type -Wno-unused-parameter -Wno-error=type-limits -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Werror=return-type -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DUSER_FIRMWARE_IMAGE_SIZE=0x40000 -DUSER_FIRMWARE_IMAGE_LOCATION=0xB4000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=6 -DMODULE_FUNCTION=5 -DMODULE_INDEX=2 -DMODULE_DEPENDENCY=4,1,5004 -DMODULE_DEPENDENCY2=0,0,0 -D_GNU_SOURCE  -fno-exceptions -fno-rtti -fcheck-new -flto -ffat-lto-objects -DPARTICLE_COMPILE_LTO_FAT -fno-use-cxa-atexit -std=gnu++17 -c -o ../build/target/wiring_globals/platform-12-m/src/spark_wiring_gpio.o src/spark_wiring_gpio.cpp

Building cpp file: src/wiring_globals_spi.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/wiring_globals/platform-12-m/src/
C:/Users/<me>/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-gcc -DMCU_DEVICE -DnRF52840 -DNRF52840_XXAA -DPLATFORM_THREADING=1 -DPLATFORM_ID=12 -DPLATFORM_NAME=argon -DPLATFORM_GEN=3 -DUSBD_VID_PARTICLE=0x2B04 -DUSBD_PID_DFU=0xD00C -DUSBD_PID_CDC=0xC00C -fno-builtin-puts -fno-builtin-printf -Wl,--wrap=puts -Wl,--wrap=printf -g3 -gdwarf-2 -Os -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DARM_CPU_CORTEX_M4 --specs=nano.specs -DSOFTDEVICE_PRESENT=1 -DS140 -D_WIZCHIP_=W5500 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DLFS_CONFIG=lfs_config.h -DPRODUCT_ID=12 -DPRODUCT_FIRMWARE_VERSION=65535 -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -DSYSTEM_VERSION_STRING=5.1.0 -DRELEASE_BUILD -Werror -Wextra <a million includes> -MD -MP -MF ../build/target/wiring_globals/platform-12-m/src/wiring_globals_spi.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -fmessage-length=0 -Wno-error=deprecated-declarations -Wno-error=unused-parameter -Wno-deprecated-declarations  -Wimplicit-fallthrough=2 -Wno-expansion-to-defined -Wno-cast-function-type -Wno-unused-parameter -Wno-error=type-limits -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Werror=return-type -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DUSER_FIRMWARE_IMAGE_SIZE=0x40000 -DUSER_FIRMWARE_IMAGE_LOCATION=0xB4000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=6 -DMODULE_FUNCTION=5 -DMODULE_INDEX=2 -DMODULE_DEPENDENCY=4,1,5004 -DMODULE_DEPENDENCY2=0,0,0 -D_GNU_SOURCE  -fno-exceptions -fno-rtti -fcheck-new -flto -ffat-lto-objects -DPARTICLE_COMPILE_LTO_FAT -fno-use-cxa-atexit -std=gnu++17 -c -o ../build/target/wiring_globals/platform-12-m/src/wiring_globals_spi.o src/wiring_globals_spi.cpp

Hi Jason, under the main folder of your project there is a target folder.
I’d bet, or I suspect, you can clean up only your application by deleting that folder, but I cannot confirm.
Best
EDIT: and welcome to the Particle community!

Those lines are expected even with a clean only of the application.

There are components of Device OS that are linked into the user application. In particular, the global variables that are accessible to user firmware need to be compiled and linked to the application binary, not the Device OS binary.

Also the make process needs to make sure the static library that contains the stubs to be able to dynamically link with the rest of Device OS (libplatform.a) is up-to-date.