Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -config option to ocamlrun #9284

Merged
merged 5 commits into from Jan 5, 2021
Merged

Add -config option to ocamlrun #9284

merged 5 commits into from Jan 5, 2021

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Feb 5, 2020

The main purpose of this PR is to add a -config option to ocamlrun similar to the one already in ocamlc/ocamlopt. This is loosely related to the work I'm doing with relocating the compiler, but independent enough to push it now - it's obviously non-urgent. ocamlrun -config gives output like:

version: 4.11.0+dev0-2019-10-18
standard_library_default: /usr/local/lib/ocaml
standard_library: runtime
int_size: 64
word_size: 63
os_type: Unix
host: x86_64-pc-linux-gnu
flat_float_array: true
supports_afl: true
windows_unicode: false
supports_shared_libraries: true
no_naked_pointers: false
profinfo: false
profinfo_width: 0
exec_magic_number: Caml1999X027
shared_libs_path:
  /usr/local/lib/ocaml/stublibs
  /usr/local/lib/ocaml

Options are exactly the same as ocamlc -config, with four exceptions:

  • supports_afl indicates that the runtime has the shared memory support for execution with AFL, which is independent of using a compiler which had AFL instrumentation turned on for a particular build. cc @stedolan to ensure I got the detail of that correct
  • shared_libs_path which contains the contents of caml_shared_libs_path after parsing ld.conf and any -I parameters on the command line (this is the feature I particularly wanted).
  • no_naked_pointers and profinfo/profinfo_width

There's also a little shopping list of other things related to ocamlrun's argument parsing:

  • Support -- so you can now have bytecode programs which begin with - if you, um, want
  • Support -Ifoo as -I foo (previously, this was interpreted as -I
  • Update some missing things in the manual
  • Use puts instead of printf("%s\n", …) in a few places in startup_byt.c
  • Strictly recognise command line parameters (previously, the first letter was checked only, so -backtrace was equivalent to -b - -backtrace is now an error).
  • Display a slightly improved message for ocamlrun -I (indicate that -I expects a <dir> rather than that no bytecode file was specified).
  • Add -help/--help

Exposes the logic for parsing OCAMLLIB, etc. in dynlink.c
Renamed to caml_parse_ld_conf
Similar to ocamlc/ocamlopt -config, displays the information pertinent
to the bytecode runtime only. Also displays the search path for shared
stub libraries, which means the entire command line is parsed in order
to include any -I flags.
@stedolan
Copy link
Contributor

The AFL bit looks good to me!

@dra27
Copy link
Member Author

dra27 commented Dec 29, 2020

I've broken this PR up into parts in a bid to get it merged. This PR also includes #10098 and #10101 which need merging first.

Note that this PR works without #10103 (since if WINDOWS_UNICODE is not defined, it will default to 0 according to the specs for the C preprocessor) but I think it may fail one of the sanitizer checks.

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

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

More nitpicking on the parts that have not been sliced off.

runtime/startup_byt.c Outdated Show resolved Hide resolved
runtime/startup_byt.c Outdated Show resolved Hide resolved
runtime/startup_byt.c Outdated Show resolved Hide resolved
Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

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

Looks good to me, once all the various PRs are put back together.

@dra27
Copy link
Member Author

dra27 commented Jan 4, 2021

Rebased, squashed, extra bits removed and ready for a CI-approving merge, thanks!

@dra27 dra27 merged commit 2118969 into ocaml:trunk Jan 5, 2021
@dra27 dra27 deleted the ocamlrun-config branch January 5, 2021 21:47
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.

None yet

3 participants