Skip to content

Commit

Permalink
Add --dump-bitcode option to dump bitcode when building the system image
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Aug 12, 2014
1 parent da5e8f8 commit aa9baa1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jl_compileropts_t jl_compileropts = { NULL, // build_path
0, // code_coverage
0, // malloc_log
JL_COMPILEROPT_CHECK_BOUNDS_DEFAULT,
JL_COMPILEROPT_DUMPBITCODE_OFF,
0 // int32_literals
};

Expand Down Expand Up @@ -1011,6 +1012,16 @@ DLLEXPORT int julia_trampoline(int argc, char **argv, int (*pmain)(int ac,char *
if (asprintf(&build_ji, "%s.ji",build_path) > 0) {
jl_save_system_image(build_ji);
free(build_ji);
if (jl_compileropts.dumpbitcode == JL_COMPILEROPT_DUMPBITCODE_ON)
{
char *build_bc;
if (asprintf(&build_bc, "%s.bc",build_path) > 0) {
jl_dump_bitcode(build_bc);
free(build_bc);
} else {
ios_printf(ios_stderr,"\nWARNING: failed to create string for .bc build path\n");
}
}
char *build_o;
if (asprintf(&build_o, "%s.o",build_path) > 0) {
jl_dump_objfile(build_o,0);
Expand Down
4 changes: 4 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,7 @@ typedef struct {
int8_t code_coverage;
int8_t malloc_log;
int8_t check_bounds;
int8_t dumpbitcode;
int int_literals;
} jl_compileropts_t;

Expand All @@ -1340,6 +1341,9 @@ extern DLLEXPORT jl_compileropts_t jl_compileropts;
#define JL_COMPILEROPT_CHECK_BOUNDS_ON 1
#define JL_COMPILEROPT_CHECK_BOUNDS_OFF 2

#define JL_COMPILEROPT_DUMPBITCODE_ON 1
#define JL_COMPILEROPT_DUMPBITCODE_OFF 2

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 9 additions & 1 deletion ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static const char *opts =
" --track-allocation={none|user|all}\n"
" Count bytes allocated by each source line\n"
" --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)\n"
" --int-literals={32|64} Select integer literal size independent of platform\n";
" --int-literals={32|64} Select integer literal size independent of platform\n"
" --dump-bitcode={yes|no} Dump bitcode for the system image (used with --build)\n";

void parse_opts(int *argcp, char ***argvp)
{
Expand All @@ -96,6 +97,7 @@ void parse_opts(int *argcp, char ***argvp)
{ "track-allocation",required_argument, 0, 'm' },
{ "check-bounds", required_argument, 0, 300 },
{ "int-literals", required_argument, 0, 301 },
{ "dump-bitcode", required_argument, 0, 302 },
{ 0, 0, 0, 0 }
};
int c;
Expand Down Expand Up @@ -166,6 +168,12 @@ void parse_opts(int *argcp, char ***argvp)
exit(1);
}
break;
case 302:
if (!strcmp(optarg,"yes"))
jl_compileropts.dumpbitcode = JL_COMPILEROPT_DUMPBITCODE_ON;
else if (!strcmp(optarg,"no"))
jl_compileropts.dumpbitcode = JL_COMPILEROPT_DUMPBITCODE_OFF;
break;
default:
ios_printf(ios_stderr, "julia: unhandled option -- %c\n", c);
ios_printf(ios_stderr, "This is a bug, please report it.\n");
Expand Down

0 comments on commit aa9baa1

Please sign in to comment.