Skip to content

[ATFE] Add build controls for layered runtime payloads#877

Open
simpal01 wants to merge 5 commits into
arm:arm-softwarefrom
simpal01:variant-specific-payload-install
Open

[ATFE] Add build controls for layered runtime payloads#877
simpal01 wants to merge 5 commits into
arm:arm-softwarefrom
simpal01:variant-specific-payload-install

Conversation

@simpal01

@simpal01 simpal01 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Add CMake cache options to control which runtime payloads are built and installed for layered variants. This allows llvm-libc variants to install only the required minor-variant payload, while also making compiler-rt, llvm-libc core archives, and llvm-libc support libraries independently selectable.

These options are currently defined in CMake so the layering flow can be enabled, but they are expected to move into the variant JSON handling in a follow-up patch..

@simpal01 simpal01 requested a review from a team as a code owner June 9, 2026 15:14
@simpal01 simpal01 changed the title [ATFE] Add controls for layered runtime payloads [ATFE] Add build controls for layered runtime payloads Jun 10, 2026
Comment thread arm-software/embedded/arm-runtimes/CMakeLists.txt
set(ENABLE_LIBCXX_TESTS ${ENABLE_LIBCXX_TESTS_def} CACHE BOOL "Enable libcxx tests.")
set(ENABLE_LLVMLIBC_MINOR_VARIANT ${ENABLE_LLVMLIBC_MINOR_VARIANT_def} CACHE BOOL "Install only the llvm-libc minor variant payload for this variant.")
set(LLVMLIBC_SUBARCHIVE_NAME ${LLVMLIBC_SUBARCHIVE_NAME_def} CACHE STRING "llvm-libc subarchive to install when ENABLE_LLVMLIBC_MINOR_VARIANT is enabled.")
set(ENABLE_LLVMLIBC_CORE_LIBS ${ENABLE_LLVMLIBC_CORE_LIBS_def} CACHE BOOL "Build and install the core llvm-libc library archives.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What are the "core llvmlibc" libraries?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here, “core llvm-libc libraries” means the libraries produced by the upstream libc runtime build itself, mainly the target specific llvm-libc archives installed.

That is separate from llvmlibc-support, which is ATfE’s support layer under arm-software/embedded/llvmlibc-support. The support layer builds things like libcrt0.a, libcrt0-none.a, libcrt0-semihost.a, and libsemihost.a.

I will change the help text to avoid the vague word “core”.

set(ENABLE_LLVMLIBC_CORE_LIBS ${ENABLE_LLVMLIBC_CORE_LIBS_def} CACHE BOOL "Build and install library archives from the llvm-libc build.")

set_property(CACHE LIBRARY_BUILD_TYPE PROPERTY STRINGS ${SUPPORTED_LIBRARY_BUILD_TYPES})

set(ENABLE_CXX_LIBS ${ENABLE_CXX_LIBS_def} CACHE BOOL "Build CXX libs")
set(ENABLE_COMPILER_RT_LIBS ${ENABLE_COMPILER_RT_LIBS_def} CACHE BOOL "Build compiler-rt libraries.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The descriptions below mention "build and install", where this one is limited to "build". Does this make sense?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think ENABLE_COMPILER_RT_LIBS also enables the install step for
compiler-rt, so I agree the description should say “Build and install” for consistency.

# the files that differ from the base layer.
if(ENABLE_LLVMLIBC_MINOR_VARIANT)
if(NOT C_LIBRARY STREQUAL llvmlibc)
message(FATAL_ERROR "ENABLE_LLVMLIBC_MINOR_VARIANT is only supported with C_LIBRARY=llvmlibc.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't the CMake var to enable llvm libc LLVM_TOOLCHAIN_ENABLE_LLVMLIBC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LLVM_TOOLCHAIN_ENABLE_LLVMLIBC is the top-level option for enabling the llvm-libc runtime. This check is in the arm-runtimes subproject, where the selected libc is passed in as C_LIBRARY . arm-multilib configures it with -DC_LIBRARY=${C_LIBRARY} So C_LIBRARY=llvmlibc is the local condition we need here.

@vhscampos vhscampos Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But since this CMakeLists.txt here is internal, I wonder if the error message should mention the public facing CMake variable instead. I am not sure, just bringing this up for reflection

Comment on lines +439 to +441
add_custom_target(compiler_rt-configure)
add_custom_target(compiler_rt-build)
add_custom_target(compiler_rt-install)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the point of these custom targets?

@simpal01 simpal01 Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Those empty add_custom_target() calls are placeholders for when ENABLE_COMPILER_RT_LIBS=OFF.

When compiler-rt is disabled, those targets would not exist. But the rest of the build graph still refers to them, for example:

  • picolibc has DEPENDS compiler_rt-install
  • cxxlibs has DEPENDS compiler_rt-install
  • etc

So the empty targets keep those dependencies valid and make them no-ops when compiler-rt is disabled rather than forcing every dependency site to special-case compiler-rt.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would make more sense to only set the dependencies when they're actually needed, rather than have placeholder targets that are never intended to build anything.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with @dcandler

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +476 to +478
add_custom_target(compiler_rt_profile-configure)
add_custom_target(compiler_rt_profile-build)
add_custom_target(compiler_rt_profile-install)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are also the same placeholder pattern

# Let CMake know we're cross-compiling
-DCMAKE_SYSTEM_NAME=Generic
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
-DLLVM_LIBC_ENABLE_MINOR_VARIANT=${ENABLE_LLVMLIBC_MINOR_VARIANT}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume these CMake vars will be defined in another patch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.
ENABLE_LLVMLIBC_MINOR_VARIANT and LLVMLIBC_SUBARCHIVE_NAME are cache variables defined in this patch, with ENABLE_LLVMLIBC_MINOR_VARIANT defaulting to OFF and LLVMLIBC_SUBARCHIVE_NAME as empty.

The intent is to enable this later through the corresponding JSON files, which will come in a separate patch once we agree on the naming conventions used here. As it stands, this patch should not introduce functional changes because these new CMake controls are disabled by default.

Comment on lines +874 to +891
${common_llvmlibc_cmake_args}
-DLIBC_TARGET_TRIPLE=${target_triple}
-DLIBC_CONF_TIME_64BIT=ON
-DLIBC_CONF_ERRNO_MODE=LIBC_ERRNO_MODE_SHARED
-DLIBC_CONF_PRINTF_DISABLE_FLOAT=OFF
-DLIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320=ON
-DLIBC_CONF_PRINTF_MODULAR=ON
-DLLVM_CMAKE_DIR=${LLVM_BINARY_DIR}/lib/cmake/llvm
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-DLLVM_ENABLE_RUNTIMES=libc
-DLLVM_LIBC_ALL_HEADERS=ON
-DLLVM_LIBC_FULL_BUILD=ON
-DLIBC_TEST_COMPILE_OPTIONS_DEFAULT=${llvmlibc_test_compile_options_default}
-DLIBC_TEST_LINK_OPTIONS_DEFAULT=${llvmlibc_test_link_options_default}
-DLIBC_TEST_CMD=${test_cmd}
-DLIBC_TEST_HERMETIC_ONLY=ON
-DLLVM_EXTERNAL_LIT=${external_lit_path}
-DLLVM_LIT_ARGS=${llvmlibc_lit_args}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most of this is duplicated between the if and else branches. Is it possible to have a single ExternalProject_Add call, but decide between the required argument valuesusing the if-else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree. I’ve moved the layering-specific build/install commands into a small argument list, and now use a single shared ExternalProject_Add call for llvmlibc.

Just to clarify, there are two separate LLVM libc flows:

  1. The normal/full libc.a build, including the subarchive build.
  2. The variant builds, which only build llvmlibc-support.

llvmlibc-support is ATfE’s support layer under arm-software/embedded/llvmlibc-support. It builds artifacts such as libcrt0.a, libcrt0-none.a, libcrt0-semihost.a, and libsemihost.a.

So for this minor variant, even though we do not build libc.a, we still need the libc headers because llvm-libc-support depends on them.

Comment on lines +988 to +989
add_custom_target(llvmlibc-support-build)
add_custom_target(llvmlibc-support-install)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are also the same placeholder pattern as explained above

simpal01 added 5 commits July 1, 2026 21:28
Add CMake cache options to control which runtime payloads are built and
installed for layered variants. This allows llvm-libc variants to install
only the required minor-variant payload, while also making compiler-rt,
llvm-libc core archives, and llvm-libc support libraries independently
selectable.

These options are currently defined in CMake so the layering flow can be
enabled, but they are expected to move into the variant JSON handling in a
follow-up patch..
The CMake option passing to llvm libc should be
LLVM_LIBC_ENABLE_MINOR_VARIANT to match the existing
patterns in llvm libc.
Rename ENABLE_LLVM_LIBC_MINOR_VARIANT to ENABLE_LLVMLIBC_MINOR_VARIANT
and LLVM_LIBC_SUBARCHIVE_NAME to LLVMLIBC_SUBARCHIVE_NAME to consistent
with the naming patterns used in the ATFE.
1. Moved the Layering specific build/install commands
   into a small argument list and now use a single shared
   ExternalProject_Add call for llvmlibc
2. Changed the help text to avoid the vague word “core”.
3. ENABLE_COMPILER_RT_LIBS also enables the install step for
   compiler-rt, so the description should say “Build and install”
   for consistency.
Avoid creating placeholder runtime targets when
compiler-rt, compiler-rt-profile, or llvmlibc support
libraries are disabled. Only schedule runtime subtargets
that are actually built, and add ENABLE_COMPILER_RT_LIBS
across the variant definitions.
@simpal01 simpal01 force-pushed the variant-specific-payload-install branch from 2f06513 to d0053f0 Compare July 1, 2026 20:41
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.

4 participants