Commit 9faa5eed authored by Kevin Puetz's avatar Kevin Puetz Committed by Alexandre Julliard

winegcc: Implement -Wl,--out-implib.

This allows a CMake toolchain (or other caller) to treat winegcc like MinGW, specifying that it produce a separate file for imports, e.g. set(CMAKE_IMPORT_LIBRARY_PREFIX lib) set(CMAKE_IMPORT_LIBRARY_SUFFIX .a) string(APPEND CMAKE_C_CREATE_SHARED_LIBRARY " -Wl,--out-implib,<TARGET_IMPLIB>") Signed-off-by: 's avatarKevin Puetz <PuetzKevinA@JohnDeere.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 32524883
...@@ -141,6 +141,7 @@ static const char* app_loader_template = ...@@ -141,6 +141,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 const char *output_debug_file;
static const char *output_implib;
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
...@@ -231,6 +232,7 @@ struct options ...@@ -231,6 +232,7 @@ struct options
const char* entry_point; const char* entry_point;
const char* prelink; const char* prelink;
const char* debug_file; const char* debug_file;
const char* out_implib;
strarray* prefix; strarray* prefix;
strarray* lib_dirs; strarray* lib_dirs;
strarray* args; strarray* args;
...@@ -273,6 +275,7 @@ static void cleanup_output_files(void) ...@@ -273,6 +275,7 @@ 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 ); if (output_debug_file) unlink( output_debug_file );
if (output_implib) unlink( output_implib );
} }
static void clean_temp_files(void) static void clean_temp_files(void)
...@@ -522,6 +525,9 @@ static strarray *get_link_args( struct options *opts, const char *output_name ) ...@@ -522,6 +525,9 @@ static strarray *get_link_args( struct options *opts, const char *output_name )
if (opts->debug_file && strendswith(opts->debug_file, ".pdb")) if (opts->debug_file && strendswith(opts->debug_file, ".pdb"))
strarray_add(link_args, strmake("-Wl,-pdb,%s", opts->debug_file)); strarray_add(link_args, strmake("-Wl,-pdb,%s", opts->debug_file));
if (opts->out_implib)
strarray_add(link_args, strmake("-Wl,--out-implib,%s", opts->out_implib));
if (!try_link( opts->prefix, link_args, "-Wl,--file-alignment,0x1000" )) if (!try_link( opts->prefix, link_args, "-Wl,--file-alignment,0x1000" ))
strarray_add( link_args, strmake( "-Wl,--file-alignment,%s", strarray_add( link_args, strmake( "-Wl,--file-alignment,%s",
opts->file_align ? opts->file_align : "0x1000" )); opts->file_align ? opts->file_align : "0x1000" ));
...@@ -554,6 +560,10 @@ static strarray *get_link_args( struct options *opts, const char *output_name ) ...@@ -554,6 +560,10 @@ static strarray *get_link_args( struct options *opts, const char *output_name )
strarray_add(link_args, "-Wl,-debug"); strarray_add(link_args, "-Wl,-debug");
strarray_add(link_args, strmake("-Wl,-pdb:%s", opts->debug_file)); strarray_add(link_args, strmake("-Wl,-pdb:%s", opts->debug_file));
} }
if (opts->out_implib)
strarray_add(link_args, strmake("-Wl,-implib:%s", opts->out_implib));
else if (!opts->strip) else if (!opts->strip)
strarray_add(link_args, "-Wl,-debug:dwarf"); strarray_add(link_args, "-Wl,-debug:dwarf");
strarray_add( link_args, strmake( "-Wl,-filealign:%s", opts->file_align ? opts->file_align : "0x1000" )); strarray_add( link_args, strmake( "-Wl,-filealign:%s", opts->file_align ? opts->file_align : "0x1000" ));
...@@ -1085,7 +1095,7 @@ static void add_library( struct options *opts, strarray *lib_dirs, strarray *fil ...@@ -1085,7 +1095,7 @@ static void add_library( struct options *opts, strarray *lib_dirs, strarray *fil
static void build(struct options* opts) static void build(struct options* opts)
{ {
strarray *lib_dirs, *files; strarray *lib_dirs, *files;
strarray *spec_args, *link_args, *tool; strarray *spec_args, *link_args, *implib_args, *tool;
char *output_file, *output_path; char *output_file, *output_path;
const char *spec_o_name, *libgcc = NULL; const char *spec_o_name, *libgcc = NULL;
const char *output_name, *spec_file, *lang; const char *output_name, *spec_file, *lang;
...@@ -1430,6 +1440,7 @@ static void build(struct options* opts) ...@@ -1430,6 +1440,7 @@ static void build(struct options* opts)
output_file_name = output_path; output_file_name = output_path;
output_debug_file = opts->debug_file; output_debug_file = opts->debug_file;
output_implib = opts->out_implib;
atexit( cleanup_output_files ); atexit( cleanup_output_files );
spawn(opts->prefix, link_args, 0); spawn(opts->prefix, link_args, 0);
...@@ -1460,6 +1471,26 @@ static void build(struct options* opts) ...@@ -1460,6 +1471,26 @@ static void build(struct options* opts)
strarray_free(tool); strarray_free(tool);
} }
if (opts->out_implib && !is_pe)
{
if (!spec_file)
error("--out-implib requires a .spec or .def file\n");
implib_args = get_winebuild_args( opts );
if ((tool = build_tool_name( opts, TOOL_CC ))) strarray_add( implib_args, strmake( "--cc-cmd=%s", strarray_tostring( tool, " " )));
if ((tool = build_tool_name( opts, TOOL_LD ))) strarray_add( implib_args, strmake( "--ld-cmd=%s", strarray_tostring( tool, " " )));
strarray_add(implib_args, "--implib");
strarray_add(implib_args, "-o");
strarray_add(implib_args, opts->out_implib);
strarray_add(implib_args, "--export");
strarray_add(implib_args, spec_file);
strarray_addall(implib_args, opts->winebuild_args);
spawn(opts->prefix, implib_args, 0);
strarray_free (implib_args);
}
/* 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)
{ {
...@@ -1972,6 +2003,11 @@ int main(int argc, char **argv) ...@@ -1972,6 +2003,11 @@ int main(int argc, char **argv)
strarray_add( opts.files, strmake( "-Wl,%s", Wl->base[j] )); strarray_add( opts.files, strmake( "-Wl,%s", Wl->base[j] ));
continue; continue;
} }
if (!strcmp(Wl->base[j], "--out-implib"))
{
opts.out_implib = 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]));
} }
...@@ -2056,5 +2092,6 @@ int main(int argc, char **argv) ...@@ -2056,5 +2092,6 @@ int main(int argc, char **argv)
output_file_name = NULL; output_file_name = NULL;
output_debug_file = NULL; output_debug_file = NULL;
output_implib = NULL;
return 0; return 0;
} }
...@@ -72,6 +72,8 @@ Do not add the winecrt0 library when linking. ...@@ -72,6 +72,8 @@ Do not add the winecrt0 library when linking.
.IP \fB-Wb,\fIoption\fR .IP \fB-Wb,\fIoption\fR
Pass an option to winebuild. If \fIoption\fR contains Pass an option to winebuild. If \fIoption\fR contains
commas, it is split into multiple options at the commas. commas, it is split into multiple options at the commas.
.IP \fB-Wl,--out-implib,\fIlib.a\fR
When linking a dll, also create its corresponding import library.
.SH ENVIRONMENT .SH ENVIRONMENT
.TP .TP
.B WINEBUILD .B WINEBUILD
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment