<div dir="ltr">This seems strange to me as I don't get this issue. Could this be related to a newer version of Apple cctools/Xcode?, could you give an example of what you attempt to run and get an issue with not finding ntdll.so?<br><div><br></div><div><br></div><div>The following make sense to keep for general usage on macOS, this would save the macOS specific step of fixing the libraries install_name.</div><div><br></div><div>diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c<br>index 426336e4536..0a72e6fbe49 100644<br>--- a/tools/winegcc/winegcc.c<br>+++ b/tools/winegcc/winegcc.c<br>@@ -492,6 +492,11 @@ static strarray *get_link_args( struct options *opts, const char *output_name )<br>             strarray_add( flags, opts->image_base );<br>         }<br>         if (opts->strip) strarray_add( flags, "-Wl,-x" );<br>+        if (opts->unix_lib)<br>+        {<br>+            strarray_add( flags, "-install_name" );<br>+            strarray_add( flags, strmake( "@rpath/%s.so", output_name ) );<br>+        }<br>         strarray_addall( link_args, flags );<br>         return link_args;<br><font color="#888888"><br></font>For the injecting LDFLAGS it would be better to add for example UNIX_LDFLAGS so any specific linker flags can be passed only for the unix libraries.<font color="#888888"><br></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 20, 2021 at 8:23 AM Huw Davies <<a href="mailto:huw@codeweavers.com">huw@codeweavers.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On macOS unixlibs that link to ntdll.so currently fail to load.<br>
It appears the macOS loader needs to be able to locate the file<br>
even if the library is already loaded.<br>
<br>
This patch changes the LC_ID_DYLIB name of ntdll.so to<br>
"@rpath/ntdll.so" so that when other unixlibs link against this they<br>
will insert that name into their LC_LOAD_DYLIB entry for ntdll.so.<br>
<br>
The patch also adds LC_RPATH entries for both @loader_path/ (running<br>
from installed tree) and @loader_path/../ntdll/ (running from build<br>
tree).<br>
<br>
Although it's only required to explicitly change ntdll.so's<br>
LC_ID_DYLIB and to only add LC_RPATHs to unixlibs that load ntdll.so,<br>
it seems simpler to do the same for all unixlibs, which is what this<br>
patch does.<br>
<br>
Signed-off-by: Huw Davies <<a href="mailto:huw@codeweavers.com" target="_blank">huw@codeweavers.com</a>><br>
---<br>
I'm not exactly happy with this patch, so any other ideas would be appreciated.<br>
 tools/winegcc/winegcc.c | 7 +++++++<br>
 1 file changed, 7 insertions(+)<br>
<br>
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c<br>
index 426336e4536..0a72e6fbe49 100644<br>
--- a/tools/winegcc/winegcc.c<br>
+++ b/tools/winegcc/winegcc.c<br>
@@ -492,6 +492,13 @@ static strarray *get_link_args( struct options *opts, const char *output_name )<br>
             strarray_add( flags, opts->image_base );<br>
         }<br>
         if (opts->strip) strarray_add( flags, "-Wl,-x" );<br>
+        if (opts->unix_lib)<br>
+        {<br>
+            strarray_add( flags, "-install_name" );<br>
+            strarray_add( flags, strmake( "@rpath/%s.so", output_name ) );<br>
+            strarray_add( flags, "-Wl,-rpath,@loader_path/" );<br>
+            strarray_add( flags, "-Wl,-rpath,@loader_path/../ntdll/" );<br>
+        }<br>
         strarray_addall( link_args, flags );<br>
         return link_args;<br>
<br>
-- <br>
2.23.0<br>
<br>
<br>
</blockquote></div>