Skip to content

Fix problem with ocamlopt.opt -plugin#980

Closed
lefessan wants to merge 1 commit intoocaml:4.04from
lefessan:2016-12-19-ocamlopt-plugin
Closed

Fix problem with ocamlopt.opt -plugin#980
lefessan wants to merge 1 commit intoocaml:4.04from
lefessan:2016-12-19-ocamlopt-plugin

Conversation

@lefessan
Copy link
Contributor

In 4.04, ocamlopt.opt cannot load plugins, whereas ocamlc.byte, ocamlc.opt and ocamlopt.byte work correctly with plugins. This is due to a missing argument when linking ocamlopt.opt, whereas ocamlc.opt is correctly linked. This PR adds the missing argument.

@gasche
Copy link
Member

gasche commented Dec 19, 2016

ocamlc.opt also gets compiled with -cclib $(BYTECCLIBS), is there a reason not to have this one as well for ocamlopt.opt?

@lefessan
Copy link
Contributor Author

I don't know. I just added the minimum needed to get plugins working also for ocamlopt.opt.

@gasche
Copy link
Member

gasche commented Dec 19, 2016

It would be nice to have the opinion of someone familiar with the build system and -cclib semantics before merging this.

@dra27
Copy link
Member

dra27 commented Dec 20, 2016

I'll have a test of this later today.

@dra27
Copy link
Member

dra27 commented Dec 20, 2016

Right, I've done some both some testing and checking:

  • While I realise that we now have the (acceptably) strange situation that linking the native code compiler requires the bytecode compilation libraries, there's no way that a native code program should be being linked using BYTECCLINKOPTS (or BYTECCLIBS) - this should be NATDYNLINKOPTS
  • However, this shouldn't be being specified for ocamlopt.opt at all: if this were being done with dynlink.cmxa, the option would be auto-imported from the .cmxa file
  • The patch therefore should be to ocamlbytecomp.cmxa, in order to ensure that any other tool which may or may not using the compiler's plugin feature gets the correct settings:
diff --git a/Makefile b/Makefile
index 85be2db..0f6c128 100644
--- a/Makefile
+++ b/Makefile
@@ -475,7 +475,7 @@ partialclean::
 # The bytecode compiler compiled with the native-code compiler

 compilerlibs/ocamlbytecomp.cmxa: $(BYTECOMP:.cmo=.cmx)
-       $(CAMLOPT) -a -o $@ $(BYTECOMP:.cmo=.cmx)
+       $(CAMLOPT) -ccopt "$(NATDYNLINKOPTS)" -a -o $@ $(BYTECOMP:.cmo=.cmx)
 partialclean::
        rm -f compilerlibs/ocamlbytecomp.cmxa compilerlibs/ocamlbytecomp.a
  • However, there are potential implications to ocamlbytecomp.cmxa including a cclib option which it didn't have before - if that's a problem, then perhaps the inclusion of compdynlink.cm{o,x} in ocamlbytecomp.cm{,x}a should be revisited (i.e. there should be a separate library containing the compdynlink/plugins part and the correct linking option)

This also needs a Changes entry (@gasche - {sh/c}ould you cherry-pick your updated Travis settings from trunk to 4.04?) and it would be worth noting that is a non-Windows problem.

