[PATCH 0/2] MR4908: tools: Fix support for Link-Time Optimization (LTO).
This makes some of the wine build tools handle LTO properly (when passed via CFLAGS/LDFLAGS in some way). Of course more work is needed for a successful build with LTO, but not that far fetched honestly (asm functions are the biggest issue, also because they can call "seemingly unused" C functions which have to be marked with the `used` attribute). But that's for other MRs not related to wine tools. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4908
From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> For Link-Time Optimization (LTO) it is required to use gcc-* prefixed utils (gcc-ar, gcc-ranlib, gcc-nm) to invoke the plugin properly, and since they're a superset of the standard utils, we can simply always use them if available. Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- tools/winebuild/import.c | 6 ++++-- tools/winebuild/utils.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 9325837b749..baac8786a98 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -1439,7 +1439,8 @@ void output_static_lib( const char *output_name, struct strarray files, int crea if (!create || target.platform != PLATFORM_WINDOWS) { - args = find_tool( "ar", NULL ); + static const char * const commands[] = { "gcc-ar", "ar", NULL }; + args = find_tool( "ar", commands ); strarray_add( &args, create ? "rc" : "r" ); strarray_add( &args, output_name ); } @@ -1457,7 +1458,8 @@ void output_static_lib( const char *output_name, struct strarray files, int crea if (target.platform != PLATFORM_WINDOWS) { - struct strarray ranlib = find_tool( "ranlib", NULL ); + static const char * const commands[] = { "gcc-ranlib", "ranlib", NULL }; + struct strarray ranlib = find_tool( "ranlib", commands ); strarray_add( &ranlib, output_name ); spawn( ranlib ); } diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 9f51a60c01f..91d83fd6ba4 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -389,7 +389,7 @@ const char *get_nm_command(void) { if (!nm_command.count) { - static const char * const commands[] = { "nm", "gnm", NULL }; + static const char * const commands[] = { "gcc-nm", "nm", "gnm", NULL }; nm_command = find_tool( "nm", commands ); } if (nm_command.count > 1) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4908
From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> -ffat-lto-objects wasn't included since it's not necessary for linking. Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- tools/winegcc/winegcc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 56fe179c92b..d8e13c80bbb 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -1633,6 +1633,13 @@ int main(int argc, char **argv) opts.pic = 1; else if (!strcmp("-fno-PIC", opts.args.str[i]) || !strcmp("-fno-pic", opts.args.str[i])) opts.pic = 0; + /* LTO options are available for both the compiler and the linker */ + else if ((!strncmp("-flto", opts.args.str[i], 5) && (!opts.args.str[i][5] || opts.args.str[i][5] == '=')) || !strcmp("-fno-lto", opts.args.str[i])) + raw_linker_arg = 1; + else if (!strncmp("-flto-partition=", opts.args.str[i], 16)) + raw_linker_arg = 1; + else if (!strcmp("-fuse-linker-plugin", opts.args.str[i]) || !strcmp("-fno-use-linker-plugin", opts.args.str[i])) + raw_linker_arg = 1; break; case 'i': if (!strcmp( "-isysroot", opts.args.str[i] )) opts.isysroot = opts.args.str[i + 1]; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4908
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=142290 Your paranoid android. === debian11b (64 bit WoW report) === mf: Unhandled exception: divide by zero in 64-bit code (0x0000000042e22c).
Is there anything I should do here? For someone unfamiliar with the tools build system (i.e. me before this MR), it's extremely infuriating to debug such issues because it's completely "silent". The make commands show "winegcc" for instance being used, you expect it to pass all options properly if you have them in CFLAGS/LDFLAGS (or the CROSS variants), etc. I was surprised at how much it needs to inspect. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4908#note_58846
participants (2)
-
Gabriel Ivăncescu -
Marvin