When cross-compiling on macOS, like building on ARM64 to target x86_64 [1], `make install` would fail with `winebuild: cannot find the 'ar' tool`. `winebuild` was looking for `x86_64-apple-darwin-ar`, but macOS does not install prefixed tools. As a last step before failing in `find_tool()`, search for the un-prefixed tool name.
[1]: with a `configure` invocation like: `../configure --enable-archs=i386,x86_64 --host=x86_64-apple-darwin CC="clang -arch x86_64"`
-- v2: winebuild: As a last resort, search for tools un-prefixed using clang. winebuild: Refactor find_tool().
From: Brendan Shanks bshanks@codeweavers.com
--- tools/winebuild/utils.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 9f51a60c01f..0f81832bd68 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -243,15 +243,17 @@ 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) + file = find_binary( "llvm", name ); + if (!file) { - if (cc_command.count) file = find_clang_tool( cc_command, name ); - if (!file && !(file = find_binary( "llvm", name ))) - { - struct strarray clang = empty_strarray; - strarray_add( &clang, "clang" ); - file = find_clang_tool( clang, strmake( "llvm-%s", name )); - } + struct strarray clang = empty_strarray; + strarray_add( &clang, "clang" ); + file = find_clang_tool( clang, strmake( "llvm-%s", name )); } if (!file) fatal_error( "cannot find the '%s' tool\n", name );
From: Brendan Shanks bshanks@codeweavers.com
--- tools/winebuild/utils.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 0f81832bd68..11fa33f27d9 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -254,6 +254,8 @@ struct strarray find_tool( const char *name, const char * const *names ) struct strarray clang = empty_strarray; strarray_add( &clang, "clang" ); file = find_clang_tool( clang, strmake( "llvm-%s", name )); + if (!file) + file = find_clang_tool( clang, name ); } if (!file) fatal_error( "cannot find the '%s' tool\n", name );
On Tue Jan 30 19:29:00 2024 +0000, Jacek Caban wrote:
Maybe we should just always pass `--cc-cmd` to winebuild. This would allow `find_clang_tool` to work. We could also, as a last resort, search for `clang` and use that for `find_clang_tool` instead of limiting that code path to explicitly passed compiler.
Thanks for the comments, I pushed a new version that does the 2nd option