-
Notifications
You must be signed in to change notification settings - Fork 86
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
Update to build clean on macOS 10.11 with M1 cpu #41
Conversation
Checked on the pi with Raspbian; Worked fine for me:
|
This trace doesn’t look right to me. Will investigate. |
The client probably doesn't benefit much from march=native in reality. I'd say it's generally better this way, let's merge and adjust again if this doesn't turn out to be a good idea for some reason. |
This is what compilation should look like under Raspbian. @distek, you may have forgotten to pi@raspberrypi:~/github/m8c $ make
gcc -c -o main.o main.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o serial.o serial.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o slip.o slip.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o command.o command.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o write.o write.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o render.o render.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o ini.o ini.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o config.o config.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -c -o input.o input.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
[~cat] inline_font.h inprint2.c > font.c
gcc -c -o font.o font.c -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I.
gcc -o m8c main.o serial.o slip.o command.o write.o render.o ini.o config.o input.o font.o -D_REENTRANT -I/usr/include/SDL2 -Wall -O2 -pipe -I. -lSDL2 -lserialport Results:Confirmed successful, warning-free compilation. Performance:Very sluggish, until I enabled the GL (Full KMS) driver and Glamor acceleration in
|
Update to build clean on macOS 10.11 with M1 cpu
Summary
This change
-march
flag from the compilation commandpkg-config
usage to the makefileDetails
This commit fixes one major and a few minor compilation issues on macOS 10.11 on M1 silicon.
-march Directive
The biggest issue is that gcc on M1 doesn't seem to support
-march=native
(or the-march
flag at all..)There are two ways to approach this:
-mcpu=apple-m1
in a conditional makefile-march=native
from the makefile and don't replace itThe first option may be preferable for RPi targets, since you probably want to squeeze every bit of performance out of what you have. Processor-specific compilation may improve battery performance on the M1 as well-- no testing done there.
If you want to keep processor-specific builds, a conditional compilation or multiple makefiles need to be set up to keep this aspect from breaking builds.
pkg-config Integration
pkg-config
is a tool that is aware of installed library locations and configurations and produces the appropriate compilation and linker flags for the platform.Moving to
pkg-config
should be more portable, but that definitely needs testing. Introducingpkg-config
silences a bunch of warnings on my setup, but is more specific about the SDL directory location than the previous method which required changes to header file references in several .c files.