From: Brendan Shanks bshanks@codeweavers.com
macOS has conflicting TOOL_ defines in <mach-o/loader.h>. --- tools/winegcc/winegcc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 600bd171b89..5516ca196c3 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -236,11 +236,11 @@ static int is_pe_target( const struct options *opts )
enum tool { - TOOL_CC, - TOOL_CXX, - TOOL_CPP, - TOOL_LD, - TOOL_OBJCOPY, + WINEGCC_TOOL_CC, + WINEGCC_TOOL_CXX, + WINEGCC_TOOL_CPP, + WINEGCC_TOOL_LD, + WINEGCC_TOOL_OBJCOPY, };
static const struct @@ -312,12 +312,12 @@ static struct strarray get_translator(struct options *opts) switch(opts->processor) { case proc_cpp: - return build_tool_name( opts, opts->target_alias, TOOL_CPP ); + return build_tool_name( opts, opts->target_alias, WINEGCC_TOOL_CPP ); case proc_cc: case proc_as: - return build_tool_name( opts, opts->target_alias, TOOL_CC ); + return build_tool_name( opts, opts->target_alias, WINEGCC_TOOL_CC ); case proc_cxx: - return build_tool_name( opts, opts->target_alias, TOOL_CXX ); + return build_tool_name( opts, opts->target_alias, WINEGCC_TOOL_CXX ); } assert(0); return empty_strarray; @@ -639,8 +639,8 @@ static void compile(struct options* opts, const char* lang) /* mixing different C and C++ compilers isn't supported in configure anyway */ case proc_cc: case proc_cxx: - gcc = build_tool_name( opts, opts->target_alias, TOOL_CC ); - gpp = build_tool_name( opts, opts->target_alias, TOOL_CXX ); + gcc = build_tool_name( opts, opts->target_alias, WINEGCC_TOOL_CC ); + gpp = build_tool_name( opts, opts->target_alias, WINEGCC_TOOL_CXX ); for ( j = 0; !gcc_defs && j < comp_args.count; j++ ) { const char *cc = comp_args.str[j]; @@ -963,11 +963,11 @@ static void build_spec_obj( struct options *opts, const char *spec_file, const c /* get the filename from the path */ output_name = get_basename( output_file );
- tool = build_tool_name( opts, target, TOOL_CC ); + tool = build_tool_name( opts, target, WINEGCC_TOOL_CC ); strarray_add( &spec_args, strmake( "--cc-cmd=%s", strarray_tostring( tool, " " ))); if (!is_pe) { - tool = build_tool_name( opts, target, TOOL_LD ); + tool = build_tool_name( opts, target, WINEGCC_TOOL_LD ); strarray_add( &spec_args, strmake( "--ld-cmd=%s", strarray_tostring( tool, " " ))); }
@@ -1362,7 +1362,7 @@ static void build(struct options* opts)
if (opts->debug_file && !strendswith(opts->debug_file, ".pdb")) { - struct strarray tool, objcopy = build_tool_name(opts, opts->target_alias, TOOL_OBJCOPY); + struct strarray tool, objcopy = build_tool_name(opts, opts->target_alias, WINEGCC_TOOL_OBJCOPY);
tool = empty_strarray; strarray_addall( &tool, objcopy ); @@ -1393,9 +1393,9 @@ static void build(struct options* opts) error("--out-implib requires a .spec or .def file\n");
implib_args = get_winebuild_args( opts, opts->target_alias ); - tool = build_tool_name( opts, opts->target_alias, TOOL_CC ); + tool = build_tool_name( opts, opts->target_alias, WINEGCC_TOOL_CC ); strarray_add( &implib_args, strmake( "--cc-cmd=%s", strarray_tostring( tool, " " ))); - tool = build_tool_name( opts, opts->target_alias, TOOL_LD ); + tool = build_tool_name( opts, opts->target_alias, WINEGCC_TOOL_LD ); strarray_add( &implib_args, strmake( "--ld-cmd=%s", strarray_tostring( tool, " " )));
strarray_add(&implib_args, "--implib");
From: Brendan Shanks bshanks@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57874 --- tools/tools.h | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/tools/tools.h b/tools/tools.h index 319aff77da7..f017bab0e93 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -39,6 +39,9 @@ #ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> #endif +#ifdef __APPLE__ +# include <mach-o/dyld.h> +#endif
#ifdef _WIN32 # include <direct.h> @@ -705,6 +708,12 @@ static inline char *get_bindir( const char *argv0 ) if (!sysctl( pathname, ARRAY_SIZE(pathname), path, &path_size, NULL, 0 )) dir = realpath( path, NULL ); free( path ); +#elif defined(__APPLE__) + uint32_t path_size = PATH_MAX; + char *path = xmalloc( path_size ); + if (!_NSGetExecutablePath( path, &path_size )) + dir = realpath( path, NULL ); + free( path ); #endif if (!dir && !(dir = realpath( argv0, NULL ))) return NULL; return get_dirname( dir );
From: Brendan Shanks bshanks@codeweavers.com
--- server/unicode.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/server/unicode.c b/server/unicode.c index b4864310f83..bb39b55e50c 100644 --- a/server/unicode.c +++ b/server/unicode.c @@ -29,6 +29,9 @@ #ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> #endif +#ifdef __APPLE__ +# include <mach-o/dyld.h> +#endif
#include "windef.h" #include "winternl.h" @@ -290,6 +293,17 @@ static char *get_nls_dir(void) dir = NULL; } } +#elif defined(__APPLE__) + uint32_t dir_size = PATH_MAX; + dir = malloc( dir_size ); + if (dir) + { + if (_NSGetExecutablePath( dir, &dir_size )) + { + free( dir ); + dir = NULL; + } + } #else dir = realpath( server_argv0, NULL ); #endif
From: Brendan Shanks bshanks@codeweavers.com
--- loader/main.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/loader/main.c b/loader/main.c index 3467d29cb5c..f8b113f3136 100644 --- a/loader/main.c +++ b/loader/main.c @@ -34,6 +34,9 @@ #ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> #endif +#ifdef __APPLE__ +# include <mach-o/dyld.h> +#endif
#include "main.h"
@@ -134,6 +137,12 @@ static const char *get_self_exe(void) if (path && !sysctl( pathname, sizeof(pathname)/sizeof(pathname[0]), path, &path_size, NULL, 0 )) return path; free( path ); +#elif defined(__APPLE__) + uint32_t path_size = PATH_MAX; + char *path = malloc( path_size ); + if (path && !_NSGetExecutablePath( path, &path_size )) + return path; + free( path ); #endif return NULL; }
Did some quick testing and that seems to resolve the bug