# compiling .s files

**URL:** https://discourse.cmake.org/t/compiling-s-files/2681
**Category:** Usage
**Tags:** os:windows, gen:makefiles
**Created:** [February 3, 2021, 1:54pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681 "2021-02-03T13:54:33Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![deepan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@deepan](https://discourse.cmake.org/u/deepan)
#### Post date: [February 3, 2021, 1:54pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681/1 "2021-02-03T13:54:33Z")

</div>

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  
${BOOT\_DIR}/pbl/src/crt0.s  
${BOOT\_DIR}/common/FlexCAN/_.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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 3, 2021, 2:43pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681/2 "2021-02-03T14:43:55Z")

</div>

I think you need to use flags like `-nostartupfiles`, `-nodefaultlibs`, and `-nostdlib` when doing things like this. See [this blog](https://cs107e.github.io/guides/gcc/) for more information.

---

<div class="post-metadata">

### Author: ![deepan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@deepan](https://discourse.cmake.org/u/deepan)
#### Post date: [February 3, 2021, 3:54pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681/3 "2021-02-03T15:54:51Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 3, 2021, 4:29pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681/4 "2021-02-03T16:29:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![deepan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@deepan](https://discourse.cmake.org/u/deepan)
#### Post date: [February 3, 2021, 4:56pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681/5 "2021-02-03T16:56:02Z")

</div>

project(RRU LANGUAGES C ASM)

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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 3, 2021, 5:10pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681/6 "2021-02-03T17:10:32Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![deepan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@deepan](https://discourse.cmake.org/u/deepan)
#### Post date: [February 4, 2021, 6:44am UTC](https://discourse.cmake.org/t/compiling-s-files/2681/7 "2021-02-04T06:44:56Z")

</div>

@ben.boeckel  
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.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [February 4, 2021, 12:57pm UTC](https://discourse.cmake.org/t/compiling-s-files/2681/8 "2021-02-04T12:57:05Z")

</div>

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](https://cmake.org/cmake/help/git-master/policy/CMP0119.html), which is coming in CMake 3.20.
