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

Feature/configurable stack size #445

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -413,7 +418,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 @@ -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");
}
Expand Down