From 91f108eb0c29f15fa1a4ca046abcf6796164f6e9 Mon Sep 17 00:00:00 2001 From: PeosDev Date: Mon, 4 Mar 2019 18:24:29 +0200 Subject: [PATCH 1/2] Configurable stack size --- tools/include/compiler_options.hpp.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/compiler_options.hpp.in b/tools/include/compiler_options.hpp.in index 9f2650b214..975697b8d4 100644 --- a/tools/include/compiler_options.hpp.in +++ b/tools/include/compiler_options.hpp.in @@ -63,6 +63,11 @@ static cl::opt fno_stack_first_opt( "fno-stack-first", cl::desc("Don't set the stack first in memory"), cl::cat(LD_CAT)); +static cl::opt stack_size_opt( + "stack-size", + cl::desc("Specifies the maximum stack size for the contract. Defaults to ${EOSIO_STACK_SIZE} bytes."), + cl::init(${EOSIO_STACK_SIZE}), + cl::cat(LD_CAT)); static cl::opt fno_post_pass_opt( "fno-post-pass", cl::desc("Don't run post processing pass"), @@ -413,7 +418,6 @@ static void GetLdDefaults(std::vector& ldopts) { if (!fnative_opt) { ldopts.emplace_back("--gc-sections"); ldopts.emplace_back("--strip-all"); - ldopts.emplace_back("-zstack-size="+std::string("${EOSIO_STACK_SIZE}")); ldopts.emplace_back("--merge-data-segments"); if (fquery_opt || fquery_server_opt || fquery_client_opt) { ldopts.emplace_back("--export-table"); @@ -715,10 +719,12 @@ static Options CreateOptions(bool add_defaults=true) { else { ldopts.emplace_back("--lto-O3"); } + ldopts.emplace_back("-zstack-size=" + std::to_string(stack_size_opt)); #else if (fno_stack_first_opt) { ldopts.emplace_back("-fno-stack-first"); } + ldopts.emplace_back("-stack-size=" + std::to_string(stack_size_opt)); if (fno_lto_opt) { ldopts.emplace_back("-fno-lto-opt"); } From 382d9545914c4cd909c776706e6460c78ceb8f9e Mon Sep 17 00:00:00 2001 From: PeosDev Date: Tue, 12 Mar 2019 15:27:07 +0200 Subject: [PATCH 2/2] Update .md files concerning the stack-size parameter --- docs/tools/eosio-cpp.md | 1 + docs/tools/eosio-ld.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/tools/eosio-cpp.md b/docs/tools/eosio-cpp.md index 6ebab10a56..2cde5b53df 100644 --- a/docs/tools/eosio-cpp.md +++ b/docs/tools/eosio-cpp.md @@ -54,6 +54,7 @@ compiler options: -fno-lto - Disable LTO -fno-post-pass - Don't run post processing pass -fno-stack-first - Don't set the stack first in memory + -stack-size - Specifies the maximum stack size for the contract -fstack-protector - Enable stack protectors for functions potentially vulnerable to stack smashing -fstack-protector-all - Force the usage of stack protectors for all functions -fstack-protector-strong - Use a strong heuristic to apply stack protectors to functions diff --git a/docs/tools/eosio-ld.md b/docs/tools/eosio-ld.md index 41c29e2532..87f368e834 100644 --- a/docs/tools/eosio-ld.md +++ b/docs/tools/eosio-ld.md @@ -20,6 +20,7 @@ ld options: -fno-lto - Disable LTO -fno-post-pass - Don't run post processing pass -fno-stack-first - Don't set the stack first in memory + -stack-size - Specifies the maximum stack size for the contract -fuse-main - Use main as entry -l= - Root name of library to link -lto-opt= - LTO Optimization level (O0-O3)