# How to remove -arch flag from arm-none-eabi-gcc in macos builds

**URL:** https://discourse.cmake.org/t/how-to-remove-arch-flag-from-arm-none-eabi-gcc-in-macos-builds/7339
**Category:** Code
**Created:** [January 27, 2023, 4:16pm UTC](https://discourse.cmake.org/t/how-to-remove-arch-flag-from-arm-none-eabi-gcc-in-macos-builds/7339 "2023-01-27T16:16:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Girish](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/e36b37/32.png) [@Girish](https://discourse.cmake.org/u/Girish)
#### Post date: [January 27, 2023, 4:16pm UTC](https://discourse.cmake.org/t/how-to-remove-arch-flag-from-arm-none-eabi-gcc-in-macos-builds/7339/1 "2023-01-27T16:16:04Z")

</div>

I am cross compiling using arm-none-eabi-gcc on MacOS (M1) with rosetta x86. It does not make sense to have `-arch x86_64b` compilation flag as it gives error. v12 of arm-none-eabi-gcc (latest from brew) does not support -arch flag. cmake should not add this flag for eabi.

How do you remove this flag?

I get this error:  
arm-none-eabi-gcc: error: unrecognized command-line option ‘-arch’; did you mean ‘-march=’?

(I see that pico-sdk compiles somehow remove this flag. There has to be some settable parameter. I looked but nothing obvious stood out.)

---

<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 8, 2023, 4:24pm UTC](https://discourse.cmake.org/t/how-to-remove-arch-flag-from-arm-none-eabi-gcc-in-macos-builds/7339/2 "2023-02-08T16:24:13Z")

</div>

Where the flag comes from would be of interest… Does `cmake --trace-expand` show anything doing this? Might be necessary on an initial configure.

---

<div class="post-metadata">

### Author: ![Girish](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/e36b37/32.png) [@Girish](https://discourse.cmake.org/u/Girish)
#### Post date: [February 17, 2023, 6:11pm UTC](https://discourse.cmake.org/t/how-to-remove-arch-flag-from-arm-none-eabi-gcc-in-macos-builds/7339/3 "2023-02-17T18:11:43Z")

</div>

Solved. setting set(CMAKE\_SYSTEM\_NAME Linux) and set(CMAKE\_SYSTEM\_PROCESSOR ARM) will cause cmake to not look into MacOS toolchain through -arch flag.

---

<div class="post-metadata">

### Author: ![jerryshang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jerryshang/32/3482_2.png) [@jerryshang](https://discourse.cmake.org/u/jerryshang)
#### Post date: [May 28, 2023, 3:37am UTC](https://discourse.cmake.org/t/how-to-remove-arch-flag-from-arm-none-eabi-gcc-in-macos-builds/7339/4 "2023-05-28T03:37:52Z")

</div>

On my mac, cmake still add -arch prarameter if I add the above 2 set().

---

<div class="post-metadata">

### Author: ![Tareg](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tareg/32/3720_2.png) [@Tareg](https://discourse.cmake.org/u/Tareg)
#### Post date: [August 15, 2023, 3:05pm UTC](https://discourse.cmake.org/t/how-to-remove-arch-flag-from-arm-none-eabi-gcc-in-macos-builds/7339/5 "2023-08-15T15:05:00Z")

</div>

Same problem on my M1 mac. Adding the two lines did not solve the problem.
