/opt/gcc-arm/bin/arm-none-eabi-g++ ex.cc --specs=nosys.specs --specs=nano.specs -o arm.elf
/opt/gcc-riscv/bin/riscv-none-elf-g++ ex.cc --specs=nosys.specs --specs=nano.specs -o mrs.elf
../Downloads/xpack-riscv-none-elf-gcc-13.2.0-2/bin/riscv-none-elf-g++ ex.cc --specs=nosys.specs --specs=nano.specs -o xpack.elf
size *.elf
text data bss dec hex filename
47340 120 420 47880 bb08 arm.elf
320970 4500 7224 332694 51396 mrs.elf
47109 4288 724 52121 cb99 xpack.elf
可见MRS的C++库优化有问题呀。
附上原始的测试文件:
#include
#include
#include
using namespace std;
void MyFunc(int c)
{
if (c > numeric_limits< char> ::max())
{
throw invalid_argument("MyFunc argument too large.");
}
//...
}
// extern "C" void SystemInit()
// {
//
// }
int main()
{
try
{
MyFunc(256); //cause an exception to throw
}
catch (invalid_argument& e)
{
//cerr << e.what() << endl;
return -1;
}
//...
return 0;
}