Skip to content

Commit d4984e5

Browse files
committed
[cpp] attach CXXFLAGS to reduce the resource consumptions
1 parent 593d794 commit d4984e5

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

bsp/k210/drivers/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if GetDepend('RT_USING_PWM'):
3838
if GetDepend('RT_USING_WDT'):
3939
src += ['drv_wdt.c']
4040

41-
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
41+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=['NNCASE_NO_EXCEPTIONS'])
4242

4343
objs = [group]
4444

components/libc/cplusplus/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ if RT_USING_CPLUSPLUS
1616
bool "Enable RT-Thread APIs C++ wrapper"
1717
default n
1818

19+
config RT_USING_CPP_EXCEPTIONS
20+
bool "Enable C++ exceptions (will increase overhead)"
21+
default n
22+
1923
endif

components/libc/cplusplus/SConscript

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ Import('rtconfig')
55
cwd = GetCurrentDir()
66
src = ['cxx_crt_init.c', 'cxx_crt.cpp']
77
CPPPATH = [cwd]
8+
CXXFLAGS = ''
89

9-
group = DefineGroup('CPP', src, depend=['RT_USING_CPLUSPLUS'], CPPPATH=CPPPATH)
10+
11+
if rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm'] and not GetDepend('RT_USING_CPP_EXCEPTIONS'):
12+
CXXFLAGS += ' -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections' # reduce resource consumptions
13+
14+
group = DefineGroup('CPP', src, depend=['RT_USING_CPLUSPLUS'], CPPPATH=CPPPATH, CXXFLAGS=CXXFLAGS)
1015

1116
list = os.listdir(cwd)
1217
for d in list:

components/libc/cplusplus/cpp11/gcc/__utils.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
#include <rtthread.h>
1919

20-
#define RT_USING_CPP_EXCEPTION
21-
2220
inline void throw_system_error(int err, const char *what_msg)
2321
{
24-
#ifdef RT_USING_CPP_EXCEPTION
22+
#ifdef RT_USING_CPP_EXCEPTIONS
2523
throw std::system_error(std::error_code(err, std::system_category()), what_msg);
2624
#else
2725
(void)err;

0 commit comments

Comments
 (0)