winegcc: Introduce --debug-file option for generating separated symbol files.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f02b0226ca
commit
942e298308
|
@ -140,6 +140,7 @@ static const char* app_loader_template =
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char *output_file_name;
|
static const char *output_file_name;
|
||||||
|
static const char *output_debug_file;
|
||||||
static int keep_generated = 0;
|
static int keep_generated = 0;
|
||||||
static strarray* tmp_files;
|
static strarray* tmp_files;
|
||||||
#ifdef HAVE_SIGSET_T
|
#ifdef HAVE_SIGSET_T
|
||||||
|
@ -227,6 +228,7 @@ struct options
|
||||||
const char* subsystem;
|
const char* subsystem;
|
||||||
const char* entry_point;
|
const char* entry_point;
|
||||||
const char* prelink;
|
const char* prelink;
|
||||||
|
const char* debug_file;
|
||||||
strarray* prefix;
|
strarray* prefix;
|
||||||
strarray* lib_dirs;
|
strarray* lib_dirs;
|
||||||
strarray* linker_args;
|
strarray* linker_args;
|
||||||
|
@ -267,6 +269,7 @@ static enum target_platform build_platform = PLATFORM_UNSPECIFIED;
|
||||||
static void cleanup_output_files(void)
|
static void cleanup_output_files(void)
|
||||||
{
|
{
|
||||||
if (output_file_name) unlink( output_file_name );
|
if (output_file_name) unlink( output_file_name );
|
||||||
|
if (output_debug_file) unlink( output_debug_file );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clean_temp_files(void)
|
static void clean_temp_files(void)
|
||||||
|
@ -321,6 +324,7 @@ enum tool
|
||||||
TOOL_CXX,
|
TOOL_CXX,
|
||||||
TOOL_CPP,
|
TOOL_CPP,
|
||||||
TOOL_LD,
|
TOOL_LD,
|
||||||
|
TOOL_OBJCOPY,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
|
@ -330,10 +334,11 @@ static const struct
|
||||||
const char *deflt;
|
const char *deflt;
|
||||||
} tool_names[] =
|
} tool_names[] =
|
||||||
{
|
{
|
||||||
{ "gcc", "clang --driver-mode=gcc", CC },
|
{ "gcc", "clang --driver-mode=gcc", CC },
|
||||||
{ "g++", "clang --driver-mode=g++", CXX },
|
{ "g++", "clang --driver-mode=g++", CXX },
|
||||||
{ "cpp", "clang --driver-mode=cpp", CPP },
|
{ "cpp", "clang --driver-mode=cpp", CPP },
|
||||||
{ "ld", "ld.lld", LD },
|
{ "ld", "ld.lld", LD },
|
||||||
|
{ "objcopy", "llvm-objcopy" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static strarray* build_tool_name( struct options *opts, enum tool tool )
|
static strarray* build_tool_name( struct options *opts, enum tool tool )
|
||||||
|
@ -358,7 +363,7 @@ static strarray* build_tool_name( struct options *opts, enum tool tool )
|
||||||
str = strmake("%s-%s", base, opts->version);
|
str = strmake("%s-%s", base, opts->version);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str = xstrdup(deflt);
|
str = xstrdup((deflt && *deflt) ? deflt : base);
|
||||||
|
|
||||||
if ((path = find_binary( opts->prefix, str ))) return strarray_fromstring( path, " " );
|
if ((path = find_binary( opts->prefix, str ))) return strarray_fromstring( path, " " );
|
||||||
|
|
||||||
|
@ -511,6 +516,9 @@ static strarray *get_link_args( struct options *opts, const char *output_name )
|
||||||
/* make sure we don't need a libgcc_s dll on Windows */
|
/* make sure we don't need a libgcc_s dll on Windows */
|
||||||
strarray_add( flags, "-static-libgcc" );
|
strarray_add( flags, "-static-libgcc" );
|
||||||
|
|
||||||
|
if (opts->debug_file && strendswith(opts->debug_file, ".pdb"))
|
||||||
|
strarray_add(link_args, strmake("-Wl,-pdb,%s", opts->debug_file));
|
||||||
|
|
||||||
strarray_addall( link_args, flags );
|
strarray_addall( link_args, flags );
|
||||||
return link_args;
|
return link_args;
|
||||||
|
|
||||||
|
@ -529,6 +537,14 @@ static strarray *get_link_args( struct options *opts, const char *output_name )
|
||||||
else
|
else
|
||||||
strarray_add( flags, strmake("-Wl,-subsystem:%s", opts->gui_app ? "windows" : "console" ));
|
strarray_add( flags, strmake("-Wl,-subsystem:%s", opts->gui_app ? "windows" : "console" ));
|
||||||
|
|
||||||
|
if (opts->debug_file && strendswith(opts->debug_file, ".pdb"))
|
||||||
|
{
|
||||||
|
strarray_add(link_args, "-Wl,-debug");
|
||||||
|
strarray_add(link_args, strmake("-Wl,-pdb:%s", opts->debug_file));
|
||||||
|
}
|
||||||
|
else if (!opts->strip)
|
||||||
|
strarray_add(link_args, "-Wl,-debug:dwarf");
|
||||||
|
|
||||||
strarray_addall( link_args, flags );
|
strarray_addall( link_args, flags );
|
||||||
return link_args;
|
return link_args;
|
||||||
|
|
||||||
|
@ -1388,11 +1404,37 @@ static void build(struct options* opts)
|
||||||
if (libgcc) strarray_add(link_args, libgcc);
|
if (libgcc) strarray_add(link_args, libgcc);
|
||||||
|
|
||||||
output_file_name = output_path;
|
output_file_name = output_path;
|
||||||
|
output_debug_file = opts->debug_file;
|
||||||
atexit( cleanup_output_files );
|
atexit( cleanup_output_files );
|
||||||
|
|
||||||
spawn(opts->prefix, link_args, 0);
|
spawn(opts->prefix, link_args, 0);
|
||||||
strarray_free (link_args);
|
strarray_free (link_args);
|
||||||
|
|
||||||
|
if (opts->debug_file && !strendswith(opts->debug_file, ".pdb"))
|
||||||
|
{
|
||||||
|
strarray *tool, *objcopy = build_tool_name(opts, TOOL_OBJCOPY);
|
||||||
|
|
||||||
|
tool = strarray_dup(objcopy);
|
||||||
|
strarray_add(tool, "--only-keep-debug");
|
||||||
|
strarray_add(tool, output_path);
|
||||||
|
strarray_add(tool, opts->debug_file);
|
||||||
|
spawn(opts->prefix, tool, 1);
|
||||||
|
strarray_free(tool);
|
||||||
|
|
||||||
|
tool = strarray_dup(objcopy);
|
||||||
|
strarray_add(tool, "--strip-debug");
|
||||||
|
strarray_add(tool, output_path);
|
||||||
|
spawn(opts->prefix, tool, 1);
|
||||||
|
strarray_free(tool);
|
||||||
|
|
||||||
|
tool = objcopy;
|
||||||
|
strarray_add(tool, "--add-gnu-debuglink");
|
||||||
|
strarray_add(tool, opts->debug_file);
|
||||||
|
strarray_add(tool, output_path);
|
||||||
|
spawn(opts->prefix, tool, 0);
|
||||||
|
strarray_free(tool);
|
||||||
|
}
|
||||||
|
|
||||||
/* set the base address with prelink if linker support is not present */
|
/* set the base address with prelink if linker support is not present */
|
||||||
if (opts->prelink && !opts->target)
|
if (opts->prelink && !opts->target)
|
||||||
{
|
{
|
||||||
|
@ -1843,6 +1885,11 @@ int main(int argc, char **argv)
|
||||||
strarray_add( opts.delayimports, Wl->base[++j] );
|
strarray_add( opts.delayimports, Wl->base[++j] );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(Wl->base[j], "--debug-file") && j < Wl->size - 1)
|
||||||
|
{
|
||||||
|
opts.debug_file = strdup( Wl->base[++j] );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(Wl->base[j], "-static")) linking = -1;
|
if (!strcmp(Wl->base[j], "-static")) linking = -1;
|
||||||
strarray_add(opts.linker_args, strmake("-Wl,%s",Wl->base[j]));
|
strarray_add(opts.linker_args, strmake("-Wl,%s",Wl->base[j]));
|
||||||
}
|
}
|
||||||
|
@ -1926,5 +1973,6 @@ int main(int argc, char **argv)
|
||||||
else compile(&opts, lang);
|
else compile(&opts, lang);
|
||||||
|
|
||||||
output_file_name = NULL;
|
output_file_name = NULL;
|
||||||
|
output_debug_file = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue