[PATCH 0/3] MR10070: build: Propagate configured cross compiler to winegcc and winebuild.
Although we allow configuring `<target>_CC` variables to select a specific compiler for compilation, this is not currently propagated to winegcc or winebuild. As a result, linking and creation of static or import libraries uses default tools found on the PATH instead. My main use case is cross-compiling with a specific LLVM build without modifying PATH. With this change, it is enough to pass `--with-mingw=/path/to/clang`. Because we use clang to locate other tools like llvm-dlltool or llvm-ar via -print-prog-name, the rest of the LLVM toolchain from that path is picked up as well. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10070
From: Jacek Caban <jacek@codeweavers.com> Similar to how we check for in case of clang from the PATH. --- tools/winebuild/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 1f0cde60bf9..5492de99c90 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -227,7 +227,11 @@ struct strarray find_tool( const char *name, const char * const *names ) names++; } - if (!file && cc_command.count) file = find_clang_tool( cc_command, name ); + if (!file && cc_command.count) + { + file = find_clang_tool( cc_command, strmake( "llvm-%s", name )); + if (!file) file = find_clang_tool( cc_command, name ); + } if (!file) file = find_binary( "llvm", name ); if (!file) file = find_clang_tool( empty_strarray, strmake( "llvm-%s", name )); if (!file) file = find_clang_tool( empty_strarray, name ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10070
From: Jacek Caban <jacek@codeweavers.com> Similar to winebuild's --cc-cmd option. --- tools/winegcc/winegcc.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index b3cfa15fabc..3ce6ed1ee4f 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -151,6 +151,7 @@ struct strarray temp_files = { 0 }; static const char *bindir; static const char *libdir; static const char *includedir; +static const char *cc_cmd; static const char *wine_objdir; static const char *winebuild; static const char *lib_suffix; @@ -403,11 +404,30 @@ static const struct tool_names tool_cpp = { "cpp", "clang --driver-mode= static const struct tool_names tool_ld = { "ld", "ld.lld", LD }; static const struct tool_names tool_objcopy = { "objcopy", "llvm-objcopy" }; +static void add_clang_options( const char *target_name, struct strarray *ret ) +{ + if (target_name) + { + strarray_add( ret, "-target" ); + strarray_add( ret, target_name ); + } + strarray_add( ret, "-Wno-unused-command-line-argument" ); + strarray_add( ret, "-fuse-ld=lld" ); + if (no_default_config) strarray_add( ret, "--no-default-config" ); +} + static struct strarray build_tool_name( const char *target_name, struct tool_names tool ) { const char *path, *str; struct strarray ret; + if (cc_cmd && !strncmp( tool.llvm_base, "clang", 5 )) + { + ret = strarray_fromstring( cc_cmd, " " ); + if (target.platform == PLATFORM_WINDOWS) add_clang_options( target_name, &ret ); + return ret; + } + if (target_name && target_version) str = strmake( "%s-%s-%s", target_name, tool.base, target_version ); else if (target_name) @@ -427,17 +447,7 @@ static struct strarray build_tool_name( const char *target_name, struct tool_nam if (!(path = find_binary( str ))) error( "Could not find %s\n", tool.base ); ret = strarray_fromstring( path, " " ); - if (!strncmp( tool.llvm_base, "clang", 5 )) - { - if (target_name) - { - strarray_add( &ret, "-target" ); - strarray_add( &ret, target_name ); - } - strarray_add( &ret, "-Wno-unused-command-line-argument" ); - strarray_add( &ret, "-fuse-ld=lld" ); - if (no_default_config) strarray_add( &ret, "--no-default-config" ); - } + if (!strncmp( tool.llvm_base, "clang", 5 )) add_clang_options( target_name, &ret ); return ret; } @@ -1684,7 +1694,8 @@ int main(int argc, char **argv) next_is_arg = strcmp("-target", args.str[i]) == 0; break; case '-': - next_is_arg = (strcmp("--param", args.str[i]) == 0 || + next_is_arg = (strcmp("--cc-cmd", args.str[i]) == 0 || + strcmp("--param", args.str[i]) == 0 || strcmp("--sysroot", args.str[i]) == 0 || strcmp("--target", args.str[i]) == 0 || strcmp("--wine-objdir", args.str[i]) == 0 || @@ -1970,6 +1981,11 @@ int main(int argc, char **argv) no_default_config = true; raw_compiler_arg = raw_linker_arg = 1; } + else if (is_option( args, i, "--cc-cmd", &option_arg )) + { + cc_cmd = option_arg; + raw_compiler_arg = raw_linker_arg = 0; + } else if (is_option( args, i, "--sysroot", &option_arg )) { sysroot = option_arg; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10070
From: Jacek Caban <jacek@codeweavers.com> --- tools/makedep.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/makedep.c b/tools/makedep.c index 3baf7d42547..b439d933b17 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -177,6 +177,7 @@ static const char *arch_dirs[MAX_ARCHS]; static const char *arch_pe_dirs[MAX_ARCHS]; static const char *arch_install_dirs[MAX_ARCHS]; static const char *strip_progs[MAX_ARCHS]; +static const char *cc_cmds[MAX_ARCHS]; static const char *delay_load_flags[MAX_ARCHS]; static struct strarray debug_flags[MAX_ARCHS]; static struct strarray target_flags[MAX_ARCHS]; @@ -2723,6 +2724,7 @@ static void output_winegcc_command( struct makefile *make, unsigned int arch ) output_filename( "--winebuild" ); output_filename( winebuild ); } + if (cc_cmds[arch]) output_filename( cc_cmds[arch] ); output_filenames( target_flags[arch] ); if (native_archs[arch] && !make->disabled[native_archs[arch]]) output_filenames( hybrid_target_flags[arch] ); @@ -3814,6 +3816,7 @@ static void output_import_lib( struct makefile *make, unsigned int arch ) if (hybrid_arch) output_filenames_obj_dir( make, make->implib_files[hybrid_arch] ); output( "\n" ); output( "\t%s%s -w --implib -o $@", cmd_prefix( "BUILD" ), winebuild ); + if (cc_cmds[arch]) output_filename( cc_cmds[arch] ); if (!delay_load_flags[arch]) output_filename( "--without-dlltool" ); output_filenames( target_flags[hybrid_arch ? hybrid_arch : arch] ); if (make->is_win16) output_filename( "-m16" ); @@ -3874,6 +3877,7 @@ static void output_static_lib( struct makefile *make, unsigned int arch ) if (!arch) output_filenames_obj_dir( make, make->unixobj_files ); output( "\n" ); output( "\t%s%s -w --staticlib -o $@", cmd_prefix( "BUILD" ), winebuild ); + if (cc_cmds[arch]) output_filename( cc_cmds[arch] ); output_filenames( target_flags[hybrid_arch ? hybrid_arch : arch] ); output_filenames_obj_dir( make, make->object_files[arch] ); if (hybrid_arch) output_filenames_obj_dir( make, make->object_files[hybrid_arch] ); @@ -4945,6 +4949,7 @@ int main( int argc, char *argv[] ) if (!is_multiarch( arch )) continue; delay_load_flags[arch] = get_expanded_arch_var( top_makefile, "DELAYLOADFLAG", arch ); debug_flags[arch] = get_expanded_arch_var_array( top_makefile, "DEBUG", arch ); + cc_cmds[arch] = strmake( "--cc-cmd=\"%s\"", get_expanded_arch_var( top_makefile, "CC", arch )); } if (unix_lib_supported) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10070
participants (2)
-
Jacek Caban -
Jacek Caban (@jacek)