compiling .s files

I am working on an embedded project with windriver compiler
The obj file(crt0.o) has the starting point(contains “main”) as per compiler design.
In my project, we have written our own assemlbly file(crt0.s).
now i want to compile this into crt0.o and put it for linking.
I tried the below way,
file(GLOB src_pbl ${BOOT_DIR}/pbl/src/.c
add_executable(pbl ${src_pbl})

But it is not working. the linker took the crt0.o file from the default compiler path.

am I passing the .s file correctly?

I think you need to use flags like -nostartupfiles, -nodefaultlibs, and -nostdlib when doing things like this. See this blog for more information.

But before this, i don’t see the crt0.o getting generated from crt0.s.
I can see the .o files getting generated for the .c files i passed to the target.
could you verify whether i am passing the .s file correctly?

Hmm. Do you have the ASM language enabled? You can pass it either to the top-level project() call or to an explicit enable_language() call.


I have added ASM as mentioned above. still i dont see the object file getting generated.
also by adding ASM, the target i set as a compiler flag getting deleted somehow.

Hrm. Without more of the project, I don’t know how much more I can help.

@brad.king Who has other experience with CMake and ASM code?

i have added the below line without enabling ASM

set_property(SOURCE ${BOOT_DIR}/pbl/src/crt0.s PROPERTY LANGUAGE C)

now i am able to see the object file getting generated for the .s file.

Please don’t set the LANGUAGE property of a source file to be a language different than the content of the file. The .s file is written in Assembly, not C. See policy CMP0119, which is coming in CMake 3.20.