Skip to content
Merged
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
13 changes: 6 additions & 7 deletions cmake/compiler/arcmwdt/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,19 @@ set_compiler_property(PROPERTY warning_error_misra_sane -Werror=vla)

set_compiler_property(PROPERTY cstd -std=)

if (NOT CONFIG_NEWLIB_LIBC AND
NOT CONFIG_NATIVE_APPLICATION)
if (NOT CONFIG_ARCMWDT_LIBC)
set_compiler_property(PROPERTY nostdinc -Hno_default_include -Hnoarcexlib)
set_compiler_property(APPEND PROPERTY nostdinc_include ${NOSTDINC})
endif()

set_compiler_property(APPEND PROPERTY nostdinc_include ${NOSTDINC})

# C++ std options
set_property(TARGET compiler-cpp PROPERTY dialect_cpp98 "-std=c++98")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp11 "-std=c++11")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp14 "-std=c++14")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp17 "-std=c++17")

#no support of C++14, C++17, C++2a, C++20, C++2b
set_property(TARGET compiler-cpp PROPERTY dialect_cpp14 "")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp17 "")
#no support of C++2a, C++20, C++2b
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a "")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 "")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b "")
Expand Down Expand Up @@ -173,7 +172,7 @@ set_compiler_property(PROPERTY security_canaries -fstack-protector-all)
set_compiler_property(PROPERTY security_fortify "")

# Required C++ flags when using mwdt
set_property(TARGET compiler-cpp PROPERTY required "")
set_property(TARGET compiler-cpp PROPERTY required "-Hcplus" "-Hoff=Stackcheck_alloca")

# Compiler flag for turning off thread-safe initialization of local statics
set_property(TARGET compiler-cpp PROPERTY no_threadsafe_statics "-fno-threadsafe-statics")
Expand Down
4 changes: 4 additions & 0 deletions cmake/compiler/arcmwdt/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ set(NOSTDINC "")

list(APPEND NOSTDINC ${TOOLCHAIN_HOME}/arc/inc)

if(CONFIG_ARCMWDT_LIBC AND CONFIG_LIB_CPLUSPLUS)
list(APPEND NOSTDINC ${TOOLCHAIN_HOME}/arc/lib/src/c++/inc)
endif()

# For CMake to be able to test if a compiler flag is supported by the
# toolchain we need to give CMake the necessary flags to compile and
# link a dummy C file.
Expand Down
2 changes: 1 addition & 1 deletion cmake/linker/arcmwdt/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ endmacro()
# link C++ libraries
macro(toolchain_ld_cpp)
zephyr_link_libraries(
-Hcppmw -Hcplus
-Hcplus
)
endmacro()

Expand Down
10 changes: 10 additions & 0 deletions include/arch/arc/v2/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ SECTIONS {
__kernel_ram_end = .;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;

#ifdef __MWDT_LINKER_CMD__
/* mwdt requires _fstack, _estack which will be used in _stkchk.
* _stkchk is inserted by mwdt automatically, if _fstack, _estack is not
* set correctly, the brk_s instruction will be called
* here, we use a trick to deceive the compiler.
*/
_fstack = _image_ram_start;
_estack = .;
#endif /* __MWDT_LINKER_CMD__ */

GROUP_END(RAMABLE_REGION)

/* Located in generated directory. This file is populated by the
Expand Down
8 changes: 8 additions & 0 deletions include/toolchain/mwdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@
#endif
#endif /* _SSIZE_T_DEFINED */

#ifdef CONFIG_NEWLIB_LIBC
#error "ARC MWDT doesn't support building with CONFIG_NEWLIB_LIBC as it doesn't have newlib"
#endif /* CONFIG_NEWLIB_LIBC */

#ifdef CONFIG_NATIVE_APPLICATION
#error "ARC MWDT doesn't support building Zephyr as an native application"
#endif /* CONFIG_NATIVE_APPLICATION */


#define __no_optimization __attribute__((optnone))

Expand Down
1 change: 0 additions & 1 deletion tests/subsys/cpp/libcxx/prj.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_NEWLIB_LIBC=y
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_STD_CPP17=y
Expand Down
12 changes: 11 additions & 1 deletion tests/subsys/cpp/libcxx/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
common:
filter: TOOLCHAIN_HAS_NEWLIB == 1
integration_platforms:
- mps2_an385
tests:
cpp.libcxx.newlib:
filter: TOOLCHAIN_HAS_NEWLIB == 1
toolchain_exclude: xcc
min_flash: 54
tags: cpp
extra_configs:
- CONFIG_NEWLIB_LIBC=y
- CONFIG_NEWLIB_LIBC_NANO=n
- CONFIG_EXCEPTIONS=y
cpp.libcxx.newlib_nano:
filter: TOOLCHAIN_HAS_NEWLIB == 1
toolchain_exclude: xcc
min_flash: 54
tags: cpp
timeout: 30
extra_configs:
- CONFIG_NEWLIB_LIBC=y
- CONFIG_NEWLIB_LIBC_NANO=y
cpp.libcxx.arcmwdtlib:
toolchain_allow: arcmwdt
platform_allow: nsim_hs nsim_em
min_flash: 54
tags: cpp
extra_configs:
- CONFIG_ARCMWDT_LIBC=y