Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #445 from peosdev/feature/configurable-stack-size
Browse files Browse the repository at this point in the history
Feature/configurable stack size
  • Loading branch information
larryk85 committed Jul 8, 2019
2 parents e669d7e + 39ccc55 commit b5e4510
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/tools/eosio-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/tools/eosio-ld.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<string> - Root name of library to link
-lto-opt=<string> - LTO Optimization level (O0-O3)
Expand Down
8 changes: 7 additions & 1 deletion tools/include/compiler_options.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ static cl::opt<bool> fno_stack_first_opt(
"fno-stack-first",
cl::desc("Don't set the stack first in memory"),
cl::cat(LD_CAT));
static cl::opt<int> 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<bool> fno_post_pass_opt(
"fno-post-pass",
cl::desc("Don't run post processing pass"),
Expand Down Expand Up @@ -415,7 +420,6 @@ static void GetLdDefaults(std::vector<std::string>& 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");
Expand Down Expand Up @@ -720,10 +724,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");
}
Expand Down

0 comments on commit b5e4510

Please sign in to comment.