Skip to content

Conversation

@PerMac
Copy link
Member

@PerMac PerMac commented Nov 6, 2024

Fix the include guard mismatch. Found building with clang.

stephanosio and others added 21 commits October 24, 2024 17:12
This commit renames the existing `zephyr` toolchain variant, which is used
to select the Zephyr SDK GNU (Binutils and GCC) toolchain to `zephyr-gnu`
in preparation for introducing the Zephyr SDK LLVM toolchain variant.

After this change, the `ZEPHYR_TOOLCHAIN_VARIANT` environment variable must
be set to `zephyr-gnu` in order to select the Zephyr SDK GNU toolchain.

Signed-off-by: Stephanos Ioannidis <[email protected]>
After the renaming of the `zephyr` toolchain variant to `zephyr-gnu`, this
commit gracefully deprecates the `zephyr` toolchain variant by displaying a
warning message and handling the legacy Zephyr SDK directory layout when
`ZEPHYR_TOOLCHAIN_VARIANT=zephyr`.

This effectively allows legacy Zephyr SDK releases (<= 0.17) to be used
as-is in the current version of Zephyr.

For Zephyr SDK >= 0.18, which has the new directory layout, the
`zephyr-gnu` toolchain variant must be selected.

Revert this commit when the legacy `zephyr` toolchain variant support is
removed.

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit updates all references to the `zephyr` toolchain variant, which
has been deprecated, to `zephyr-gnu` in the CI workflows.

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit updates all references to the `zephyr` toolchain variant, which
has been deprecated, to `zephyr-gnu` in the documentation.

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit updates all references to the `zephyr` toolchain variant, which
has been deprecated, to `zephyr-gnu` in the Kconfig files and build
scripts.

Signed-off-by: Stephanos Ioannidis <[email protected]>
After the renaming of the `zephyr` toolchain variant to `zephyr-gnu`, this
commit gracefully deprecates the `zephyr` toolchain variant by treating
`zephyr` toolchain variant to be equivalent to `zephyr-gnu` toolchain
variant.

Revert this commit when the legacy `zephyr` toolchain variant support is
removed.

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit updates all deprecated `zephyr` toolchain variant references in
the board YAML files to `zephyr-gnu`.

The following command line was used to automate this:

  git grep -l toolchain -- boards/*.{yml,yaml} | \
  xargs -n 1 -t -P $(nproc) \
  yq -i '.toolchain |= map(select(. == "zephyr") = "zephyr-gnu")'

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit adds a new toolchain variant `zephyr-llvm` to be used with the
Zephyr SDK LLVM toolchain.

Signed-off-by: Stephanos Ioannidis <[email protected]>
The ARM Thumb-1 instruction set, used by ARMv6-M and ARMv8-M Baseline
cores, does not have a valid encoding for "immediate-to-register move
without affecting flags" instruction (i.e. `mov reg, imm`), and the only
valid variant of immediate-to-register move instruction for it is `movs`,
which affects the flags.

Since none of the register initialisation instructions used here are
flag-sensitive in their context, this commit changes `mov` to `movs`.

This fixes the compilation errors with Clang/LLVM, which is more picky
about the `mov` mnemonic usage and prints out an "invalid instruction"
error when `mov reg, imm` is specified in Thumb-1 mode.

Note that GNU assembler implicitly converts `mov reg, imm` to `movs reg,
imm` when assembling in Thumb-1 mode.

Signed-off-by: Stephanos Ioannidis <[email protected]>
The coprocessor number in ARM `mrc` and `mcr` instructions must be prefixed
with `p`.

GNU assembler allows specifying coprocessor number without the `p` prefix;
but, LLVM assembler is more picky about this and prints out "invalid
instruction" error otherwise.

Signed-off-by: Stephanos Ioannidis <[email protected]>
The A64 `msr` instruction always takes a 64-bit register (`xN`) value
operand.

When a value of size other than 64-bit is specified as an operand to this
instruction, Clang prints out the following warning:

  warning: value size does not match register size specified by the
  constraint and modifier [-Wasm-operand-widths]

This commit modifies the `write_sysreg()` macro to cast its value parameter
into `uint64_t` before specifying it as an operand to `msr` instruction in
order to ensure that always a 64-bit value is specified.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Select `COMPILER_RT_SUPPORTED` for `zephyr-llvm` toolchain variant since
Zephyr SDK LLVM toolchain includes pre-built compiler-rt library.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Default to aggressive size optimisation (`SIZE_OPTIMIZATIONS_AGGRESSIVE`)
for Zephyr SDK LLVM toolchain as with the generic LLVM toolchain.

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit introduces `TOOLCHAIN_HAS_GLIBCXX` CMake variable, which is
set to `y` when GNU C++ Standard Library aka. libstdc++ is available.

This helps filter libstdc++-specific Kconfig and tests in a more refined
manner.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Run libstdc++ tests only using the toolchains that have libstdc++ (i.e.
GCC-based toolchain).

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit introduces `TOOLCHAIN_HAS_LIBCXX` CMake variable, which is set
to `y` when LLVM C++ Standard Library aka. libc++ is available.

This helps filter libc++-specific Kconfig and tests in a more refined
manner.

Signed-off-by: Stephanos Ioannidis <[email protected]>
LLVM C++ Standard Library aka. libc++ may be used with Picolibc -- for
example, LLVM Embedded Toolchain for Arm ships with Picolibc and libc++
compiled for Picolibc, and so does Zephyr SDK LLVM toolchain.

Ideally, we would a flag like `TOOLCHAIN_HAS_LIBCXX_PICOLIBC` indicating
that toolchain has libc++ compiled specifically for Picolibc; but, we do
not want to overcomplicate the toolchain feature flags at this time without
proper underlying infrastructure to handle it.

Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit adds a new C++ standard library test variant that builds with
Picolibc and LLVM C++ Standard Library aka. libc++ on the supported
toolchains (e.g. LLVM Embedded Toolchain for Arm and Zephyr SDK LLVM).

Signed-off-by: Stephanos Ioannidis <[email protected]>
LLVM C++ Standard Library aka. libc++ makes use of POSIX and GNU C
extensions in its headers.

While far from ideal, there is no other option but to globally enable these
extensions for C++ source files in order to ensure that libc++ headers can
be used.

Signed-off-by: Stephanos Ioannidis <[email protected]>
When LLVM linker is used, the toolchain-provided C standard library is
always linked, even when the Zephyr minimal libc is selected, because `c`
is unconditionally specified in `link_order_library`, which causes `-lc` to
be specified in the linker flags.

This commit adds a check to ensure that `-lc` is not specified when the
Zephyr minimal libc is selected because it is a standalone C standard
library and it does not make sense to link two C standard libraries at
once.

Signed-off-by: Stephanos Ioannidis <[email protected]>
Fix the include guard mismatch. Found building with clang.

Signed-off-by: Carles Cufi <[email protected]>
@PerMac PerMac added the DNM This PR should not be merged (Do Not Merge) label Nov 6, 2024
@PerMac
Copy link
Member Author

PerMac commented Nov 6, 2024

Cherry-picks fix needed for testing

PerMac and others added 3 commits November 6, 2024 18:24
As in the topic

Signed-off-by: Maciej Perkowski <[email protected]>
Fixes returning a define from a different enum which throws an
error with clang

Signed-off-by: Jamie McCrae <[email protected]>
@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Mar 13, 2025
@github-actions github-actions bot closed this Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DNM This PR should not be merged (Do Not Merge) Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants