[PATCH v3 1/5] winegcc: Strip symbols before the make_wine_builtin call.

Rémi Bernon rbernon at codeweavers.com
Wed Oct 9 02:47:09 CDT 2019


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47718
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 tools/winegcc/winegcc.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 0ca553318eb..893ad1021ea 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -406,6 +406,10 @@ static strarray *get_link_args( struct options *opts, const char *output_name )
             strarray_add( flags, "-image_base" );
             strarray_add( flags, opts->image_base );
         }
+        /* On Mac, change -s into -Wl,-x. ld's -s switch
+         * is deprecated, and it doesn't work on Tiger with
+         * MH_BUNDLEs anyway
+         */
         if (opts->strip) strarray_add( flags, "-Wl,-x" );
         strarray_addall( link_args, flags );
         return link_args;
@@ -1250,9 +1254,21 @@ static void build(struct options* opts)
 
     if (libgcc) strarray_add(link_args, libgcc);
 
+    if (opts->target_platform != PLATFORM_APPLE && !is_pe && opts->strip)
+        strarray_add(link_args, "-s");
+
     spawn(opts->prefix, link_args, 0);
     strarray_free (link_args);
 
+    if (opts->target_platform != PLATFORM_APPLE && is_pe && opts->strip)
+    {
+        strarray *strip_args = strarray_fromstring(build_tool_name(opts, "strip", "strip"), " ");
+        strarray_add(strip_args, "--strip-all");
+        strarray_add(strip_args, output_path);
+        spawn(opts->prefix, strip_args, 1);
+        strarray_free(strip_args);
+    }
+
     if (is_pe && opts->wine_builtin) make_wine_builtin( output_path );
 
     /* set the base address with prelink if linker support is not present */
@@ -1626,12 +1642,8 @@ int main(int argc, char **argv)
 			opts.shared = 1;
                         raw_compiler_arg = raw_linker_arg = 0;
 		    }
-                    else if (strcmp("-s", argv[i]) == 0 && opts.target_platform == PLATFORM_APPLE)
+                    else if (strcmp("-s", argv[i]) == 0)
                     {
-                        /* On Mac, change -s into -Wl,-x. ld's -s switch
-                         * is deprecated, and it doesn't work on Tiger with
-                         * MH_BUNDLEs anyway
-                         */
                         opts.strip = 1;
                         raw_linker_arg = 0;
                     }
@@ -1666,6 +1678,11 @@ int main(int argc, char **argv)
                                 opts.wine_builtin = 1;
                                 continue;
                             }
+                            if (!strcmp(Wl->base[j], "--strip-all") || !strcmp(Wl->base[j], "-s"))
+                            {
+                                opts.strip = 1;
+                                continue;
+                            }
                             if (!strcmp(Wl->base[j], "--subsystem") && j < Wl->size - 1)
                             {
                                 opts.subsystem = strdup( Wl->base[++j] );
-- 
2.23.0




More information about the wine-devel mailing list