Search code examples
gccmakefilecompilationarmstm32

What do these parameters mean in the makeifle that generated by cubemx?


I am learning and trying to write a makefile for a cortex based Holtek's chip. I intend to modify the makefile generated by cubemx for STM32 as a template, but I am not particularly familiar with GCC and make tools.

Now I'm studying this part.

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
    $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

I don't know what the parameters -Wa,-a,-ad and alms mean. I checked the GCC manual, but only found the description of -Wa:

-Wa,option

Pass option as an option to the assembler. If option contains commas, it is split into multiple options at the commas.

And I can't understand its real function from this description.

What do they mean?

Should I modify it in the makefile of Holtek chip?


Solution

  • As mentioned by Tom V, the first parameter -Wa is used to send the subsequent parameters -a,-ad,-alms to the assembler compiler (GAS).

    The arguments -a,-ad, and -alms are used to generate listing files (those .lst files you find in build output directory) during compilation.

    Listing files are useful to understand low-level details of your code after being compiled.

    You can find more details about these options (and others)here:

    https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_2.html#SEC10

    and here:

    https://www.systutorials.com/generate-a-mixed-source-and-assembly-listing-using-gcc/

    Should I modify it in the makefile of Holtek chip?

    No need to change, but you can omit these parameters if you want to compile a bit faster (not really a great difference in my setup).