From 6f037c4fab3c5be805199ba58d951259a6492522 Mon Sep 17 00:00:00 2001 From: Michael 'ASAP' Weinrich Date: Thu, 15 Feb 2024 20:11:47 -0800 Subject: [PATCH 1/2] makefile: Replace CFLAGS -I with -iquote The -iquote tells GCC to only search that path when resolving a quoted "include" (vs ) which by convention imples a include from the projects own soruce tree. This prevents a conflict between Klippers "sched.h" and "gpio.h" and and glibc . Signed-off-by: Michael 'ASAP' Weinrich --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6d0184037d8a..735d18633272 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,9 @@ dirs-y = src cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;) -CFLAGS := -I$(OUT) -Isrc -I$(OUT)board-generic/ -std=gnu11 -O2 -MD \ - -Wall -Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \ +CFLAGS := -iquote $(OUT) -iquote src -iquote $(OUT)board-generic/ \ + -std=gnu11 -O2 -MD -Wall \ + -Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \ -ffunction-sections -fdata-sections -fno-delete-null-pointer-checks CFLAGS += -flto=auto -fwhole-program -fno-use-linker-plugin -ggdb3 From 73883668a4796f4affeb86545fb3bfb446315405 Mon Sep 17 00:00:00 2001 From: Michael 'ASAP' Weinrich Date: Thu, 15 Feb 2024 20:17:08 -0800 Subject: [PATCH 2/2] linux: Don't use absolute paths for include Not all systems (i.e. Nix) repect the standard Linux filesystem hierarchy, instead relative paths should be used and allowing GCC to rely on it's builtin search paths. Signed-off-by: Michael 'ASAP' Weinrich --- src/linux/gpio.c | 2 +- src/linux/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/linux/gpio.c b/src/linux/gpio.c index bb07f5a07a9f..c7f4c5bf66c2 100644 --- a/src/linux/gpio.c +++ b/src/linux/gpio.c @@ -10,7 +10,7 @@ #include // memset #include // ioctl #include // close -#include // GPIOHANDLE_REQUEST_OUTPUT +#include // GPIOHANDLE_REQUEST_OUTPUT #include "command.h" // shutdown #include "gpio.h" // gpio_out_write #include "internal.h" // report_errno diff --git a/src/linux/main.c b/src/linux/main.c index f9ea3f6daaa8..b260f162b800 100644 --- a/src/linux/main.c +++ b/src/linux/main.c @@ -4,7 +4,7 @@ // // This file may be distributed under the terms of the GNU GPLv3 license. -#include // sched_setscheduler sched_get_priority_max +#include // sched_setscheduler sched_get_priority_max #include // fprintf #include // memset #include // getopt