From: Jacek Caban Subject: [PATCH 1/4] winegcc: Add new -delayload argument. Message-Id: <11f37734-dee7-53f7-66ed-bda638726394@codeweavers.com> Date: Mon, 7 Oct 2019 18:51:04 +0200 With syntax inspired by LLD: https://reviews.llvm.org/D65728 Signed-off-by: Jacek Caban --- tools/winegcc/winegcc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index fa4407f913..60e5e60ab8 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -226,6 +226,7 @@ struct options strarray* compiler_args; strarray* winebuild_args; strarray* files; + strarray* delayloads; }; #ifdef __i386__ @@ -1164,6 +1165,17 @@ static void build(struct options* opts) for ( j = 0 ; j < opts->winebuild_args->size ; j++ ) strarray_add(spec_args, opts->winebuild_args->base[j]); + if (!is_pe) + { + for (j = 0; j < opts->delayloads->size; j++) + { + char *module = xstrdup(opts->delayloads->base[j]), *p; + if ((p = strrchr(module, '.')) && !strcmp(p, ".dll")) *p = 0; + strarray_add(spec_args, strmake("-d%s", module)); + free(module); + } + } + /* add resource files */ for ( j = 0; j < files->size; j++ ) if (files->base[j][1] == 'r') strarray_add(spec_args, files->base[j]); @@ -1423,6 +1435,7 @@ int main(int argc, char **argv) opts.linker_args = strarray_alloc(); opts.compiler_args = strarray_alloc(); opts.winebuild_args = strarray_alloc(); + opts.delayloads = strarray_alloc(); opts.pic = 1; /* determine the processor type */ @@ -1672,6 +1685,11 @@ int main(int argc, char **argv) opts.subsystem = strdup( Wl->base[++j] ); continue; } + if (!strcmp(Wl->base[j], "-delayload") && j < Wl->size - 1) + { + strarray_add( opts.delayloads, Wl->base[++j] ); + continue; + } if (!strcmp(Wl->base[j], "-static")) linking = -1; strarray_add(opts.linker_args, strmake("-Wl,%s",Wl->base[j])); }