Skip to content

C-language API permits weaker backward compatibility requirements. #1798

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

Closed
wants to merge 1 commit into from

Conversation

jhwoodyatt
Copy link

Change to the C-language API extracted from #1003 for introducing the CAML_API_VERSION mechanism to improve control of the backward compatibility requirement.

  • Add CAML_API_VERSION parameter in the "caml/compatibility.h" header.
  • Default value is 100.
  • Explicitly define CAML_NAME_SPACE if CAML_API_VERSION >= 400.
  • If CAML_API_VERSION < 403, then also #define caml_stat_heap_xxx_size.
  • If CAML_API_VERSION < 400, then also #define Modify, Begin_roots, End_roots.
  • Always include "caml/compatibility.h" from "caml/memory.h" header.
  • Never include "caml/compatibility.h" from other headers.

@jhwoodyatt jhwoodyatt force-pushed the x-jhwoodyatt-api-version branch from 4384918 to 6fa8189 Compare May 24, 2018 19:07
@damiendoligez damiendoligez self-assigned this May 31, 2018
@dra27 dra27 changed the base branch from 4.07 to trunk June 30, 2018 12:01
@dra27 dra27 changed the base branch from trunk to 4.07 June 30, 2018 12:01
@dra27
Copy link
Member

dra27 commented Jun 30, 2018

Sorry, changing the base did not do what I'd hoped - please could you rebase this commit on to trunk?

Copy link
Member

@damiendoligez damiendoligez left a comment

Choose a reason for hiding this comment

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

There is a problem in compatibility.h. The rest looks OK.

You also need to rebase to trunk. (and also change the base? I'm not sure)

@@ -465,6 +464,8 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */
caml_modify (&Field ((block), caml__temp_offset), caml__temp_val); \
}while(0)

#if CAML_API_VERSION < 400

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid that Begin_roots and End_roots are used in code generated by the venerable CamlIDL tool (https://github.com/xavierleroy/camlidl/). The tool hasn't been updated in a long time but still has users. Forcing them to set CAML_API_VERSION to 312 or something is not nice.

Copy link
Author

Choose a reason for hiding this comment

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

Okay. Now that this is on trunk and not 4.07 I'll get around to this after my vacation.

Copy link
Author

Choose a reason for hiding this comment

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

So, first question about this: if the venerable CamlIDL doesn't set CAML_API_VERSION then it defaults to 100, and Begin_roots/End_roots definitions are available accordingly. Am I mistaken?

- Add CAML_API_VERSION parameter in the "caml/compatibility.h" header.
- Default value is 100.
- Explicitly define CAML_NAME_SPACE if CAML_API_VERSION >= 400.
- If CAML_API_VERSION < 403, then also #define caml_stat_heap_xxx_size.
- If CAML_API_VERSION < 400, then also #define Modify, Begin_roots, End_roots.
- Always include "caml/compatibility.h" from "caml/memory.h" header.
- Never include "caml/compatibility.h" from other headers.
@jhwoodyatt jhwoodyatt force-pushed the x-jhwoodyatt-api-version branch from 6fa8189 to 2f0769e Compare July 26, 2018 16:10
@jhwoodyatt jhwoodyatt changed the base branch from 4.07 to trunk July 26, 2018 16:11
@jhwoodyatt
Copy link
Author

I have rebased this on trunk and addressed the "fishy" thing that @damiendoligez noticed. I'm ready to make whatever change @xavierleroy thinks is necessary to keep CamlIDL from being damaged, but I'm not sure I know what to do there.

@xavierleroy
Copy link
Contributor

My problem is that I'm not sure what CAML_API_VERSION=100 means:

  1. all runtime APIs since version 1.00 can be used, or
  2. only runtime APIs that were in version 1.00 can be used.

CamlIDL is a case where we need both old APIs (for code generated by CamlIDL) and newer APIs (for code hand-written by users to do things that CamlIDL cannot handle).

@jhwoodyatt
Copy link
Author

My problem is that I'm not sure what CAML_API_VERSION=100 means...

I had this problem too, and I agree it's confusing. Here's a proposal, which I hope perhaps @stedolan or somebody else more central to the multicore effort will review, that would expand the set of configuration variables used for API backward compatibility selection.

  1. Change all the instances of CAML_API_VERSION in this change to CAML_API_COMPATIBILITY.
  2. Introduce another configuration variable CAML_API_VERSION which matches the version in the top level VERSION file. (I might be able to write some logic that automatically generates the definition during the compiler build.)
#define CAML_API_COMPATIBILITY 100
#define CAML_API_VERSION 408

This would allow consumers of the runtime API A) to assert their minimum API compatibility using definitions of the CAML_API_COMPATIBILITY variable before inclusion of <caml/compatibility.h>, and B) to adapt their internal logic to version of the API in the current compiler switch.

