Keil Logo

ARMCLANG: Producing dependency file from an assembly file


Information in this knowledgebase article applies to:

  • ARMCLANG v6.x compiler toolchain

SYMPTOM

I'm compiling a C file with ARMCLANG compiler with compiler options as follows to produce a dependency file, which works fine

armclang (other flags...) -MP -MMD -MF filename.d -c -o file.o file.c

However, it doesn't produce a dependency file, if I compile an assembly file like this:

armclang (other flags...) -MP -MMD -MF filename.d -c -o file.o file.s

The warning I got from ARMCLANG compiler is:

armclang.exe: warning: argument unused during compilation: '-MP' [-Wunused-command-line-argument]

CAUSE

The ARMCLANG compiler treats the file extension as a hint as to what form of compilation it should perform.

The file extensions *.s and *.S are treated differently by ARMCLANG. A file with *.s (lower case) is an assembly language file and a file with *.S (upper case) is an assembly language file which should be run through the C preprocessor first.

None of the C preprocessor options, such as -Mxx, will be performed on these files, because ARMCLANG does not invoke the C preprocessor for *.s files, by default. This is why the compiler warning above is given.

RESOLUTION

To create the dependency file, choose one of the following options:

  • Pass the parameter '-x assembler-with-cpp' to ARMCLANG compiler, which forces the above behavior in spite of the filename. See below:
    armclang (other flags...) -x assembler-with-cpp -MP -MMD -MF filename.d -c -o file.o file.s
    
  • Change your file extension to *.S (upper case).

MORE INFORMATION

Last Reviewed: Friday, May 22, 2020


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.