Skip to content

Commit 65908e7

Browse files
committed
Adaptions for clang
1 parent 3fc3901 commit 65908e7

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.github/workflows/trice_lib_reusable.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ jobs:
128128
# and matches the typical embedded toolchain expectation.
129129
export OBJCOPY=arm-none-eabi-objcopy
130130
131-
# Tell clang where the ARM GCC toolchain is located (CI only).
132-
# On ubuntu-latest with gcc-arm-none-eabi from apt, this is /usr.
133-
export CLANG_GCC_TOOLCHAIN=/usr
134-
135131
# 1) GCC all-target builds (TRICE ON/OFF)
136132
if [ "${{ inputs.toolchain_gcc_trice_on }}" = "true" ]; then
137133
./ci_build.sh \
@@ -151,6 +147,20 @@ jobs:
151147
152148
# 2) Clang build(s) (as implemented in ci_build.sh)
153149
if [ "${{ inputs.toolchain_clang }}" = "true" ]; then
150+
151+
# Provide Newlib + GCC internal headers to clang (cross).
152+
# This is required for stdlib.h, stdint.h, etc. in bare-metal builds.
153+
NEWLIB_INC="/usr/arm-none-eabi/include"
154+
GCC_INC="$(arm-none-eabi-gcc -print-file-name=include)"
155+
156+
# Fail early with a clear error if paths are missing.
157+
test -d "${NEWLIB_INC}"
158+
test -d "${GCC_INC}"
159+
160+
# Makefile will append this to clang flags (see clang0.mak change).
161+
export CLANG_SYS_INCLUDES="-isystem ${NEWLIB_INC} -isystem ${GCC_INC}"
162+
echo "CLANG_SYS_INCLUDES=${CLANG_SYS_INCLUDES}"
163+
154164
./ci_build.sh \
155165
--toolchain=clang \
156166
--trice=on \

examples/G0B1_inst/clang0.mak

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,11 @@ CLANG_ONLY_FLAGS = #
2222
ifneq ($(strip $(CLANG_GCC_TOOLCHAIN)),)
2323
CLANG_ONLY_FLAGS += --gcc-toolchain=$(CLANG_GCC_TOOLCHAIN)
2424
endif
25+
26+
# Optional extra include dirs for clang cross builds (provided by CI/environment).
27+
# Example:
28+
# CLANG_SYS_INCLUDES="-isystem /usr/arm-none-eabi/include -isystem /usr/lib/gcc/arm-none-eabi/..."
29+
CLANG_ONLY_FLAGS += $(CLANG_SYS_INCLUDES)
30+
2531
#CLANG_CC_FLAGS += -Wa,-a,-ad,-alms=$(CLANG_BUILD)/$(notdir $(<:.c=.lst))
2632
#CLANG_ONLY_FLAGS += -Wa,--noexecstack

0 commit comments

Comments
 (0)