Skip to content

Use the strip command detected by libtool#13282

Merged
dra27 merged 2 commits intoocaml:trunkfrom
shym:libtool-strip
Jul 16, 2024
Merged

Use the strip command detected by libtool#13282
dra27 merged 2 commits intoocaml:trunkfrom
shym:libtool-strip

Conversation

@shym
Copy link
Copy Markdown
Contributor

@shym shym commented Jul 5, 2024

This PR proposes to use the strip command detected by libtool during configure so that it is replaced with : when the command is absent and it becomes easy to override it if need be, such as in cross-compilation cases.
It also proposes to strip tmpheader.exe also on Windows, as it seems that GNU strip can be called safely on binaries generated by cl as well as by MinGW GCC (even if it doesn't produce a smaller executable for cl-generated binaries).

Using GNU strip 2.42 on a basic hello-world example, I get:

size (bytes) executable generated with
143360 hello.cl.exe cl
143360 hello.cl.strip.exe cl, stripped
647168 hello.clZi.exe cl with /Zi
647168 hello.clZi.strip.exe cl with /Zi, stripped
143360 hello.clangcl.exe clang-cl
143360 hello.clangcl.strip.exe clang-cl, stripped
651264 hello.clangclZi.exe clang-cl with /Zi
651264 hello.clangclZi.strip.exe clang-cl with /Zi, stripped
258048 hello.mingw.exe MinGW gcc
40960 hello.mingw.strip.exe MinGW gcc, stripped
262144 hello.mingw-g.exe MinGW gcc with -g
40960 hello.mingw-g.strip.exe MinGW gcc with -g, stripped

I compared the output of dumpbin /all before and after stripping. Symbols no longer appear in the stripped versions for cl and clang-cl even if the files keep the exact same size, strangely.

All the binaries run as expected, but that’s not a big test.

shym added 2 commits July 5, 2024 12:44
Instead of using `strip` unconditionally to build `tmpheader.exe`, use
the `strip` command detected by `libtool` during configure so that it is
replaced with `:` when the command is absent and it becomes easy to
override it if need be
GNU strip can be called safely on binaries generated by cl as well as by
MinGW GCC (even if it doesn't produce a smaller executable for
cl-generated binaries) so invoke strip also on Windows so that MinGW
binaries are properly stripped
Tested with GNU strip 2.42
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on behalf of @dustanddreams and @MisterDA. Thanks!

@dra27 dra27 merged commit c8f046f into ocaml:trunk Jul 16, 2024
@shym shym deleted the libtool-strip branch July 16, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants