Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove -march=native, to allow cross-compilation #1715

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cceckman
Copy link

@cceckman cceckman commented Oct 8, 2024

On my (x86_64-bit Debian) machine:

$ uname -a
Linux cromwell 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux

I tried to cross-compile, overriding CXX to use a cross-compiling
toolchain.

This failed because -march=native is not a valid value when
cross-compiling from x86_64 to ARMv8.

In the lib directory:

$ CXX=aarch64-linux-gnu-g++ CC=aarch64-linux-gnu-gcc make
aarch64-linux-gnu-g++ -I../include -W -Wall -Wextra -Wno-unused-parameter -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -march=native -fno-exceptions -std=c++11 -c -o gpio.o gpio.cc
cc1plus: error: unknown value ‘native’ for ‘-march’
cc1plus: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8.6-a armv8.7-a armv8.8-a armv8-r armv9-a
make: *** [Makefile:192: gpio.o] Error 1

With this change, compilation succeeds:

$ CXX=aarch64-linux-gnu-g++ CC=aarch64-linux-gnu-gcc make

produces librgbmatrix.a and librgbmatrix.so.1 files just fine.

My machine, "cromwell":

```
$ uname -a
Linux cromwell 6.1.0-25-amd64 hzeller#1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux
```

I tried to cross-compile, overriding `CXX` to use a cross-compiling
toolchain. This failed because `-march=native` is not a valid value when
cross-compiling from x86_64 to ARMv8. In the `lib` directory:

```
$ CXX=aarch64-linux-gnu-g++ CC=aarch64-linux-gnu-gcc make
aarch64-linux-gnu-g++ -I../include -W -Wall -Wextra -Wno-unused-parameter -O3 -g -fPIC  -DDEFAULT_HARDWARE='"regular"' -march=native -fno-exceptions -std=c++11 -c -o gpio.o gpio.cc
cc1plus: error: unknown value ‘native’ for ‘-march’
cc1plus: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8.6-a armv8.7-a armv8.8-a armv8-r armv9-a
make: *** [Makefile:192: gpio.o] Error 1
```

With this change, compilation succeeds:

```
$ CXX=aarch64-linux-gnu-g++ CC=aarch64-linux-gnu-gcc make
```

produces `librgbmatrix.a` and `librgbmatrix.so.1` files just fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant