LCOV - code coverage report
Current view: top level - src - jloptions.c (source / functions) Hit Total Coverage
Test: [build process] commit ef510b1f346f4c9f9d86eaceace5ca54961a1dbc Lines: 106 423 25.1 %
Date: 2022-07-17 01:01:28 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 43 298 14.4 %

           Branch data     Line data    Source code
       1                 :            : // This file is a part of Julia. License is MIT: https://julialang.org/license
       2                 :            : 
       3                 :            : #include <limits.h>
       4                 :            : #include <errno.h>
       5                 :            : 
       6                 :            : #include "julia.h"
       7                 :            : #include "julia_internal.h"
       8                 :            : 
       9                 :            : #include <unistd.h>
      10                 :            : #include <getopt.h>
      11                 :            : #include "julia_assert.h"
      12                 :            : 
      13                 :            : #ifdef _OS_WINDOWS_
      14                 :            : char *shlib_ext = ".dll";
      15                 :            : #elif defined(_OS_DARWIN_)
      16                 :            : char *shlib_ext = ".dylib";
      17                 :            : #else
      18                 :            : char *shlib_ext = ".so";
      19                 :            : #endif
      20                 :            : 
      21                 :            : static const char system_image_path[256] = "\0" JL_SYSTEM_IMAGE_PATH;
      22                 :         15 : JL_DLLEXPORT const char *jl_get_default_sysimg_path(void)
      23                 :            : {
      24                 :         15 :     return &system_image_path[1];
      25                 :            : }
      26                 :            : 
      27                 :            : static int jl_options_initialized = 0;
      28                 :            : 
      29                 :         30 : JL_DLLEXPORT void jl_init_options(void)
      30                 :            : {
      31         [ +  + ]:         30 :     if (jl_options_initialized)
      32                 :         15 :         return;
      33                 :         15 :     jl_options =
      34                 :            :         (jl_options_t){ 0,    // quiet
      35                 :            :                         -1,   // banner
      36                 :            :                         NULL, // julia_bindir
      37                 :            :                         NULL, // julia_bin
      38                 :            :                         NULL, // cmds
      39                 :            :                         NULL, // image_file (will be filled in below)
      40                 :            :                         NULL, // cpu_target ("native", "core2", etc...)
      41                 :            :                         0,    // nthreadpools
      42                 :            :                         0,    // nthreads
      43                 :            :                         NULL, // nthreads_per_pool
      44                 :            :                         0,    // nprocs
      45                 :            :                         NULL, // machine_file
      46                 :            :                         NULL, // project
      47                 :            :                         0,    // isinteractive
      48                 :            :                         0,    // color
      49                 :            :                         JL_OPTIONS_HISTORYFILE_ON, // history file
      50                 :            :                         0,    // startup file
      51                 :            :                         JL_OPTIONS_COMPILE_DEFAULT, // compile_enabled
      52                 :            :                         0,    // code_coverage
      53                 :            :                         0,    // malloc_log
      54                 :            :                         NULL, // tracked_path
      55                 :            :                         2,    // opt_level
      56                 :            :                         0,    // opt_level_min
      57                 :            : #ifdef JL_DEBUG_BUILD
      58                 :            :                         2,    // debug_level [debug build]
      59                 :            : #else
      60                 :            :                         1,    // debug_level [release build]
      61                 :            : #endif
      62                 :            :                         JL_OPTIONS_CHECK_BOUNDS_DEFAULT, // check_bounds
      63                 :            :                         JL_OPTIONS_DEPWARN_OFF,    // deprecation warning
      64                 :            :                         0,    // method overwrite warning
      65                 :            :                         1,    // can_inline
      66                 :            :                         JL_OPTIONS_POLLY_ON, // polly
      67                 :            :                         NULL, // trace_compile
      68                 :            :                         JL_OPTIONS_FAST_MATH_DEFAULT,
      69                 :            :                         0,    // worker
      70                 :            :                         NULL, // cookie
      71                 :            :                         JL_OPTIONS_HANDLE_SIGNALS_ON,
      72                 :            :                         JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES,
      73                 :            :                         JL_OPTIONS_USE_COMPILED_MODULES_YES,
      74                 :            :                         NULL, // bind-to
      75                 :            :                         NULL, // output-bc
      76                 :            :                         NULL, // output-unopt-bc
      77                 :            :                         NULL, // output-o
      78                 :            :                         NULL, // output-asm
      79                 :            :                         NULL, // output-ji
      80                 :            :                         NULL, // output-code_coverage
      81                 :            :                         0, // incremental
      82                 :            :                         0, // image_file_specified
      83                 :            :                         JL_OPTIONS_WARN_SCOPE_ON,  // ambiguous scope warning
      84                 :            :                         0, // image-codegen
      85                 :            :                         0, // rr-detach
      86                 :            :                         0, // strip-metadata
      87                 :            :                         0, // strip-ir
      88                 :            :                         0, // heap-size-hint
      89                 :            :     };
      90                 :         15 :     jl_options_initialized = 1;
      91                 :            : }
      92                 :            : 
      93                 :            : static const char usage[] = "\n    julia [switches] -- [programfile] [args...]\n\n";
      94                 :            : static const char opts[]  =
      95                 :            :     "Switches (a '*' marks the default value, if applicable):\n\n"
      96                 :            :     " -v, --version              Display version information\n"
      97                 :            :     " -h, --help                 Print this message (--help-hidden for more)\n"
      98                 :            :     " --help-hidden              Uncommon options not shown by `-h`\n\n"
      99                 :            : 
     100                 :            :     // startup options
     101                 :            :     " --project[={<dir>|@.}]     Set <dir> as the home project/environment\n"
     102                 :            :     " -J, --sysimage <file>      Start up with the given system image file\n"
     103                 :            :     " -H, --home <dir>           Set location of `julia` executable\n"
     104                 :            :     " --startup-file={yes*|no}   Load `JULIA_DEPOT_PATH/config/startup.jl`; if `JULIA_DEPOT_PATH`\n"
     105                 :            :     "                            environment variable is unset, load `~/.julia/config/startup.jl`\n"
     106                 :            :     " --handle-signals={yes*|no} Enable or disable Julia's default signal handlers\n"
     107                 :            :     " --sysimage-native-code={yes*|no}\n"
     108                 :            :     "                            Use native code from system image if available\n"
     109                 :            :     " --compiled-modules={yes*|no}\n"
     110                 :            :     "                            Enable or disable incremental precompilation of modules\n\n"
     111                 :            : 
     112                 :            :     // actions
     113                 :            :     " -e, --eval <expr>          Evaluate <expr>\n"
     114                 :            :     " -E, --print <expr>         Evaluate <expr> and display the result\n"
     115                 :            :     " -L, --load <file>          Load <file> immediately on all processors\n\n"
     116                 :            : 
     117                 :            :     // parallel options
     118                 :            :     " -t, --threads {auto|N[,auto|M]}\n"
     119                 :            :     "                           Enable N[+M] threads; N threads are assigned to the `default`\n"
     120                 :            :     "                           threadpool, and if M is specified, M threads are assigned to the\n"
     121                 :            :     "                           `interactive` threadpool; \"auto\" tries to infer a useful\n"
     122                 :            :     "                           default number of threads to use but the exact behavior might change\n"
     123                 :            :     "                           in the future. Currently sets N to the number of CPUs assigned to\n"
     124                 :            :     "                           this Julia process based on the OS-specific affinity assignment\n"
     125                 :            :     "                           interface if supported (Linux and Windows) or to the number of CPU\n"
     126                 :            :     "                           threads if not supported (MacOS) or if process affinity is not\n"
     127                 :            :     "                           configured, and sets M to 1.\n"
     128                 :            :     " -p, --procs {N|auto}      Integer value N launches N additional local worker processes\n"
     129                 :            :     "                           \"auto\" launches as many workers as the number of local CPU threads (logical cores)\n"
     130                 :            :     " --machine-file <file>     Run processes on hosts listed in <file>\n\n"
     131                 :            : 
     132                 :            :     // interactive options
     133                 :            :     " -i                         Interactive mode; REPL runs and `isinteractive()` is true\n"
     134                 :            :     " -q, --quiet                Quiet startup: no banner, suppress REPL warnings\n"
     135                 :            :     " --banner={yes|no|auto*}    Enable or disable startup banner\n"
     136                 :            :     " --color={yes|no|auto*}     Enable or disable color text\n"
     137                 :            :     " --history-file={yes*|no}   Load or save history\n\n"
     138                 :            : 
     139                 :            :     // error and warning options
     140                 :            :     " --depwarn={yes|no*|error}  Enable or disable syntax and method deprecation warnings (`error` turns warnings into errors)\n"
     141                 :            :     " --warn-overwrite={yes|no*} Enable or disable method overwrite warnings\n"
     142                 :            :     " --warn-scope={yes*|no}     Enable or disable warning for ambiguous top-level scope\n\n"
     143                 :            : 
     144                 :            :     // code generation options
     145                 :            :     " -C, --cpu-target <target>  Limit usage of CPU features up to <target>; set to `help` to see the available options\n"
     146                 :            :     " -O, --optimize={0,1,2*,3}  Set the optimization level (level 3 if `-O` is used without a level)\n"
     147                 :            :     " --min-optlevel={0*,1,2,3}  Set a lower bound on the optimization level\n"
     148                 :            : #ifdef JL_DEBUG_BUILD
     149                 :            :         " -g [{0,1,2*}]              Set the level of debug info generation in the julia-debug build\n"
     150                 :            : #else
     151                 :            :         " -g [{0,1*,2}]              Set the level of debug info generation (level 2 if `-g` is used without a level)\n"
     152                 :            : #endif
     153                 :            :     " --inline={yes*|no}         Control whether inlining is permitted, including overriding @inline declarations\n"
     154                 :            :     " --check-bounds={yes|no|auto*}\n"
     155                 :            :     "                            Emit bounds checks always, never, or respect @inbounds declarations\n"
     156                 :            : #ifdef USE_POLLY
     157                 :            :     " --polly={yes*|no}          Enable or disable the polyhedral optimizer Polly (overrides @polly declaration)\n"
     158                 :            : #endif
     159                 :            : 
     160                 :            :     // instrumentation options
     161                 :            :     " --code-coverage[={none*|user|all}]\n"
     162                 :            :     "                            Count executions of source lines (omitting setting is equivalent to `user`)\n"
     163                 :            :     " --code-coverage=@<path>\n"
     164                 :            :     "                            Count executions but only in files that fall under the given file path/directory.\n"
     165                 :            :     "                            The `@` prefix is required to select this option. A `@` with no path will track the\n"
     166                 :            :     "                            current directory.\n"
     167                 :            : 
     168                 :            :     " --code-coverage=tracefile.info\n"
     169                 :            :     "                            Append coverage information to the LCOV tracefile (filename supports format tokens)\n"
     170                 :            : // TODO: These TOKENS are defined in `runtime_ccall.cpp`. A more verbose `--help` should include that list here.
     171                 :            :     " --track-allocation[={none*|user|all}]\n"
     172                 :            :     "                            Count bytes allocated by each source line (omitting setting is equivalent to `user`)\n"
     173                 :            :     " --track-allocation=@<path>\n"
     174                 :            :     "                            Count bytes but only in files that fall under the given file path/directory.\n"
     175                 :            :     "                            The `@` prefix is required to select this option. A `@` with no path will track the\n"
     176                 :            :     "                            current directory.\n"
     177                 :            :     " --bug-report=KIND          Launch a bug report session. It can be used to start a REPL, run a script, or evaluate\n"
     178                 :            :     "                            expressions. It first tries to use BugReporting.jl installed in current environment and\n"
     179                 :            :     "                            fallbacks to the latest compatible BugReporting.jl if not. For more information, see\n"
     180                 :            :     "                            --bug-report=help.\n\n"
     181                 :            : 
     182                 :            :     " --heap-size-hint=<size>    Forces garbage collection if memory usage is higher than that value.\n"
     183                 :            :     "                            The memory hint might be specified in megabytes(500M) or gigabytes(1G)\n\n"
     184                 :            : ;
     185                 :            : 
     186                 :            : static const char opts_hidden[]  =
     187                 :            :     "Switches (a '*' marks the default value, if applicable):\n\n"
     188                 :            :     // code generation options
     189                 :            :     " --compile={yes*|no|all|min}\n"
     190                 :            :     "                          Enable or disable JIT compiler, or request exhaustive or minimal compilation\n\n"
     191                 :            : 
     192                 :            :     // compiler output options
     193                 :            :     " --output-o <name>        Generate an object file (including system image data)\n"
     194                 :            :     " --output-ji <name>       Generate a system image data file (.ji)\n"
     195                 :            :     " --strip-metadata         Remove docstrings and source location info from system image\n"
     196                 :            :     " --strip-ir               Remove IR (intermediate representation) of compiled functions\n\n"
     197                 :            : 
     198                 :            :     // compiler debugging (see the devdocs for tips on using these options)
     199                 :            :     " --output-unopt-bc <name> Generate unoptimized LLVM bitcode (.bc)\n"
     200                 :            :     " --output-bc <name>       Generate LLVM bitcode (.bc)\n"
     201                 :            :     " --output-asm <name>      Generate an assembly file (.s)\n"
     202                 :            :     " --output-incremental={yes|no*}\n"
     203                 :            :     "                          Generate an incremental output file (rather than complete)\n"
     204                 :            :     " --trace-compile={stderr,name}\n"
     205                 :            :     "                          Print precompile statements for methods compiled during execution or save to a path\n"
     206                 :            :     " --image-codegen          Force generate code in imaging mode\n"
     207                 :            : ;
     208                 :            : 
     209                 :         15 : JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
     210                 :            : {
     211                 :            :     enum { opt_machinefile = 300,
     212                 :            :            opt_color,
     213                 :            :            opt_history_file,
     214                 :            :            opt_startup_file,
     215                 :            :            opt_compile,
     216                 :            :            opt_code_coverage,
     217                 :            :            opt_track_allocation,
     218                 :            :            opt_check_bounds,
     219                 :            :            opt_output_unopt_bc,
     220                 :            :            opt_output_bc,
     221                 :            :            opt_depwarn,
     222                 :            :            opt_warn_overwrite,
     223                 :            :            opt_warn_scope,
     224                 :            :            opt_inline,
     225                 :            :            opt_polly,
     226                 :            :            opt_trace_compile,
     227                 :            :            opt_math_mode,
     228                 :            :            opt_worker,
     229                 :            :            opt_bind_to,
     230                 :            :            opt_handle_signals,
     231                 :            :            opt_optlevel_min,
     232                 :            :            opt_output_o,
     233                 :            :            opt_output_asm,
     234                 :            :            opt_output_ji,
     235                 :            :            opt_use_precompiled,
     236                 :            :            opt_use_compilecache,
     237                 :            :            opt_incremental,
     238                 :            :            opt_help_hidden,
     239                 :            :            opt_banner,
     240                 :            :            opt_sysimage_native_code,
     241                 :            :            opt_compiled_modules,
     242                 :            :            opt_machine_file,
     243                 :            :            opt_project,
     244                 :            :            opt_bug_report,
     245                 :            :            opt_image_codegen,
     246                 :            :            opt_rr_detach,
     247                 :            :            opt_strip_metadata,
     248                 :            :            opt_strip_ir,
     249                 :            :            opt_heap_size_hint,
     250                 :            :     };
     251                 :            :     static const char* const shortopts = "+vhqH:e:E:L:J:C:it:p:O:g:";
     252                 :            :     static const struct option longopts[] = {
     253                 :            :         // exposed command line options
     254                 :            :         // NOTE: This set of required arguments need to be kept in sync
     255                 :            :         // with the required arguments defined in base/options.jl `struct JLOptions`
     256                 :            :         { "version",         no_argument,       0, 'v' },
     257                 :            :         { "help",            no_argument,       0, 'h' },
     258                 :            :         { "help-hidden",     no_argument,       0, opt_help_hidden },
     259                 :            :         { "quiet",           no_argument,       0, 'q' },
     260                 :            :         { "banner",          required_argument, 0, opt_banner },
     261                 :            :         { "home",            required_argument, 0, 'H' },
     262                 :            :         { "eval",            required_argument, 0, 'e' },
     263                 :            :         { "print",           required_argument, 0, 'E' },
     264                 :            :         { "load",            required_argument, 0, 'L' },
     265                 :            :         { "bug-report",      required_argument, 0, opt_bug_report },
     266                 :            :         { "sysimage",        required_argument, 0, 'J' },
     267                 :            :         { "sysimage-native-code", required_argument, 0, opt_sysimage_native_code },
     268                 :            :         { "compiled-modules",required_argument, 0, opt_compiled_modules },
     269                 :            :         { "cpu-target",      required_argument, 0, 'C' },
     270                 :            :         { "procs",           required_argument, 0, 'p' },
     271                 :            :         { "threads",         required_argument, 0, 't' },
     272                 :            :         { "machine-file",    required_argument, 0, opt_machine_file },
     273                 :            :         { "project",         optional_argument, 0, opt_project },
     274                 :            :         { "color",           required_argument, 0, opt_color },
     275                 :            :         { "history-file",    required_argument, 0, opt_history_file },
     276                 :            :         { "startup-file",    required_argument, 0, opt_startup_file },
     277                 :            :         { "compile",         required_argument, 0, opt_compile },
     278                 :            :         { "code-coverage",   optional_argument, 0, opt_code_coverage },
     279                 :            :         { "track-allocation",optional_argument, 0, opt_track_allocation },
     280                 :            :         { "optimize",        optional_argument, 0, 'O' },
     281                 :            :         { "min-optlevel",    optional_argument, 0, opt_optlevel_min },
     282                 :            :         { "check-bounds",    required_argument, 0, opt_check_bounds },
     283                 :            :         { "output-bc",       required_argument, 0, opt_output_bc },
     284                 :            :         { "output-unopt-bc", required_argument, 0, opt_output_unopt_bc },
     285                 :            :         { "output-o",        required_argument, 0, opt_output_o },
     286                 :            :         { "output-asm",      required_argument, 0, opt_output_asm },
     287                 :            :         { "output-ji",       required_argument, 0, opt_output_ji },
     288                 :            :         { "output-incremental",required_argument, 0, opt_incremental },
     289                 :            :         { "depwarn",         required_argument, 0, opt_depwarn },
     290                 :            :         { "warn-overwrite",  required_argument, 0, opt_warn_overwrite },
     291                 :            :         { "warn-scope",      required_argument, 0, opt_warn_scope },
     292                 :            :         { "inline",          required_argument, 0, opt_inline },
     293                 :            :         { "polly",           required_argument, 0, opt_polly },
     294                 :            :         { "trace-compile",   required_argument, 0, opt_trace_compile },
     295                 :            :         { "math-mode",       required_argument, 0, opt_math_mode },
     296                 :            :         { "handle-signals",  required_argument, 0, opt_handle_signals },
     297                 :            :         // hidden command line options
     298                 :            :         { "worker",          optional_argument, 0, opt_worker },
     299                 :            :         { "bind-to",         required_argument, 0, opt_bind_to },
     300                 :            :         { "lisp",            no_argument,       0, 1 },
     301                 :            :         { "image-codegen",   no_argument,       0, opt_image_codegen },
     302                 :            :         { "rr-detach",       no_argument,       0, opt_rr_detach },
     303                 :            :         { "strip-metadata",  no_argument,       0, opt_strip_metadata },
     304                 :            :         { "strip-ir",        no_argument,       0, opt_strip_ir },
     305                 :            :         { "heap-size-hint",  required_argument, 0, opt_heap_size_hint },
     306                 :            :         { 0, 0, 0, 0 }
     307                 :            :     };
     308                 :            : 
     309                 :            :     // If CPUID specific binaries are enabled, this varies between runs, so initialize
     310                 :            :     // it here, rather than as part of the static initialization above.
     311                 :         15 :     jl_options.image_file = jl_get_default_sysimg_path();
     312                 :         15 :     jl_options.cmds = NULL;
     313                 :            : 
     314                 :         15 :     int ncmds = 0;
     315                 :         15 :     const char **cmds = NULL;
     316                 :         15 :     int codecov = JL_LOG_NONE;
     317                 :         15 :     int malloclog = JL_LOG_NONE;
     318                 :         15 :     int argc = *argcp;
     319                 :         15 :     char **argv = *argvp;
     320                 :            :     char *endptr;
     321                 :         15 :     opterr = 0; // suppress getopt warning messages
     322                 :        114 :     while (1) {
     323                 :        129 :         int lastind = optind;
     324                 :        129 :         int c = getopt_long(argc, argv, shortopts, longopts, 0);
     325         [ +  + ]:        129 :         if (c == -1) break;
     326                 :        114 : restart_switch:
     327   [ -  -  -  -  :        114 :         switch (c) {
          -  -  +  -  +  
          +  -  -  -  -  
          +  -  -  -  -  
          +  +  +  -  -  
          -  +  -  +  -  
          -  -  +  -  +  
          +  -  +  -  -  
          -  +  -  -  -  
          -  -  -  -  -  
                   -  - ]
     328                 :          0 :         case 0:
     329                 :          0 :             break;
     330                 :          0 :         case 1:
     331                 :          0 :             jl_errorf("--lisp must be specified as the first argument");
     332                 :            :             break;
     333                 :          0 :         case '?':
     334                 :            :         case ':':
     335         [ #  # ]:          0 :             if (optopt) {
     336         [ #  # ]:          0 :                 if (optopt == 'g') {
     337                 :          0 :                     c = 'g';
     338                 :          0 :                     goto restart_switch;
     339                 :            :                 }
     340         [ #  # ]:          0 :                 for (const struct option *o = longopts; o->val; o++) {
     341         [ #  # ]:          0 :                     if (optopt == o->val) {
     342         [ #  # ]:          0 :                         if (o->has_arg == optional_argument) {
     343                 :          0 :                             c = o->val;
     344                 :          0 :                             goto restart_switch;
     345                 :            :                         }
     346   [ #  #  #  # ]:          0 :                         else if (o->val <= 0xff && strchr(shortopts, o->val)) {
     347                 :          0 :                             jl_errorf("option `-%c/--%s` is missing an argument", o->val, o->name);
     348                 :            :                         }
     349                 :            :                         else {
     350                 :          0 :                             jl_errorf("option `--%s` is missing an argument", o->name);
     351                 :            :                         }
     352                 :            :                     }
     353                 :            :                 }
     354                 :          0 :                 jl_errorf("unknown option `-%c`", optopt);
     355                 :            :             }
     356                 :            :             else {
     357                 :          0 :                 jl_errorf("unknown option `%s`", argv[lastind]);
     358                 :            :             }
     359                 :            :             break;
     360                 :          0 :         case 'v': // version
     361                 :          0 :             jl_printf(JL_STDOUT, "julia version %s\n", JULIA_VERSION_STRING);
     362                 :          0 :             exit(0);
     363                 :          0 :         case 'h': // help
     364                 :          0 :             jl_printf(JL_STDOUT, "%s%s", usage, opts);
     365                 :          0 :             exit(0);
     366                 :          0 :         case opt_help_hidden:
     367                 :          0 :             jl_printf(JL_STDOUT, "%s%s", usage, opts_hidden);
     368                 :          0 :             exit(0);
     369                 :          7 :         case 'g': // debug info
     370         [ +  - ]:          7 :             if (optarg != NULL) {
     371         [ +  + ]:          7 :                 if (!strcmp(optarg,"0"))
     372                 :          1 :                     jl_options.debug_level = 0;
     373         [ +  + ]:          6 :                 else if (!strcmp(optarg,"1"))
     374                 :          2 :                     jl_options.debug_level = 1;
     375         [ +  - ]:          4 :                 else if (!strcmp(optarg,"2"))
     376                 :          4 :                     jl_options.debug_level = 2;
     377                 :            :                 else
     378                 :          0 :                     jl_errorf("julia: invalid argument to -g (%s)", optarg);
     379                 :          7 :                 break;
     380                 :            :             }
     381                 :            :             else {
     382                 :          0 :                 jl_options.debug_level = 2;
     383                 :            :             }
     384                 :          0 :             break;
     385                 :          0 :         case 'H': // home
     386                 :          0 :             jl_options.julia_bindir = strdup(optarg);
     387         [ #  # ]:          0 :             if (!jl_options.julia_bindir)
     388                 :          0 :                 jl_errorf("fatal error: failed to allocate memory: %s", strerror(errno));
     389                 :          0 :             break;
     390                 :          4 :         case 'e': // eval
     391                 :            :         case 'E': // print
     392                 :            :         case 'L': // load
     393                 :            :         case opt_bug_report: // bug
     394                 :            :         {
     395                 :          4 :             size_t sz = strlen(optarg) + 1;
     396                 :          4 :             char *arg = (char*)malloc_s(sz + 1);
     397                 :            :             const char **newcmds;
     398         [ +  - ]:          4 :             arg[0] = c == opt_bug_report ? 'B' : c;
     399                 :          4 :             memcpy(arg + 1, optarg, sz);
     400                 :          4 :             newcmds = (const char**)realloc_s(cmds, (ncmds + 2) * sizeof(char*));
     401                 :          4 :             cmds = newcmds;
     402                 :          4 :             cmds[ncmds] = arg;
     403                 :          4 :             ncmds++;
     404                 :          4 :             cmds[ncmds] = 0;
     405                 :          4 :             jl_options.cmds = cmds;
     406                 :          4 :             break;
     407                 :            :         }
     408                 :         12 :         case 'J': // sysimage
     409                 :         12 :             jl_options.image_file = strdup(optarg);
     410         [ -  + ]:         12 :             if (!jl_options.image_file)
     411                 :          0 :                 jl_errorf("fatal error: failed to allocate memory: %s", strerror(errno));
     412                 :         12 :             jl_options.image_file_specified = 1;
     413                 :         12 :             break;
     414                 :          0 :         case 'q': // quiet
     415                 :          0 :             jl_options.quiet = 1;
     416         [ #  # ]:          0 :             if (jl_options.banner < 0)
     417                 :          0 :                 jl_options.banner = 0;
     418                 :          0 :             break;
     419                 :          0 :         case opt_banner: // banner
     420         [ #  # ]:          0 :             if (!strcmp(optarg, "yes"))
     421                 :          0 :                 jl_options.banner = 1;
     422         [ #  # ]:          0 :             else if (!strcmp(optarg, "no"))
     423                 :          0 :                 jl_options.banner = 0;
     424         [ #  # ]:          0 :             else if (!strcmp(optarg, "auto"))
     425                 :          0 :                 jl_options.banner = -1;
     426                 :            :             else
     427                 :          0 :                 jl_errorf("julia: invalid argument to --banner={yes|no|auto} (%s)", optarg);
     428                 :          0 :             break;
     429                 :          0 :         case opt_sysimage_native_code:
     430         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     431                 :          0 :                 jl_options.use_sysimage_native_code = JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES;
     432         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     433                 :          0 :                 jl_options.use_sysimage_native_code = JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_NO;
     434                 :            :             else
     435                 :          0 :                 jl_errorf("julia: invalid argument to --sysimage-native-code={yes|no} (%s)", optarg);
     436                 :          0 :             break;
     437                 :          0 :         case opt_compiled_modules:
     438         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     439                 :          0 :                 jl_options.use_compiled_modules = JL_OPTIONS_USE_COMPILED_MODULES_YES;
     440         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     441                 :          0 :                 jl_options.use_compiled_modules = JL_OPTIONS_USE_COMPILED_MODULES_NO;
     442                 :            :             else
     443                 :          0 :                 jl_errorf("julia: invalid argument to --compiled-modules={yes|no} (%s)", optarg);
     444                 :          0 :             break;
     445                 :         13 :         case 'C': // cpu-target
     446                 :         13 :             jl_options.cpu_target = strdup(optarg);
     447         [ -  + ]:         13 :             if (!jl_options.cpu_target)
     448                 :          0 :                 jl_error("julia: failed to allocate memory");
     449                 :         13 :             break;
     450                 :          0 :         case 't': // threads
     451                 :          0 :             errno = 0;
     452                 :          0 :             jl_options.nthreadpools = 1;
     453                 :          0 :             long nthreads = -1, nthreadsi = 0;
     454         [ #  # ]:          0 :             if (!strncmp(optarg, "auto", 4)) {
     455                 :          0 :                 jl_options.nthreads = -1;
     456         [ #  # ]:          0 :                 if (optarg[4] == ',') {
     457         [ #  # ]:          0 :                     if (!strncmp(&optarg[5], "auto", 4))
     458                 :          0 :                         nthreadsi = 1;
     459                 :            :                     else {
     460                 :          0 :                         errno = 0;
     461                 :          0 :                         nthreadsi = strtol(&optarg[5], &endptr, 10);
     462   [ #  #  #  #  :          0 :                         if (errno != 0 || endptr == &optarg[5] || *endptr != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX)
          #  #  #  #  #  
                      # ]
     463                 :          0 :                             jl_errorf("julia: -t,--threads=auto,<m>; m must be an integer >= 1");
     464                 :            :                     }
     465                 :          0 :                     jl_options.nthreadpools++;
     466                 :            :                 }
     467                 :            :             }
     468                 :            :             else {
     469                 :          0 :                 nthreads = strtol(optarg, &endptr, 10);
     470   [ #  #  #  #  :          0 :                 if (errno != 0 || optarg == endptr || nthreads < 1 || nthreads >= INT16_MAX)
             #  #  #  # ]
     471                 :          0 :                     jl_errorf("julia: -t,--threads=<n>[,auto|<m>]; n must be an integer >= 1");
     472         [ #  # ]:          0 :                 if (*endptr == ',') {
     473         [ #  # ]:          0 :                     if (!strncmp(&endptr[1], "auto", 4))
     474                 :          0 :                         nthreadsi = 1;
     475                 :            :                     else {
     476                 :          0 :                         errno = 0;
     477                 :            :                         char *endptri;
     478                 :          0 :                         nthreadsi = strtol(&endptr[1], &endptri, 10);
     479   [ #  #  #  #  :          0 :                         if (errno != 0 || endptri == &endptr[1] || *endptri != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX)
          #  #  #  #  #  
                      # ]
     480                 :          0 :                             jl_errorf("julia: -t,--threads=<n>,<m>; n and m must be integers >= 1");
     481                 :            :                     }
     482                 :          0 :                     jl_options.nthreadpools++;
     483                 :            :                 }
     484                 :          0 :                 jl_options.nthreads = nthreads + nthreadsi;
     485                 :            :             }
     486                 :          0 :             int16_t *ntpp = (int16_t *)malloc_s(jl_options.nthreadpools * sizeof(int16_t));
     487                 :          0 :             ntpp[0] = (int16_t)nthreads;
     488         [ #  # ]:          0 :             if (jl_options.nthreadpools == 2)
     489                 :          0 :                 ntpp[1] = (int16_t)nthreadsi;
     490                 :          0 :             jl_options.nthreads_per_pool = ntpp;
     491                 :          0 :             break;
     492                 :          0 :         case 'p': // procs
     493                 :          0 :             errno = 0;
     494         [ #  # ]:          0 :             if (!strcmp(optarg,"auto")) {
     495                 :          0 :                 jl_options.nprocs = jl_effective_threads();
     496                 :            :             }
     497                 :            :             else {
     498                 :          0 :                 long nprocs = strtol(optarg, &endptr, 10);
     499   [ #  #  #  #  :          0 :                 if (errno != 0 || optarg == endptr || *endptr != 0 || nprocs < 1 || nprocs >= INT16_MAX)
          #  #  #  #  #  
                      # ]
     500                 :          0 :                     jl_errorf("julia: -p,--procs=<n> must be an integer >= 1");
     501                 :          0 :                 jl_options.nprocs = (int)nprocs;
     502                 :            :             }
     503                 :          0 :             break;
     504                 :          0 :         case opt_machine_file:
     505                 :          0 :             jl_options.machine_file = strdup(optarg);
     506         [ #  # ]:          0 :             if (!jl_options.machine_file)
     507                 :          0 :                 jl_error("julia: failed to allocate memory");
     508                 :          0 :             break;
     509                 :          0 :         case opt_project:
     510         [ #  # ]:          0 :             jl_options.project = optarg ? strdup(optarg) : "@.";
     511                 :          0 :             break;
     512                 :          8 :         case opt_color:
     513         [ +  + ]:          8 :             if (!strcmp(optarg, "yes"))
     514                 :          6 :                 jl_options.color = JL_OPTIONS_COLOR_ON;
     515         [ -  + ]:          2 :             else if (!strcmp(optarg, "no"))
     516                 :          0 :                 jl_options.color = JL_OPTIONS_COLOR_OFF;
     517         [ +  - ]:          2 :             else if (!strcmp(optarg, "auto"))
     518                 :          2 :                 jl_options.color = JL_OPTIONS_COLOR_AUTO;
     519                 :            :             else
     520                 :          0 :                 jl_errorf("julia: invalid argument to --color={yes|no|auto} (%s)", optarg);
     521                 :          8 :             break;
     522                 :          4 :         case opt_history_file:
     523         [ -  + ]:          4 :             if (!strcmp(optarg,"yes"))
     524                 :          0 :                 jl_options.historyfile = JL_OPTIONS_HISTORYFILE_ON;
     525         [ +  - ]:          4 :             else if (!strcmp(optarg,"no"))
     526                 :          4 :                 jl_options.historyfile = JL_OPTIONS_HISTORYFILE_OFF;
     527                 :            :             else
     528                 :          0 :                 jl_errorf("julia: invalid argument to --history-file={yes|no} (%s)", optarg);
     529                 :          4 :             break;
     530                 :         19 :         case opt_startup_file:
     531         [ -  + ]:         19 :             if (!strcmp(optarg,"yes"))
     532                 :          0 :                 jl_options.startupfile = JL_OPTIONS_STARTUPFILE_ON;
     533         [ +  - ]:         19 :             else if (!strcmp(optarg,"no"))
     534                 :         19 :                 jl_options.startupfile = JL_OPTIONS_STARTUPFILE_OFF;
     535                 :            :             else
     536                 :          0 :                 jl_errorf("julia: invalid argument to --startup-file={yes|no} (%s)", optarg);
     537                 :         19 :             break;
     538                 :          0 :         case opt_compile:
     539         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     540                 :          0 :                 jl_options.compile_enabled = JL_OPTIONS_COMPILE_ON;
     541         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     542                 :          0 :                 jl_options.compile_enabled = JL_OPTIONS_COMPILE_OFF;
     543         [ #  # ]:          0 :             else if (!strcmp(optarg,"all"))
     544                 :          0 :                 jl_options.compile_enabled = JL_OPTIONS_COMPILE_ALL;
     545         [ #  # ]:          0 :             else if (!strcmp(optarg,"min"))
     546                 :          0 :                 jl_options.compile_enabled = JL_OPTIONS_COMPILE_MIN;
     547                 :            :             else
     548                 :          0 :                 jl_errorf("julia: invalid argument to --compile (%s)", optarg);
     549                 :          0 :             break;
     550                 :          0 :         case opt_code_coverage:
     551         [ #  # ]:          0 :             if (optarg != NULL) {
     552                 :          0 :                 size_t endof = strlen(optarg);
     553         [ #  # ]:          0 :                 if (!strcmp(optarg, "user"))
     554                 :          0 :                     codecov = JL_LOG_USER;
     555         [ #  # ]:          0 :                 else if (!strcmp(optarg, "all"))
     556                 :          0 :                     codecov = JL_LOG_ALL;
     557         [ #  # ]:          0 :                 else if (!strcmp(optarg, "none"))
     558                 :          0 :                     codecov = JL_LOG_NONE;
     559   [ #  #  #  # ]:          0 :                 else if (endof > 5 && !strcmp(optarg + endof - 5, ".info")) {
     560         [ #  # ]:          0 :                     if (codecov == JL_LOG_NONE)
     561                 :          0 :                         codecov = JL_LOG_ALL;
     562                 :          0 :                     jl_options.output_code_coverage = optarg;
     563                 :            :                 }
     564         [ #  # ]:          0 :                 else if (!strncmp(optarg, "@", 1)) {
     565                 :          0 :                     codecov = JL_LOG_PATH;
     566                 :          0 :                     jl_options.tracked_path = optarg + 1; // skip `@`
     567                 :            :                 }
     568                 :            :                 else
     569                 :          0 :                     jl_errorf("julia: invalid argument to --code-coverage (%s)", optarg);
     570                 :          0 :                 break;
     571                 :            :             }
     572                 :            :             else {
     573                 :          0 :                 codecov = JL_LOG_USER;
     574                 :            :             }
     575                 :          0 :             break;
     576                 :          0 :         case opt_track_allocation:
     577         [ #  # ]:          0 :             if (optarg != NULL) {
     578         [ #  # ]:          0 :                 if (!strcmp(optarg,"user"))
     579                 :          0 :                     malloclog = JL_LOG_USER;
     580         [ #  # ]:          0 :                 else if (!strcmp(optarg,"all"))
     581                 :          0 :                     malloclog = JL_LOG_ALL;
     582         [ #  # ]:          0 :                 else if (!strcmp(optarg,"none"))
     583                 :          0 :                     malloclog = JL_LOG_NONE;
     584         [ #  # ]:          0 :                 else if (!strncmp(optarg, "@", 1)) {
     585                 :          0 :                     malloclog = JL_LOG_PATH;
     586                 :          0 :                     jl_options.tracked_path = optarg + 1; // skip `@`
     587                 :            :                 }
     588                 :            :                 else
     589                 :          0 :                     jl_errorf("julia: invalid argument to --track-allocation (%s)", optarg);
     590                 :          0 :                 break;
     591                 :            :             }
     592                 :            :             else {
     593                 :          0 :                 malloclog = JL_LOG_USER;
     594                 :            :             }
     595                 :          0 :             break;
     596                 :         17 :         case 'O': // optimize
     597         [ +  - ]:         17 :             if (optarg != NULL) {
     598         [ +  - ]:         17 :                 if (!strcmp(optarg,"0"))
     599                 :         17 :                     jl_options.opt_level = 0;
     600         [ #  # ]:          0 :                 else if (!strcmp(optarg,"1"))
     601                 :          0 :                     jl_options.opt_level = 1;
     602         [ #  # ]:          0 :                 else if (!strcmp(optarg,"2"))
     603                 :          0 :                     jl_options.opt_level = 2;
     604         [ #  # ]:          0 :                 else if (!strcmp(optarg,"3"))
     605                 :          0 :                     jl_options.opt_level = 3;
     606                 :            :                 else
     607                 :          0 :                     jl_errorf("julia: invalid argument to -O (%s)", optarg);
     608                 :         17 :                 break;
     609                 :            :             }
     610                 :            :             else {
     611                 :          0 :                 jl_options.opt_level = 3;
     612                 :            :             }
     613                 :          0 :             break;
     614                 :          0 :         case opt_optlevel_min: // minimum module optimize level
     615         [ #  # ]:          0 :             if (optarg != NULL) {
     616         [ #  # ]:          0 :                 if (!strcmp(optarg,"0"))
     617                 :          0 :                     jl_options.opt_level_min = 0;
     618         [ #  # ]:          0 :                 else if (!strcmp(optarg,"1"))
     619                 :          0 :                     jl_options.opt_level_min = 1;
     620         [ #  # ]:          0 :                 else if (!strcmp(optarg,"2"))
     621                 :          0 :                     jl_options.opt_level_min = 2;
     622         [ #  # ]:          0 :                 else if (!strcmp(optarg,"3"))
     623                 :          0 :                     jl_options.opt_level_min = 3;
     624                 :            :                 else
     625                 :          0 :                     jl_errorf("julia: invalid argument to --min-optlevel (%s)", optarg);
     626                 :          0 :                 break;
     627                 :            :             }
     628                 :            :             else {
     629                 :          0 :                 jl_options.opt_level_min = 0;
     630                 :            :             }
     631                 :          0 :             break;
     632                 :          2 :         case 'i': // isinteractive
     633                 :          2 :             jl_options.isinteractive = 1;
     634                 :          2 :             break;
     635                 :          0 :         case opt_check_bounds:
     636         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     637                 :          0 :                 jl_options.check_bounds = JL_OPTIONS_CHECK_BOUNDS_ON;
     638         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     639                 :          0 :                 jl_options.check_bounds = JL_OPTIONS_CHECK_BOUNDS_OFF;
     640         [ #  # ]:          0 :             else if (!strcmp(optarg,"auto"))
     641                 :          0 :                 jl_options.check_bounds = JL_OPTIONS_CHECK_BOUNDS_DEFAULT;
     642                 :            :             else
     643                 :          0 :                 jl_errorf("julia: invalid argument to --check-bounds={yes|no|auto} (%s)", optarg);
     644                 :          0 :             break;
     645                 :          0 :         case opt_output_bc:
     646                 :          0 :             jl_options.outputbc = optarg;
     647         [ #  # ]:          0 :             if (!jl_options.image_file_specified) jl_options.image_file = NULL;
     648                 :          0 :             break;
     649                 :          0 :         case opt_output_unopt_bc:
     650                 :          0 :             jl_options.outputunoptbc = optarg;
     651         [ #  # ]:          0 :             if (!jl_options.image_file_specified) jl_options.image_file = NULL;
     652                 :          0 :             break;
     653                 :          2 :         case opt_output_o:
     654                 :          2 :             jl_options.outputo = optarg;
     655         [ +  - ]:          2 :             if (!jl_options.image_file_specified) jl_options.image_file = NULL;
     656                 :          2 :             break;
     657                 :          0 :         case opt_output_asm:
     658                 :          0 :             jl_options.outputasm = optarg;
     659         [ #  # ]:          0 :             if (!jl_options.image_file_specified) jl_options.image_file = NULL;
     660                 :          0 :             break;
     661                 :          7 :         case opt_output_ji:
     662                 :          7 :             jl_options.outputji = optarg;
     663         [ +  + ]:          7 :             if (!jl_options.image_file_specified) jl_options.image_file = NULL;
     664                 :          7 :             break;
     665                 :          4 :         case opt_incremental:
     666         [ +  - ]:          4 :             if (!strcmp(optarg,"yes"))
     667                 :          4 :                 jl_options.incremental = 1;
     668         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     669                 :          0 :                 jl_options.incremental = 0;
     670                 :            :             else
     671                 :          0 :                 jl_errorf("julia: invalid argument to --output-incremental={yes|no} (%s)", optarg);
     672                 :          4 :             break;
     673                 :          0 :         case opt_depwarn:
     674         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     675                 :          0 :                 jl_options.depwarn = JL_OPTIONS_DEPWARN_ON;
     676         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     677                 :          0 :                 jl_options.depwarn = JL_OPTIONS_DEPWARN_OFF;
     678         [ #  # ]:          0 :             else if (!strcmp(optarg,"error"))
     679                 :          0 :                 jl_options.depwarn = JL_OPTIONS_DEPWARN_ERROR;
     680                 :            :             else
     681                 :          0 :                 jl_errorf("julia: invalid argument to --depwarn={yes|no|error} (%s)", optarg);
     682                 :          0 :             break;
     683                 :          9 :         case opt_warn_overwrite:
     684         [ +  - ]:          9 :             if (!strcmp(optarg,"yes"))
     685                 :          9 :                 jl_options.warn_overwrite = JL_OPTIONS_WARN_OVERWRITE_ON;
     686         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     687                 :          0 :                 jl_options.warn_overwrite = JL_OPTIONS_WARN_OVERWRITE_OFF;
     688                 :            :             else
     689                 :          0 :                 jl_errorf("julia: invalid argument to --warn-overwrite={yes|no} (%s)", optarg);
     690                 :          9 :             break;
     691                 :          0 :         case opt_warn_scope:
     692         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     693                 :          0 :                 jl_options.warn_scope = JL_OPTIONS_WARN_SCOPE_ON;
     694         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     695                 :          0 :                 jl_options.warn_scope = JL_OPTIONS_WARN_SCOPE_OFF;
     696                 :            :             else
     697                 :          0 :                 jl_errorf("julia: invalid argument to --warn-scope={yes|no} (%s)", optarg);
     698                 :          0 :             break;
     699                 :          0 :         case opt_inline:
     700         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     701                 :          0 :                 jl_options.can_inline = 1;
     702         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     703                 :          0 :                 jl_options.can_inline = 0;
     704                 :            :             else {
     705                 :          0 :                 jl_errorf("julia: invalid argument to --inline (%s)", optarg);
     706                 :            :             }
     707                 :          0 :             break;
     708                 :          0 :        case opt_polly:
     709         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     710                 :          0 :                 jl_options.polly = JL_OPTIONS_POLLY_ON;
     711         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     712                 :          0 :                 jl_options.polly = JL_OPTIONS_POLLY_OFF;
     713                 :            :             else {
     714                 :          0 :                 jl_errorf("julia: invalid argument to --polly (%s)", optarg);
     715                 :            :             }
     716                 :          0 :             break;
     717                 :          6 :          case opt_trace_compile:
     718                 :          6 :             jl_options.trace_compile = strdup(optarg);
     719         [ -  + ]:          6 :             if (!jl_options.trace_compile)
     720                 :          0 :                 jl_errorf("fatal error: failed to allocate memory: %s", strerror(errno));
     721                 :          6 :             break;
     722                 :          0 :         case opt_math_mode:
     723         [ #  # ]:          0 :             if (!strcmp(optarg,"ieee"))
     724                 :          0 :                 jl_options.fast_math = JL_OPTIONS_FAST_MATH_OFF;
     725         [ #  # ]:          0 :             else if (!strcmp(optarg,"fast"))
     726                 :          0 :                 jl_options.fast_math = JL_OPTIONS_FAST_MATH_DEFAULT;
     727         [ #  # ]:          0 :             else if (!strcmp(optarg,"user"))
     728                 :          0 :                 jl_options.fast_math = JL_OPTIONS_FAST_MATH_DEFAULT;
     729                 :            :             else
     730                 :          0 :                 jl_errorf("julia: invalid argument to --math-mode (%s)", optarg);
     731                 :          0 :             break;
     732                 :          0 :         case opt_worker:
     733                 :          0 :             jl_options.worker = 1;
     734         [ #  # ]:          0 :             if (optarg != NULL) {
     735                 :          0 :                 jl_options.cookie = strdup(optarg);
     736         [ #  # ]:          0 :                 if (!jl_options.cookie)
     737                 :          0 :                     jl_error("julia: failed to allocate memory");
     738                 :            :             }
     739                 :          0 :             break;
     740                 :          0 :         case opt_bind_to:
     741                 :          0 :             jl_options.bindto = strdup(optarg);
     742         [ #  # ]:          0 :             if (!jl_options.bindto)
     743                 :          0 :                 jl_error("julia: failed to allocate memory");
     744                 :          0 :             break;
     745                 :          0 :         case opt_handle_signals:
     746         [ #  # ]:          0 :             if (!strcmp(optarg,"yes"))
     747                 :          0 :                 jl_options.handle_signals = JL_OPTIONS_HANDLE_SIGNALS_ON;
     748         [ #  # ]:          0 :             else if (!strcmp(optarg,"no"))
     749                 :          0 :                 jl_options.handle_signals = JL_OPTIONS_HANDLE_SIGNALS_OFF;
     750                 :            :             else
     751                 :          0 :                 jl_errorf("julia: invalid argument to --handle-signals (%s)", optarg);
     752                 :          0 :             break;
     753                 :          0 :         case opt_image_codegen:
     754                 :          0 :             jl_options.image_codegen = 1;
     755                 :          0 :             break;
     756                 :          0 :         case opt_rr_detach:
     757                 :          0 :             jl_options.rr_detach = 1;
     758                 :          0 :             break;
     759                 :          0 :         case opt_strip_metadata:
     760                 :          0 :             jl_options.strip_metadata = 1;
     761                 :          0 :             break;
     762                 :          0 :         case opt_strip_ir:
     763                 :          0 :             jl_options.strip_ir = 1;
     764                 :          0 :             break;
     765                 :          0 :         case opt_heap_size_hint:
     766         [ #  # ]:          0 :             if (optarg != NULL) {
     767                 :          0 :                 size_t endof = strlen(optarg);
     768                 :          0 :                 long double value = 0.0;
     769   [ #  #  #  # ]:          0 :                 if (sscanf(optarg, "%Lf", &value) == 1 && value > 1e-7) {
     770                 :          0 :                     char unit = optarg[endof - 1];
     771                 :          0 :                     uint64_t multiplier = 1ull;
     772   [ #  #  #  #  :          0 :                     switch (unit) {
                      # ]
     773                 :          0 :                         case 'k':
     774                 :            :                         case 'K':
     775                 :          0 :                             multiplier <<= 10;
     776                 :          0 :                             break;
     777                 :          0 :                         case 'm':
     778                 :            :                         case 'M':
     779                 :          0 :                             multiplier <<= 20;
     780                 :          0 :                             break;
     781                 :          0 :                         case 'g':
     782                 :            :                         case 'G':
     783                 :          0 :                             multiplier <<= 30;
     784                 :          0 :                             break;
     785                 :          0 :                         case 't':
     786                 :            :                         case 'T':
     787                 :          0 :                             multiplier <<= 40;
     788                 :          0 :                             break;
     789                 :          0 :                         default:
     790                 :          0 :                             break;
     791                 :            :                     }
     792                 :          0 :                     jl_options.heap_size_hint = (uint64_t)(value * multiplier);
     793                 :            : 
     794                 :          0 :                     jl_gc_set_max_memory(jl_options.heap_size_hint);
     795                 :            :                 }
     796                 :            :             }
     797         [ #  # ]:          0 :             if (jl_options.heap_size_hint == 0)
     798                 :          0 :                 jl_errorf("julia: invalid argument to --heap-size-hint without memory size specified");
     799                 :            : 
     800                 :          0 :             break;
     801                 :          0 :         default:
     802                 :          0 :             jl_errorf("julia: unhandled option -- %c\n"
     803                 :            :                       "This is a bug, please report it.", c);
     804                 :            :         }
     805                 :            :     }
     806                 :         15 :     jl_options.code_coverage = codecov;
     807                 :         15 :     jl_options.malloc_log = malloclog;
     808                 :         15 :     int proc_args = *argcp < optind ? *argcp : optind;
     809                 :         15 :     *argvp += proc_args;
     810                 :         15 :     *argcp -= proc_args;
     811                 :         15 : }
     812                 :            : 
     813                 :          3 : JL_DLLEXPORT ssize_t jl_sizeof_jl_options(void)
     814                 :            : {
     815                 :          3 :     return sizeof(jl_options_t);
     816                 :            : }

Generated by: LCOV version 1.14