@jhwoodyatt
Copy link
Author

Gentle acknowledgement that I'm still holding the ball on this problem, and I'm not sure what to do with it.

@damiendoligez
Copy link
Member

If I understand correctly, your CAML_API_COMPATIBILITY variable is defined by the user and is the minimum API version needed by the user's code, while the CAML_API_VERSION is the actual version number and defined by the runtime's headers.

@jhwoodyatt
Copy link
Author

If I understand correctly, your CAML_API_COMPATIBILITY variable is defined by the user and is the minimum API version needed by the user's code, while the CAML_API_VERSION is the actual version number and defined by the runtime's headers.

That's what I think I was doing, yes. Again, I'm not sure this pull request is really the appropriate way to address the underlying problem, or even if the underlying problem is important enough to address. My interest in it developed when I tried to make some of my personal code with a few C-language foreign functions in it compile under the Multicore OCaml branch, which seems like it will need something in the runtime interface that allows extension implementations to compile according to the version of the runtime available.

@jhwoodyatt
Copy link
Author

When I get a few spare cycles next, I'll see about resolving those merge conflicts.

@XVilka
Copy link
Contributor

XVilka commented Sep 20, 2019

@johnwhitington will be this part of the 4.10 by any chance?

@johnwhitington
Copy link
Contributor

@XVilka I assume that was autocomplete for @jhwoodyatt :-)

@XVilka
Copy link
Contributor

XVilka commented Sep 20, 2019

Yes, sorry about that.

@gadmm
Copy link
Contributor

gadmm commented Dec 7, 2019

This is superseded by #9167 in case it is accepted. Please see the discussion there.

@jhwoodyatt
Copy link
Author

I'm tracking the progress of #9167 and will withdraw this if that achieves consensus.

@gadmm
Copy link
Contributor

gadmm commented Jan 23, 2020

For the record, I proposed a clarification of CAML_API_VERSION renamed as CAML_NAME_SPACE at #9167 which can be reused. (The bug #9167 was meant to fix was fixed differently but I still think that the approach there is preferable if some mechanism of the sort is deemed useful.)

@jhwoodyatt
Copy link
Author

Abandoning this request as the basic concern was more recently considered in #9167 and keeping this open when that has been closed seems unnecessary.

@jhwoodyatt jhwoodyatt closed this Jun 10, 2021
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
* Figma colors tailwind.config.js, old colors->legacy, tutorial block, hero section
* split hero background in background and camel, scale background
* remove featured+rating on book, book difficulty variant type, lang manual banner draft, books block draft
* add two more book recommendations
* exercises block
* language manual banner background
* better book recommendation text
* move industrial user success story card to template
* platform tools section learn landing, rename legacy cards class
* update border color from Figma, adjust card hover shadow, transform paper cards to new class
* refactor footer
* refactor learn_sidebar into learn_layout
* buttons from design system, substitute legacy primary by new primary, books page
* exercises.eml
* legacy primary-600 and primary-700 to new primary color
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.

7 participants