It would also be good to have some tests to prevent accidental regressions on this - your hello plugin, for example, could allow a quick test of the plugin interfaces with an easy .reference-style output. The testsuite (certainly on Windows) already requires the .opt compilers for native testing to work (at present, I think this is a bug, but @shindere's work on ocamltest formally tests the .opt compilers, so that will soon be a feature).

@lefessan lefessan force-pushed the 2016-12-19-ocamlopt-plugin branch 2 times, most recently from 43d939d to 9da0ff6 Compare December 20, 2016 13:23
@lefessan
Copy link
Contributor Author

Thanks for the review ! I used your (much proper) solution, and modified the Changes file too. I won't update the testsuite, waiting for ocamltest to make it simpler !

I don't think the current solution will impact anybody using ocamlbytecomp, as NATDYNLINKOPTS flags are pretty much harmless.

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

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

Nit-picking the Changes file...

- MPR#7417, GPR#930: ensure 16 byte stack alignment inside caml_allocN on x86-64
for ocaml build with WITH_FRAME_POINTERS defined
- MPR#7417, GPR#930: ensure 16 byte stack alignment inside caml_allocN
on x86-64 for ocaml build with WITH_FRAME_POINTERS defined
Copy link
Member

Choose a reason for hiding this comment

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

This change is unnecessarily - the line is exactly 80 columns

Changes Outdated
- PR#7405, GPR#903: s390x: Fix address of caml_raise_exn in native dynlink modules
(Richard Jones, review by Xavier Leroy)
- PR#7405, GPR#903: s390x: Fix address of caml_raise_exn in native
dynlink modules (Richard Jones, review by Xavier Leroy)
Copy link
Member

Choose a reason for hiding this comment

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

I guess your editor did this? This line had slipped through at 82 columns, but the credits should remain on a line on their own

Changes Outdated
- GPR#912: Fix segfault in Unix.create_process on Windows caused by
wrong header configuration. (David Allsopp)

-GPR#980: add dynlink options to ocamlbytecomp.cmxa to allow ocamlopt.opt
Copy link
Member

Choose a reason for hiding this comment

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

The - and space are twiddled before GPR#980.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, and the previous GPR#912 has been corrupted (again, I guess your editor) - the first line is exactly 80 columns and the credit should be on its own line.

Changes Outdated
wrong header configuration. (David Allsopp)

-GPR#980: add dynlink options to ocamlbytecomp.cmxa to allow ocamlopt.opt
to load plugins
Copy link
Member

Choose a reason for hiding this comment

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

Needs your name!

Add NATDYNLINKOPTS options to ocamlbytecomp.cmxa
@lefessan lefessan force-pushed the 2016-12-19-ocamlopt-plugin branch from 9da0ff6 to 2d56472 Compare December 20, 2016 14:56
@gasche
Copy link
Member

gasche commented Dec 23, 2016

I removed the whitespace noise and pushed in 4.04 and trunk. Thanks!

@gasche gasche closed this Dec 23, 2016
sadiqj pushed a commit to sadiqj/ocaml that referenced this pull request Feb 21, 2023
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Mar 21, 2023
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Mar 21, 2023
b11eea1 flambda-backend: Introduce Import_info (ocaml#1036)
bc5b135 flambda-backend: Fix `ocamlobjinfo` on flambda2 .cmx files (ocaml#1029)
c8babbd flambda-backend: Compilation_unit optimisations (ocaml#1035)
e8d3e22 flambda-backend: Use 4.14.0 opam switch for building (includes upgrading ocamlformat to 0.24.1) (ocaml#1030)
eb14a86 flambda-backend: Port PR81 from ocaml-jst (ocaml#1024)
131bc12 flambda-backend: Merge ocaml-jst 2022-12-13 (ocaml#1022)
06c189a flambda-backend: Make stack allocation the default (ocaml#1013)
98debd5 flambda-backend: Initial support for value slots not of value kind (ocaml#946)
deb1714 flambda-backend: Add is_last flag to closinfo words (ocaml#938)
d07fce1 flambda-backend: Disable poll insertion in Configure (ocaml#967)
0f1ce0e flambda-backend: Regenerate ocaml/configure autoconf 2.69 (instead of 2.71) (ocaml#1012)
27132d8 flambda-backend: Fix for spurious typing error related to expanding through functor arguments (ocaml#997)
724fb68 flambda-backend: Use `Compilation_unit.t` instead of `Ident.t` for globals (ocaml#871)
396d5b8 flambda-backend: Add a test for frametable setup in natdynlinked libraries (ocaml#983)
b73ab12 flambda-backend: Fix invocation of `caml_shared_startup` in native dynlink (ocaml#980)
7c7d75a flambda-backend: Fix split_default_wrapper which did not trigger anymore with flambda2 (ocaml#970)
8fb75bd flambda-backend: Port ocaml#11727 and ocaml#11732 (ocaml#965)
fdb7987 flambda-backend: Fix include functor issue after 4.14 merge. (ocaml#948)
9745cdb flambda-backend: Print -dprofile/-dtimings output to stdout like 4.12 (ocaml#943)
5f51f21 flambda-backend: Merge pull request ocaml#932 from mshinwell/4.14-upgrade
841687d flambda-backend: Run make alldepend in ocaml/ (ocaml#936)
72a7658 flambda-backend: Remove reformatting changes only in dynlink/dune (preserving PR889 and adjusting to minimise diff)
6d758cd flambda-backend: Revert whitespace changes in dune files, to match upstream
c86bf6e flambda-backend: Remove duplicate tests for polling
971dbeb flambda-backend: Testsuite fixes
32f8356 flambda-backend: Topeval fix for symbols patch
befea01 flambda-backend: Compilation fixes / rectify merge faults
a84543f flambda-backend: Merge ocaml-jst
8e65056 flambda-backend: Merge ocaml-jst
4d70045 flambda-backend: Remove filename from system frametable (amd64) (ocaml#920)
5e57b7d flambda-backend: Bugfix for runtime frame_descr logic for C frames (ocaml#918)
6423d5e flambda-backend: Merge pull request ocaml#914 from mshinwell/merge-ocaml-jst-2022-10-24
ead605c flambda-backend: Add a missing Extract_exception (ocaml#916)
c8f1481 flambda-backend: Resolve conflicts and add specialise/specialised attributes to Builtin_attributes
cf4d0d3 flambda-backend: Merge fixes (ocaml#21)
c2f742f flambda-backend: Re-enable some tests for Flambda2 (ocaml#881)
3d38d13 flambda-backend: Long frames in frametable (ocaml#797)
85aec7b flambda-backend: Add loop attribute to Builtin_attributes
c0f16e3 flambda-backend: Compilation fixes
90dea23 flambda-backend: Merge flambda-backend/main
5acc6ea flambda-backend: Fixes after merge
e501946 flambda-backend: Merge ocaml-jst
115083b flambda-backend: Merge ocaml-jst
9943b2e flambda-backend: Revert "Revert "Transform tail-recursive functions into recursive continuations (ocaml#893)"" (ocaml#909)
ce339f1 flambda-backend: Fix alloc modes and call kinds for overapplications (ocaml#902)
e6a317c flambda-backend: Revert "Transform tail-recursive functions into recursive continuations (ocaml#893)"
853c488 flambda-backend: Transform tail-recursive functions into recursive continuations (ocaml#893)
5a977e4 flambda-backend: Fix missing End_region primitives on switch arms (ocaml#898)
7fa7f9d flambda-backend: Add missing dependencies to Dune files (ocaml#889)
3cd36f0 flambda-backend: Have Lambda `Pgetglobal` and `Psetglobal` take `Compilation_unit.t` (ocaml#896)
7565915 flambda-backend: [@poll error] attribute (ocaml#745)
9eb9448 flambda-backend: Backport the main safepoints PRs (ocaml#740)
689bdda flambda-backend: Add strict mode for ocamldep (ocaml#892)

git-subtree-dir: ocaml
git-subtree-split: b11eea1
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.

3 participants