Skip to content

Reduce size of bootstrap compilers by stripping debug info#340

Merged
xavierleroy merged 2 commits intotrunkfrom
stripped-bootstrap
Dec 18, 2015
Merged

Reduce size of bootstrap compilers by stripping debug info#340
xavierleroy merged 2 commits intotrunkfrom
stripped-bootstrap

Conversation

@xavierleroy
Copy link
Copy Markdown
Contributor

Recently, we added "-g" to the build of the OCaml compilers, to make them easier to debug. This has the unfortunate effect of increasing their sizes: ocamlc goes from 2 Mbytes to 10 Mbytes. It's OK for the newly compiled compilers (those that will be installed), but a little too much for the bootstrap compilers (those in boot/, which are under version control and part of the .tgz source distribution).

This pull request proposes to strip the debug information from the bootstrap compilers. This way, the new compilers can still be debugged, but the bootstrap compilers revert to their sizes before the "-g" change.

The stripping is done during bootstrap, when copying the new ocamlc, ocamllex and ocamldep to boot/. The new "stripdebug" tool performs this task.

As a consequence, comparing the new compilers with the boot/ compilers at the end of bootstrap is more complicated, since the debug section must be ignored. A new tool, "cmpbyt" in tools/, performs this comparison.

…eir size

The stripping is done during bootstrap, when copying the new ocamlc, ocamllex and ocamldep to boot/.  The new "stripdebug" tool performs this task.

As a consequence, comparing the new compilers with the boot/ compilers at the end of bootstrap is more complicated, since the debug section must be ignored.  A new tool, "cmpbyt" in tools/, performs this comparison.
… is not needed and can cause spurious merge conflicts.
@xavierleroy
Copy link
Copy Markdown
Contributor Author

Yes, it strips everything up to the beginning of the bytecode executable proper (= the beginning of the first section of the bytecode executable).

@xavierleroy
Copy link
Copy Markdown
Contributor Author

Ping? In the absence of negative opinions, I'll merge this by the end of the week.

@damiendoligez
Copy link
Copy Markdown
Member

  1. Out of curiosity, why did you have to change the perl script?
  2. Could stripdebug be useful to the general public? And installed with the other tools? If so, you should rename it to ocamlstrip and probably provide an option to keep the header.

Maybe do (2) as a follow-up to this PR.

@xavierleroy
Copy link
Copy Markdown
Contributor Author

1- To silence a perl warning. (Apparently, "do" for function calls went out of fashion in the 1990's.)

2- The idea crossed my mind, but I couldn't find much of a general use for the tool, so let's keep it private for the moment.

xavierleroy added a commit that referenced this pull request Dec 18, 2015
Reduce size of bootstrap compilers by stripping debug info
@xavierleroy xavierleroy merged commit 5b62da1 into trunk Dec 18, 2015
@xavierleroy xavierleroy deleted the stripped-bootstrap branch December 18, 2015 10:13
@lefessan
Copy link
Copy Markdown
Contributor

For the general public, "ocamlclean" would be a better choice, as it strips debug, but also removes dead code. I have been using it for a while, with great results (program stripped from 400k without debug to 16k...)

@lefessan
Copy link
Copy Markdown
Contributor

Actually, it makes me think we could use it too, just before releasing a new version to have the smallest boot/ possible.

chambart pushed a commit to chambart/ocaml-1 that referenced this pull request Jan 4, 2022
You can now `make runtest` to run a couple of tests. One of them is an
`flexpect`-based test, with a functioning `make promote`. (The other
is the preexisting `meet_test.ml`, which simply needed to be made a
test in `dune`.)

There are also the `fldiff` and `parseflambda` utilities from the old
repo. `fldiff` might be useful for testing the `Flambda2_compare`
module, and `parseflambda` more or less runs the middle end and
nothing else.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants