Skip to content

Conversation

@DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Jul 31, 2025

This does a few things:

  • LLVM_CONFIG_PATH is deprecated, use LLVM_CMAKE_DIR instead.
  • Don't use $ before command examples. I would normally, but the key cmake commands didn't use it so I removed it from all commands.
  • Makes the commands shown full commands, so you don't have to piece them together.
  • Uses shell variables to cut down on repetition and make this easier to port to other targets.
  • Adds a few options to disable more compiler-rt things.
  • Use the built in cmake options for sysroot and toolchains.
  • Include test options in the first cmake command, so you don't have to re-do the whole thing after you read the testing section.
  • Removes the section about using BaremetalARM.cmake.

The closest I got to getting that cache to work was:

SYSROOT=/home/david.spickett/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/arm-none-eabi/libc
LLVM_TOOLCHAIN=/home/david.spickett/LLVM-20.1.8-Linux-X64/

cmake \
  -G Ninja \
  -DCMAKE_C_COMPILER=${LLVM_TOOLCHAIN}/bin/clang \
  -DBAREMETAL_ARMV6M_SYSROOT=${SYSROOT} \
  -DBAREMETAL_ARMV7M_SYSROOT=${SYSROOT} \
  -DBAREMETAL_ARMV7EM_SYSROOT=${SYSROOT} \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
  -C ../llvm-project/clang/cmake/caches/BaremetalARM.cmake \
  -DCOMPILER_RT_BUILD_BUILTINS=ON \
  -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
  -DCOMPILER_RT_BUILD_MEMPROF=OFF \
  -DCOMPILER_RT_BUILD_PROFILE=OFF \
  -DCOMPILER_RT_BUILD_CTX_PROFILE=OFF \
  -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
  -DCOMPILER_RT_BUILD_XRAY=OFF \
  -DCOMPILER_RT_BUILD_ORC=OFF \
  -DCOMPILER_RT_BUILD_CRT=OFF \
  ../llvm-project/runtimes

All this does is build the x86 builtins. I tried forcing the issue with:

  -DBUILTIN_SUPPORTED_ARCH="armv7m;armv6m;armv7em" \

But again, just x86.

It's probably something deep in compiler-rt failing a compiler check for the Arm targets. Even if that's the case, fixing that means adding more options to the cmake command.

I can't find evidence of a full command using this cache file since the commit that introduced it and that command no longer works.

I think if you ever got this to work again the command would be as long and complex as the ones already shown in the document.

I would also argue that some of the other caches, for example Fuschia's, are much better example of multi-target runtimes builds. If what's in this document isn't enough, folks should be learning from those files and about the runtimes build overall before attempting anything complex (though it does not take much to be "complex").

This does a few things:
* LLVM_CONFIG_PATH is deprecated, use LLVM_CMAKE_DIR instead.
* Don't use $ before command examples. I would normally, but the
  key cmake commands didn't use it so I removed it from all commands.
* Makes the commands shown full commands, so you don't have to piece
  them together.
* Uses shell variables to cut down on repetition and make this
  easier to port to other targets.
* Adds a few options to disable more compiler-rt things.
* Include test options in the first cmake command, so you don't
  have to re-do the whole thing after you read the testing section.
* Removes the section about using BaremetalARM.cmake.

The closest I got to getting that cache to work was:
```
SYSROOT=/home/david.spickett/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/arm-none-eabi/libc
LLVM_TOOLCHAIN=/home/david.spickett/LLVM-20.1.8-Linux-X64/

cmake \
  -G Ninja \
  -DCMAKE_C_COMPILER=${LLVM_TOOLCHAIN}/bin/clang \
  -DBAREMETAL_ARMV6M_SYSROOT=${SYSROOT} \
  -DBAREMETAL_ARMV7M_SYSROOT=${SYSROOT} \
  -DBAREMETAL_ARMV7EM_SYSROOT=${SYSROOT} \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
  -C ../llvm-project/clang/cmake/caches/BaremetalARM.cmake \
  -DCOMPILER_RT_BUILD_BUILTINS=ON \
  -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
  -DCOMPILER_RT_BUILD_MEMPROF=OFF \
  -DCOMPILER_RT_BUILD_PROFILE=OFF \
  -DCOMPILER_RT_BUILD_CTX_PROFILE=OFF \
  -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
  -DCOMPILER_RT_BUILD_XRAY=OFF \
  -DCOMPILER_RT_BUILD_ORC=OFF \
  -DCOMPILER_RT_BUILD_CRT=OFF \
  ../llvm-project/runtimes
```
All this does is build the x86 builtins. I tried forcing the issue with:
```
  -DBUILTIN_SUPPORTED_ARCH="armv7m;armv6m;armv7em" \
```
But again, just x86.

It's probably something deep in compiler-rt failing a compiler check
for the Arm targets. Even if that's the case, fixing that means adding
more options to the cmake command.

I can't find evidence of a full command using this cache file since
the commit that introduced it and that command no longer works.

I think if you ever got this to work again the command would be as
long and complex as the ones already shown in the document.

I would also argue that some of the other caches, for example Fuschia's,
are much better example of multi-target runtimes builds. If what's
in this document isn't enough, folks should be learning from those
files and about the runtimes build overall before attempting anything
complex (though it does not take much to be "complex").
@DavidSpickett
Copy link
Collaborator Author

DavidSpickett commented Jul 31, 2025

I looked at whether it should use the runtimes build and maybe it will eventually but it's easier to not have to explain any of that here. It's still valid, as far as I know, to configure using compiler-rt/.

@DavidSpickett
Copy link
Collaborator Author

ping!

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DavidSpickett DavidSpickett merged commit dc41571 into llvm:main Aug 13, 2025
10 checks passed
@DavidSpickett DavidSpickett deleted the arm-builtins-2 branch August 13, 2025 08:47
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.

2 participants