Hi all!
I’m trying to use a built-from-source clang
to compile some C code to bare metal ARM (a Cortex-M4). I’m using specifically this toolchain, but I think the principle should be the same. When compiling, I tried:
~/my/build/path/clang -c \
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-mfloat-abi=hard -target arm-none-eabi \
--sysroot=/usr/lib/gcc/arm-none-eabi/12.2.0 \
// some custom -D and -I definitions \
-Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 \
-MMD -MP -MF"build/main.d" Core/Src/main.c -o build/main.o
but it gives me the error:
In file included from /home/alessandro/tesi/LLVM-embedded-toolchain-for-Arm/build/llvm/lib/clang/17/include/stdint.h:52:
/usr/lib/gcc/arm-none-eabi/12.2.0/include/stdint.h:9:16: fatal error: 'stdint.h' file not found
# include_next <stdint.h>
^~~~~~~~~~
1 error generated.
So an online search on SO explained the problem: it is missing the header, and it should search on the next dir in some order. Point is, how can I specify this order? Right now, on my host system (Arch), I have:
/usr/lib/gcc
.
├── arm-none-eabi
│ └── 12.2.0
│ ├── arm
│ ├── cc1
│ ├── cc1plus
│ ├── collect2
│ ├── crtbegin.o
│ ├── crtend.o
│ ├── crtfastmath.o
│ ├── crti.o
│ ├── crtn.o
│ ├── g++-mapper-server
│ ├── include
│ ├── include-fixed
│ ├── install-tools
│ ├── libgcc.a
│ ├── libgcov.a
│ ├── liblto_plugin.so
│ ├── lto1
│ ├── lto-wrapper
│ ├── plugin
│ └── thumb
└── x86_64-pc-linux-gnu
└── 12.2.1
├── 32
├── cc1
├── cc1plus
├── collect2
├── crtbegin.o
├── crtbeginS.o
├── crtbeginT.o
├── crtend.o
├── crtendS.o
├── crtfastmath.o
├── crtprec32.o
├── crtprec64.o
├── crtprec80.o
├── f951
├── finclude
├── include
├── include-fixed
├── install-tools
├── libcaf_single.a
├── libgcc.a
├── libgcc_eh.a
├── libgcov.a
├── liblto_plugin.so
├── lto1
├── lto-wrapper
└── plugin
I suppose using the headers of my host triple (x86_64-pc-linux-gnu
) as fallback may solve the problem, since with GCC it works?
Thanks!