Skip to content

treewide: Merge all of the SDK 1.0 changes together #94368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

keith-packard
Copy link
Contributor

Let's see if merging all of the proposed updates for SDK 1.0 support build together.

nashif and others added 23 commits August 11, 2025 11:03
The picolibc changes were merged upstream; switch to using that revision.

Signed-off-by: Anas Nashif <[email protected]>
Now that rpi_pico can use picolibc, let's switch to it.

Signed-off-by: Keith Packard <[email protected]>
This version along the zephyr branch allows cmsis_6 to compile against
picolibc.

Signed-off-by: Keith Packard <[email protected]>
psa-arch-tests includes device drivers that failed to mark
registers with 'volatile'. GCC 14.3 cleverly optimized
sequential register accesses using strd/ldrd instructions which
caused the drivers to fail.

Signed-off-by: Keith Packard <[email protected]>
This patch (submitted upstream) avoids an incorrect warning generated by
gcc 14.3 about array bounds. It should not change the generated code at
all.

Signed-off-by: Keith Packard <[email protected]>
Signed-off-by: Anas Nashif <[email protected]>
Disable the default startup file with -nostartfiles.

Signed-off-by: Keith Packard <[email protected]>
When the target has only a single CPU, this function cannot ever
succeed. Skip all of the drama and just return -EINVAL. This makes GCC 14
happy as it doesn't get confused about possible out of bounds access of the
soc_cpus_active array.

Signed-off-by: Keith Packard <[email protected]>
The stm32u3x header files defines LL_ADC_SINGLE_ENDED but not
LL_ADC_DIFFERENTIAL as the device doesn't support differential mode. The
driver only checked for LL_ADC_SINGLE_ENDED and assumed that when that was
defined, LL_ADC_DIFFERENTIAL would also be defined.

Check for both when figuring out which calibration type will be required.

Signed-off-by: Keith Packard <[email protected]>
Zephyr replaces the toolchain version of stdint.h to define uint32_t and
int32_t as int rather than long. This breaks the ARM MVE intrinics which
require uint32_t to be defined as unsigned long.

Define 'ZEPHYR_USE_TOOLCHAIN_STDINT_H_' as that causes zephyr_stdint.h to
be skipped, ensuring that the normal stdint.h types are used instead.

Signed-off-by: Keith Packard <[email protected]>
The linker may want to know the desired optimization level as when
the multilib configuration includes -Os as a selector.

Adopt the same pattern as the assembler optimization flags by allowing
toolchains to specify linker optimization flags which default to the
compiler optimization flags and the apply those using add_link_options.

Signed-off-by: Keith Packard <[email protected]>
With inclusion of the optimization flag into the multilib selection
process, we cannot compute the compiler library path when the compiler's
target.cmake is processed as LINKER_OPTIMIZATION_FLAG is not computed until
much later.

Instead, add a function (compiler_file_path) which can be used to locate
the appropriate crtbegin.o and crtend.o files.

Delay computation of lib_include_dir and rt_library until after all
compiler flags have been computed by adding compiler_set_linker_properties
and calling that just before toolchain_linker_finalize is invoked.

Place default implementations of both of these functions in a new file,
cmake/compiler/target_template.cmake, where we assume the compiler works
like gcc or clang and handlers the --print-file-name and
--print-libgcc-file-name options. Compilers needing alternate
implementations can override these functions in their target.cmake files.

These implementations require that no generator expressions are necessary
for the compiler to compute the right library paths.

This mechanism is also used to take any additional compiler options by
adding a new (optional) linker function,
toolchain_linker_add_compiler_options, which maps compiler options to
equivalent linker options, discarding any that aren't applicable.

Signed-off-by: Keith Packard <[email protected]>
GCC version 14.3 does more extensive checking for potentially uninitialized
values and warns about a couple of arrays. Initialize them to zero to make
the compiler happy.

Signed-off-by: Keith Packard <[email protected]>
This patch has been accepted upstream ARM-software/CMSIS-DSP#265.
The module PR, zephyrproject-rtos/cmsis-dsp#7 is pending review.

Signed-off-by: Keith Packard <[email protected]>
GCC 14.3 will happily delete any code that appears before
__builtin_unreachable that isn't separated with an obvious branch. That
includes __asm__ statements, even those which generate traps.

The failure case that I debugged was on x86 in
z_check_stack_sentinel. There is a store to restore the sentinel to the
correct value just before the ARCH_EXCEPT, and that macro emits 'int $32'
followed by CODE_UNREACHABLE. Because the compiler didn't understand that
ARCH_EXCEPT was changing execution flow, it decided that the sentinel
restoring store 'couldn't' be reached and elided it.

I added the "memory" clobber to the asm statement in ARCH_EXCEPT before
CODE_UNREACHABLE to enforce that all pending store operations be performed
before the asm statement occurs. This ensures that they are not deleted by
the compiler.

I think this might be a GCC bug. The GCC documentation explicitly documents
that asm statements which change the flow of control should be followed by
__builtin_unreachable.

Signed-off-by: Keith Packard <[email protected]>
On arm64, GCC feels free to use floating point registers for essentially
anything unless we build with -mgeneral-regs-only. After the FPU gets used
in an interrupt handler, interrupts are disabled as there's no place to
save the registers during a nested exception. As the C library may be built
separately without this flag, we cannot use any of its functions or risk
having nested exceptions fail.

Switch printk usage to k_str_out and stick to (mostly) Zephyr internal
functions to ensure nested interrupts work correctly.

Signed-off-by: Keith Packard <[email protected]>
GCC 14 takes a look these functions which are just 'return true' and
inlines them even though they has the noinline attribute set. This happens
because the compiler computes the possible range of values from the
function call, and as that is a single value (true), it replaces the call
with that value. So it's not strictly inlining the function?

Insist a bit harder by adding a compiler_barrier to the functions which
seems to solve the issue.

Signed-off-by: Keith Packard <[email protected]>
…stems

RX consistently fails this test by a tiny amount. Loosen the tolerance to
let it work.

Signed-off-by: Keith Packard <[email protected]>
This adds linker script bits and compiler options so that
trusted-firmware-m will build with picolibc.

This has not been merged to the Zephyr trusted-firmware-m repository yet:

zephyrproject-rtos/trusted-firmware-m#134

Signed-off-by: Keith Packard <[email protected]>
Copy link

github-actions bot commented Aug 11, 2025

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants