| author | |
| committer | |
| log | 64d0960244a219526fc100b17f4ecd26223df496 |
| tree | 19d7f9a766bc3d3bcf2c30c342cb4d03a907bee7 |
| parent | 15ab61b2a00b56c5b15a2d5a4efbf6b7bde7a868 |
| signature |
* `--major-image-version`
* `--minor-image-version`
* `--stack`4 files changed, 29 insertions(+), 2 deletions(-)
src/all_types.hpp+1| ... | @@ -2259,6 +2259,7 @@ struct CodeGen { | ... | @@ -2259,6 +2259,7 @@ struct CodeGen { |
| 2259 | size_t version_minor; | 2259 | size_t version_minor; |
| 2260 | size_t version_patch; | 2260 | size_t version_patch; |
| 2261 | const char *linker_script; | 2261 | const char *linker_script; |
| 2262 | size_t stack_size_override; | ||
| 2262 | 2263 | ||
| 2263 | BuildMode build_mode; | 2264 | BuildMode build_mode; |
| 2264 | OutType out_type; | 2265 | OutType out_type; |
src/codegen.cpp+1| ... | @@ -10597,6 +10597,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { | ... | @@ -10597,6 +10597,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 10597 | cache_int(ch, g->linker_allow_shlib_undefined); | 10597 | cache_int(ch, g->linker_allow_shlib_undefined); |
| 10598 | cache_bool(ch, g->linker_z_nodelete); | 10598 | cache_bool(ch, g->linker_z_nodelete); |
| 10599 | cache_bool(ch, g->linker_z_defs); | 10599 | cache_bool(ch, g->linker_z_defs); |
| 10600 | cache_usize(ch, g->stack_size_override); | ||
| 10600 | 10601 | ||
| 10601 | // gen_c_objects appends objects to g->link_objects which we want to include in the hash | 10602 | // gen_c_objects appends objects to g->link_objects which we want to include in the hash |
| 10602 | gen_c_objects(g); | 10603 | gen_c_objects(g); |
src/link.cpp+4-2| ... | @@ -1840,7 +1840,8 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -1840,7 +1840,8 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 1840 | 1840 | ||
| 1841 | if (g->out_type == OutTypeExe) { | 1841 | if (g->out_type == OutTypeExe) { |
| 1842 | lj->args.append("-z"); | 1842 | lj->args.append("-z"); |
| 1843 | lj->args.append("stack-size=16777216"); // default to 16 MiB | 1843 | size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override; |
| 1844 | lj->args.append(buf_ptr(buf_sprintf("stack-size=%" ZIG_PRI_usize, stack_size))); | ||
| 1844 | } | 1845 | } |
| 1845 | 1846 | ||
| 1846 | if (g->linker_script) { | 1847 | if (g->linker_script) { |
| ... | @@ -2479,7 +2480,8 @@ static void construct_linker_job_coff(LinkJob *lj) { | ... | @@ -2479,7 +2480,8 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 2479 | 2480 | ||
| 2480 | if (g->out_type == OutTypeExe) { | 2481 | if (g->out_type == OutTypeExe) { |
| 2481 | // TODO compile time stack upper bound detection | 2482 | // TODO compile time stack upper bound detection |
| 2482 | lj->args.append("-STACK:16777216"); | 2483 | size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override; |
| 2484 | lj->args.append(buf_ptr(buf_sprintf("-STACK:%" ZIG_PRI_usize, stack_size))); | ||
| 2483 | } | 2485 | } |
| 2484 | 2486 | ||
| 2485 | coff_append_machine_arg(g, &lj->args); | 2487 | coff_append_machine_arg(g, &lj->args); |
src/main.cpp+23| ... | @@ -453,6 +453,7 @@ static int main0(int argc, char **argv) { | ... | @@ -453,6 +453,7 @@ static int main0(int argc, char **argv) { |
| 453 | OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; | 453 | OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; |
| 454 | bool linker_z_nodelete = false; | 454 | bool linker_z_nodelete = false; |
| 455 | bool linker_z_defs = false; | 455 | bool linker_z_defs = false; |
| 456 | size_t stack_size_override = 0; | ||
| 456 | 457 | ||
| 457 | ZigList<const char *> llvm_argv = {0}; | 458 | ZigList<const char *> llvm_argv = {0}; |
| 458 | llvm_argv.append("zig (LLVM option parsing)"); | 459 | llvm_argv.append("zig (LLVM option parsing)"); |
| ... | @@ -848,6 +849,27 @@ static int main0(int argc, char **argv) { | ... | @@ -848,6 +849,27 @@ static int main0(int argc, char **argv) { |
| 848 | } else { | 849 | } else { |
| 849 | fprintf(stderr, "warning: unsupported linker arg: -z %s\n", buf_ptr(z_arg)); | 850 | fprintf(stderr, "warning: unsupported linker arg: -z %s\n", buf_ptr(z_arg)); |
| 850 | } | 851 | } |
| 852 | } else if (buf_eql_str(arg, "--major-image-version")) { | ||
| 853 | i += 1; | ||
| 854 | if (i >= linker_args.length) { | ||
| 855 | fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); | ||
| 856 | return EXIT_FAILURE; | ||
| 857 | } | ||
| 858 | ver_major = atoi(buf_ptr(linker_args.at(i))); | ||
| 859 | } else if (buf_eql_str(arg, "--minor-image-version")) { | ||
| 860 | i += 1; | ||
| 861 | if (i >= linker_args.length) { | ||
| 862 | fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); | ||
| 863 | return EXIT_FAILURE; | ||
| 864 | } | ||
| 865 | ver_minor = atoi(buf_ptr(linker_args.at(i))); | ||
| 866 | } else if (buf_eql_str(arg, "--stack")) { | ||
| 867 | i += 1; | ||
| 868 | if (i >= linker_args.length) { | ||
| 869 | fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); | ||
| 870 | return EXIT_FAILURE; | ||
| 871 | } | ||
| 872 | stack_size_override = atoi(buf_ptr(linker_args.at(i))); | ||
| 851 | } else { | 873 | } else { |
| 852 | fprintf(stderr, "warning: unsupported linker arg: %s\n", buf_ptr(arg)); | 874 | fprintf(stderr, "warning: unsupported linker arg: %s\n", buf_ptr(arg)); |
| 853 | } | 875 | } |
| ... | @@ -1573,6 +1595,7 @@ static int main0(int argc, char **argv) { | ... | @@ -1573,6 +1595,7 @@ static int main0(int argc, char **argv) { |
| 1573 | g->linker_allow_shlib_undefined = linker_allow_shlib_undefined; | 1595 | g->linker_allow_shlib_undefined = linker_allow_shlib_undefined; |
| 1574 | g->linker_z_nodelete = linker_z_nodelete; | 1596 | g->linker_z_nodelete = linker_z_nodelete; |
| 1575 | g->linker_z_defs = linker_z_defs; | 1597 | g->linker_z_defs = linker_z_defs; |
| 1598 | g->stack_size_override = stack_size_override; | ||
| 1576 | 1599 | ||
| 1577 | if (override_soname) { | 1600 | if (override_soname) { |
| 1578 | g->override_soname = buf_create_from_str(override_soname); | 1601 | g->override_soname = buf_create_from_str(override_soname); |