Skip to content

toolchain: xt-clang: fixes issues when building picolibc from source #90702

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 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/compiler/gcc/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ set_compiler_property(PROPERTY cstd -std=)
if (NOT CONFIG_NEWLIB_LIBC AND
NOT (CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_USE_MODULE) AND
NOT COMPILER STREQUAL "xcc" AND
NOT COMPILER STREQUAL "xt-clang" AND
NOT CONFIG_HAS_ESPRESSIF_HAL AND
NOT CONFIG_NATIVE_BUILD)
set_compiler_property(PROPERTY nostdinc -nostdinc)
Expand Down
17 changes: 16 additions & 1 deletion cmake/compiler/xcc/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,22 @@ foreach(file_name include/stddef.h include-fixed/limits.h)
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")

list(APPEND NOSTDINC ${_OUTPUT})
# Need to make sure the path exists before we add it to ${NOSTDINC}.
# For example, include-fixed is in xcc but not xt-clang.
if(EXISTS "${_OUTPUT}")
list(APPEND NOSTDINC ${_OUTPUT})

if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "xt-clang")
# This forcibly adds -isystem so that the xt-clang system
# include paths are before the xcc include paths.
# For some reason, xt-clang places xcc include paths before
# xt-clang ones so we need to force it.
#
# Some modules ignores the compiler property nostdinc_include
# so we need to make sure -isystem is used there.
add_compile_options(-isystem ${_OUTPUT})
endif()
endif()
endforeach()

# This libgcc code is partially duplicated in compiler/*/target.cmake
Expand Down
21 changes: 3 additions & 18 deletions cmake/compiler/xt-clang/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,10 @@

include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake)

# nostdinc_include contains path to llvm headers and also relative
# path of "include-fixed".
# Clear "nostdinc" and nostdinc_include
# nostdinc needs to be cleared as it is needed for xtensa/config/core.h.
# nostdinc_include contains path to llvm headers.
set_compiler_property(PROPERTY nostdinc)
set_compiler_property(PROPERTY nostdinc_include)

# For C++ code, re-add the standard includes directory which was
# cleared up from nostdinc_inlcude in above lines with no
# "include-fixed" this time"
if(CONFIG_CPP)
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=include/stddef.h
OUTPUT_VARIABLE _OUTPUT
COMMAND_ERROR_IS_FATAL ANY
)
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")
set_compiler_property(PROPERTY nostdinc_include "${_OUTPUT}")
endif()
set_compiler_property(APPEND PROPERTY nostdinc_include ${NOSTDINC})

if($ENV{XCC_NO_G_FLAG})
# Older xcc/clang cannot use "-g" due to this bug:
Expand Down
2 changes: 2 additions & 0 deletions include/zephyr/toolchain/xcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
* XCC does not support using deprecated attribute in enum,
* so just nullify it here to avoid compilation errors.
*/
#ifndef __deprecated
#define __deprecated
#endif

#define __in_section_unique(seg) \
__attribute__((section("." STRINGIFY(seg) "." STRINGIFY(__COUNTER__))))
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_app_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def parse_args():
parser.add_argument("--pinpartitions", action="store", required=False, default="",
help="Comma separated names of partitions to be pinned in physical memory")

args = parser.parse_args()
args, _ = parser.parse_known_args()


def main():
Expand Down
Loading