a few of us had recently a discussion about how to manage the C API and possible policies regarding addition, maintenance, deprecation, and removal of API.
Even thought there is a strong agreement in the community that we shouldn't break released C API and should be backwards compatible, there doesn’t seem to be a developer policy that backs that up. This is something we should fix.
I was wondering what the interested parties think of the current approach and what could/should we improve to make the use and maintenance of the C API easier for users and the developers alike.
I was hoping we could also introduce a process that allows the removal of an API after it has been deprecated for a whole release and the release notes stated that it will be removed.
Thoughts? Comments?
Cheers,
Juergen
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> c) One of the big things appears to be the push and pull for "A C API for
> all C++ entry points" along with "We don't want to get locked into
> immobility because we have a C API for all C++ entry points". Perhaps part
> of this might be defining an actual stable set of things along with an
> unstable set of things?
This is a good idea. We should clearly document a subset that is stable.
Being stable should also have a very high bar. Things like "we have a
shipping product that has to work with two versions of llvm and has to
dynamic link with it".
So something that the webkit jit needs is in. Some API that is in C
just so someone can statically link a C/Go/Ocaml program with llvm is
not.
Cheers,
Rafael
We are not as vocally represented because don't generally give back to
the community, usually because we are just consumers of this library.
(Or maybe I'm totally wrong and lots of us give back).
For example, ORC APIs in C the bindings.
On 07/17/2015 12:36 PM, Juergen Ributzka wrote:
> Hi @ll,
>
> a few of us had recently a discussion about how to manage the C API and possible policies regarding addition, maintenance, deprecation, and removal of API.
>
> Even thought there is a strong agreement in the community that we shouldn't break released C API and should be backwards compatible, there doesn’t seem to be a developer policy that backs that up. This is something we should fix.
+1
>
> I was wondering what the interested parties think of the current approach and what could/should we improve to make the use and maintenance of the C API easier for users and the developers alike.
>
> I was hoping we could also introduce a process that allows the removal of an API after it has been deprecated for a whole release and the release notes stated that it will be removed.
+1
I'd suggest we also have an officially unofficial policy about not
versioning just for style or cleanliness reasons. i.e. We should try to
minimize churn of the API unless it's actually needed, or supporting an
old API becomes unjustifiably complicated.
On 07/17/2015 12:36 PM, Juergen Ributzka wrote:
> Hi @ll,
>
> a few of us had recently a discussion about how to manage the C API and possible policies regarding addition, maintenance, deprecation, and removal of API.
>
> Even thought there is a strong agreement in the community that we shouldn't break released C API and should be backwards compatible, there doesn’t seem to be a developer policy that backs that up. This is something we should fix.
+1
>
> I was wondering what the interested parties think of the current approach and what could/should we improve to make the use and maintenance of the C API easier for users and the developers alike.
>
> I was hoping we could also introduce a process that allows the removal of an API after it has been deprecated for a whole release and the release notes stated that it will be removed.
+1
I'd suggest we also have an officially unofficial policy about not
versioning just for style or cleanliness reasons. i.e. We should try to
minimize churn of the API unless it's actually needed, or supporting an
old API becomes unjustifiably complicated.
Hi Juergen,
I've actually got another, perhaps more radical, plan. Let's just get rid of the C API or move it to another project. This simplifies a lot of the plans here where people have too many different ideas of how the C API should work.
At this point the people who want a stable C API per incremental version can do that and handle the overhead of porting themselves and the people that want a C API that just happens to be a C interface can have a wrapper (or SWIG or whatever they want).
I realize it's radical, but it seems that there are so many different wants for C API here that solving everyone's problems or wants is going to be impossible.
Hi Juergen,I've actually got another, perhaps more radical, plan. Let's just get rid of the C API or move it to another project. This simplifies a lot of the plans here where people have too many different ideas of how the C API should work.At this point the people who want a stable C API per incremental version can do that and handle the overhead of porting themselves and the people that want a C API that just happens to be a C interface can have a wrapper (or SWIG or whatever they want).I realize it's radical, but it seems that there are so many different wants for C API here that solving everyone's problems or wants is going to be impossible.
Hi Juergen,I've actually got another, perhaps more radical, plan. Let's just get rid of the C API or move it to another project. This simplifies a lot of the plans here where people have too many different ideas of how the C API should work.At this point the people who want a stable C API per incremental version can do that and handle the overhead of porting themselves and the people that want a C API that just happens to be a C interface can have a wrapper (or SWIG or whatever they want).I realize it's radical, but it seems that there are so many different wants for C API here that solving everyone's problems or wants is going to be impossible.
Hi Juergen, Sean,I definitely agree with needing to write down the policy and definitely any policy should include a deprecation time :)Did you want to write up something and let us poke at it?A couple of thoughts outside of a deprecation policy:a) guarantee that the api itself won't go away, but could possibly be turned into a noop? (i.e. source compatibility)
b) versioning? (Should we add support for versioning in anyhow? Maybe a C API version 2 to start this off with?)
c) One of the big things appears to be the push and pull for "A C API for all C++ entry points" along with "We don't want to get locked into immobility because we have a C API for all C++ entry points". Perhaps part of this might be defining an actual stable set of things along with an unstable set of things?
I think the idea of having a (hopefully not too) fluid C API that can encompass everything people want to be able to do in the language of their choice and calls into LLVM to do work sounds like a great idea. I think it would be useful to expand the number of people who are able to do research and development with LLVM without having to reinvent LLVM. That said, this is directly at odds with our desire to have a stable C API that can be supported long term (as you said at the end of the email). I.e. where do we draw the line on what can or should be added to the C API? What if the people that want the functionality are willing to deal with it being (occasionally) unstable?
I don't agree with you that no one will take the time to design a well thought out C API. We've managed to get a lot of real world experience lately at both how these things will be used, and how we'll maintain such a thing. I think Juergen and others are a good group to come up with an answer to our engineering challenge.
It's sounds like we've reached two rough conclusions:
1) We need both a stable and a non-stable fully featured C API. It's a somewhat open question whether both or either should be part of the main tree.
2) Everyone seemed okay with the proposed deprecation policy for the stable API.
Given this, I would propose we designate the existing C API as the "hopefully stable, but subject to future clean up per policy..." Update
On Jul 30, 2015, at 3:46 PM, Eric Christopher <echr...@gmail.com> wrote:On Thu, Jul 30, 2015 at 3:36 PM Philip Reames <list...@philipreames.com> wrote:It's sounds like we've reached two rough conclusions:
1) We need both a stable and a non-stable fully featured C API. It's a somewhat open question whether both or either should be part of the main tree.I'm fine with the stable API being in the main tree. I proposed moving it out originally so that it could get some work before moving it in. I'm reasonably confident that we can get something working in tree for a stable API by the next release though.2) Everyone seemed okay with the proposed deprecation policy for the stable API.
Yes.Given this, I would propose we designate the existing C API as the "hopefully stable, but subject to future clean up per policy..." UpdateThis is where we disagree. I've tried to lay out a design that I think would be good for a stable API and the current one does not meet any guidelines there. It's too much a thin wrapper on top of the existing C++ API. There's no clear delineation for when/how/whether we extend it. It's already easy to subtly break the existing one.My proposal here is simply thus:We deprecate the existing API as "moving to unstable". For the next release cycle, as a new C API comes into existence, we continue our best effort toward keeping the existing API as stable as possible ("best effort") just like we always have. At the next release we flip the switch that says "this is now not stable, please use X”.
On Thu, Jul 30, 2015 at 3:36 PM Philip Reames <list...@philipreames.com> wrote:
It's sounds like we've reached two rough conclusions:
1) We need both a stable and a non-stable fully featured C API. It's a somewhat open question whether both or either should be part of the main tree.
I'm fine with the stable API being in the main tree. I proposed moving it out originally so that it could get some work before moving it in. I'm reasonably confident that we can get something working in tree for a stable API by the next release though.2) Everyone seemed okay with the proposed deprecation policy for the stable API.
Yes.Given this, I would propose we designate the existing C API as the "hopefully stable, but subject to future clean up per policy..." Update
This is where we disagree. I've tried to lay out a design that I think would be good for a stable API and the current one does not meet any guidelines there. It's too much a thin wrapper on top of the existing C++ API. There's no clear delineation for when/how/whether we extend it. It's already easy to subtly break the existing one.
My proposal here is simply thus:
We deprecate the existing API as "moving to unstable". For the next release cycle, as a new C API comes into existence, we continue our best effort toward keeping the existing API as stable as possible ("best effort") just like we always have. At the next release we flip the switch that says "this is now not stable, please use X".
In the mean time we can either a) move a bindings level C API into a separate directory starting with the existing wrapped C++ API that we have as part of the C API, or b) expand in the current directory and copy a set of APIs off to another directory. How to do this with minimal churn in external projects is important - this is why I'm inclined to say that the bindings API reside in the current C API directory, but others are more hesitant, I'm just not sure in their mind how the final transition from "best effort stable" to "stable".
Hi @ll,
a few of us had recently a discussion about how to manage the C API and possible policies regarding addition, maintenance, deprecation, and removal of API.
Even thought there is a strong agreement in the community that we shouldn't break released C API and should be backwards compatible, there doesn’t seem to be a developer policy that backs that up. This is something we should fix.
I was wondering what the interested parties think of the current approach and what could/should we improve to make the use and maintenance of the C API easier for users and the developers alike.
I was hoping we could also introduce a process that allows the removal of an API after it has been deprecated for a whole release and the release notes stated that it will be removed.
Thoughts? Comments?
Cheers,
Juergen
Being able to read and generate IR is at least some very basic thing we can agree on is needed. Can we get some testing for it ? Personally I don't really mind if this is going to be stable or not, but at least, having some test coverage would allow to take whatever path that is going to be taken willingly.
I'd like also to remind all to not fall into the hypothetical nirvana fallacy, ie comparing proposed solution with an idealized and unrealized one. That's a good recipe for endless bikescheding when pretty much anythign would be better than the status quo._______________________________________________2015-07-17 12:36 GMT-07:00 Juergen Ributzka <jue...@apple.com>:Hi @ll,
a few of us had recently a discussion about how to manage the C API and possible policies regarding addition, maintenance, deprecation, and removal of API.
Even thought there is a strong agreement in the community that we shouldn't break released C API and should be backwards compatible, there doesn’t seem to be a developer policy that backs that up. This is something we should fix.
I was wondering what the interested parties think of the current approach and what could/should we improve to make the use and maintenance of the C API easier for users and the developers alike.
I was hoping we could also introduce a process that allows the removal of an API after it has been deprecated for a whole release and the release notes stated that it will be removed.
Thoughts? Comments?
Cheers,
Juergen
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
LLVM Developers mailing list
On Sun, Aug 16, 2015 at 6:45 PM deadal nix via llvm-dev <llvm...@lists.llvm.org> wrote:Being able to read and generate IR is at least some very basic thing we can agree on is needed. Can we get some testing for it ? Personally I don't really mind if this is going to be stable or not, but at least, having some test coverage would allow to take whatever path that is going to be taken willingly.Right, and that's the problem. Expanding the C API to cover reading and generating IR in a stable way will lock the C++ API down in a way that I'm not comfortable with - I think it has already gone too far.-eric
2015-08-16 21:51 GMT-07:00 Eric Christopher <echr...@gmail.com>:On Sun, Aug 16, 2015 at 9:49 PM deadal nix <dead...@gmail.com> wrote:2015-08-16 21:47 GMT-07:00 Eric Christopher <echr...@gmail.com>:On Sun, Aug 16, 2015 at 6:45 PM deadal nix via llvm-dev <llvm...@lists.llvm.org> wrote:Being able to read and generate IR is at least some very basic thing we can agree on is needed. Can we get some testing for it ? Personally I don't really mind if this is going to be stable or not, but at least, having some test coverage would allow to take whatever path that is going to be taken willingly.Right, and that's the problem. Expanding the C API to cover reading and generating IR in a stable way will lock the C++ API down in a way that I'm not comfortable with - I think it has already gone too far.-ericThat seems like a bare minimum.The C++ evolve from one version to another, what is preventing the C API to do the same ?The promise of stability. We don't promise that the C++ API will stay stable.-ericWhy was that promise be made in the first place ? Has it been made in the first place ?
Also, whether, the C API is stable or change between version, being able to read and write IR from it seems like a bare minimum and having test for this as well.Having a test does not prevent the API to be changed. It just ensure that it is changed willingly as one would have to update the test in addition of the API.
Please read the rest of the thread :)
Also, whether, the C API is stable or change between version, being able to read and write IR from it seems like a bare minimum and having test for this as well.Having a test does not prevent the API to be changed. It just ensure that it is changed willingly as one would have to update the test in addition of the API.Your reading of this is not the same as anyone else's reading for what would be considered stable.-eric
2015-08-16 21:51 GMT-07:00 Eric Christopher <echr...@gmail.com>:The promise of stability. We don't promise that the C++ API will stay stable.
Why was that promise be made in the first place ? Has it been made in the first place ?
On Sun, Aug 16, 2015 at 10:34 PM, deadal nix via llvm-dev <llvm...@lists.llvm.org> wrote:2015-08-16 21:51 GMT-07:00 Eric Christopher <echr...@gmail.com>:The promise of stability. We don't promise that the C++ API will stay stable.Why was that promise be made in the first place ? Has it been made in the first place ?It sounds like you're in favor of dropping C API stability then, if it's holding us back? That feedback is actually really helpful. :)There are really three goals here: flexibility to change LLVM IR, completeness of the C API, and stability of the C API. Pick two.
The goals are mutually incompatible and we have to trade off one for the other. Most of the LLVM core developers value goal #1, the ability to change the IR. Look at the pointee type changes that David Blaikie is working on, and the new EH representation. If we promise both stability and completeness, these things are impossible.
One way forward is to guarantee stability, but limit completeness. This would mean limiting the C API to constructs that will always and forever be easily represented in LLVM.
The other choice is to forget stability and wrap the C++ API completely, potentially with something auto-generated. We could make a more limited stability promise along the lines of "these APIs will be updated to reflect changes to the IR, and are otherwise stable." I think everyone would be fine with that.
This would require a level of testing that we don't have, just to make
sure that happens, no?
>
> Ideally, if you're going to remove an API, you'd deprecate it first, if you
> can see the problem coming. Otherwise, oh well -- it's not reasonable to
> hold up LLVM development to adhere to deprecation policy on the C API.
>
> That is:
> 1) Adding new functions for new LLVM functionality: great.
> 2) Removing old functions: if it's required -- after careful deliberation.
> 3) Modifying the signature of existing functions: no way.
>
> A couple of concrete examples:
>
> - Let's say you run out of space in an existing enum type (ahem,
> LLVMAttribute...).
>
> You should introduce new function names, taking a better type (perhaps some
> sort of set type, instead of a fixed-width integer...), mark the old ones
> deprecated so that users will update to the new functions. But, keep the old
> ones around so that old code can keep working. There's no real need to
> remove the old deprecated functions -- they'll keep working as well as they
> ever did with the smaller-valued attributes.
Maybe?
Maybe not?
Maybe they were broken when built.
On Mon, Aug 17, 2015 at 12:31 PM, James Y Knight via llvm-dev
<llvm...@lists.llvm.org> wrote:
>
> I'd propose that the only 100% strict rule should be that if the ABI/API
> changes, it is done in a way that *loudly* breaks old programs -- e.g. they
> fail to compile, link, or run (depending on how the other-lang wrappers are
> accessing the API functions) -- not that you get some random weird
> misbehavior because a function's argument types or return type has been
> changed.
This would require a level of testing that we don't have, just to make
sure that happens, no?
(That seems necessary if we made James's 100% strict rule a 100% strict rule)
On Mon, Aug 17, 2015 at 12:31 PM, James Y Knight via llvm-dev
<llvm...@lists.llvm.org> wrote:
>
> I'd propose that the only 100% strict rule should be that if the ABI/API
> changes, it is done in a way that *loudly* breaks old programs -- e.g. they
> fail to compile, link, or run (depending on how the other-lang wrappers are
> accessing the API functions) -- not that you get some random weird
> misbehavior because a function's argument types or return type has been
> changed.
This would require a level of testing that we don't have, just to make
sure that happens, no?
As a data point, our approach in llvmlite (a lightweight LLVM binding
for Python -- http://llvmlite.pydata.org/) is to build the textual IR in
pure Python, to minimize the API contact surface with LLVM. But even
with that approach, the LLVM C API is too limited for us - we have to
call the C++ API at times.
> I'd propose that the only 100% strict rule should be that if the ABI/API
> changes, it is done in a way that *loudly* breaks old programs -- e.g. they
> fail to compile, link, or run (depending on how the other-lang wrappers are
> accessing the API functions) -- not that you get some random weird
> misbehavior because a function's argument types or return type has been
> changed.
I agree with this. Mandating that the C API is "100% stable" does not
seem to make a lot of sense when LLVM is changing so much otherwise, and
when you need to call C++ APIs anyway for non-toy applications...
Regards
Antoine.
As someone who used the LLVM C API for an experiment back in 2009ish (porting the SBCL lisp compiler to target LLVM as a backend -- never finished), I thought it was great that LLVM provided the C API. I was sad that it wasn't properly updated to include support for all the newly introduced IR features, though. (E.g. atomics). I tried to send patches for some of that stuff a while later, but didn't manage to get it in. (I wasn't active in llvm at that point, I was just trying to contribute a patch. I gave up.).It doesn't make sense to me to have the C API be less than a full wrapping of the IR building functions. Having less than that, you almost might as well not have it at all. (Which would be sad.)I'd like suggest that the most important thing for the C API is NOT a 100% promise of eternal compatibility, but to _strive_ for compatibility, as much as is realistically possible. If it's not possible, oh well. We're not talking about libc here, so the costs of changing it incompatibly -- with careful deliberation -- are not impossibly huge. I mean, even libstdc++ changes its ABI occassionally! LLVM's C API certainly shouldn't be considered more important to keep stable than libstdc++!That said, incompatible changes ought not be made just for trivial reasons: they should be made when there's a true need, e.g. when an existing LLVM-C function cannot sensibly maintain its existing behavior anymore because the underlying functionality of LLVM was removed, or drastically changed.
I'd propose that the only 100% strict rule should be that if the ABI/API changes, it is done in a way that *loudly* breaks old programs -- e.g. they fail to compile, link, or run (depending on how the other-lang wrappers are accessing the API functions) -- not that you get some random weird misbehavior because a function's argument types or return type has been changed.Ideally, if you're going to remove an API, you'd deprecate it first, if you can see the problem coming. Otherwise, oh well -- it's not reasonable to hold up LLVM development to adhere to deprecation policy on the C API.That is:1) Adding new functions for new LLVM functionality: great.2) Removing old functions: if it's required -- after careful deliberation.3) Modifying the signature of existing functions: no way.A couple of concrete examples:- Let's say you run out of space in an existing enum type (ahem, LLVMAttribute...).You should introduce new function names, taking a better type (perhaps some sort of set type, instead of a fixed-width integer...), mark the old ones deprecated so that users will update to the new functions. But, keep the old ones around so that old code can keep working. There's no real need to remove the old deprecated functions -- they'll keep working as well as they ever did with the smaller-valued attributes.
- Let's say you remove types from pointers.
This is a change that can be seen coming up. So, one should fairly early on add an LLVMBuildGEP2 function that takes the extra type argument. Leave the old function name around for now (deprecated), because with the current state of LLVM, it can continue to work just fine.When LLVM is changed to *actually* remove all pointer types in its core, then the LLVMBuildGEP function cannot reasonably continue to exist. It simply cannot work, if pointers don't have types, and the type isn't provided. So, remove it.
On Mon, Aug 17, 2015 at 12:31 PM, James Y Knight via llvm-dev <llvm...@lists.llvm.org> wrote:As someone who used the LLVM C API for an experiment back in 2009ish (porting the SBCL lisp compiler to target LLVM as a backend -- never finished), I thought it was great that LLVM provided the C API. I was sad that it wasn't properly updated to include support for all the newly introduced IR features, though. (E.g. atomics). I tried to send patches for some of that stuff a while later, but didn't manage to get it in. (I wasn't active in llvm at that point, I was just trying to contribute a patch. I gave up.).It doesn't make sense to me to have the C API be less than a full wrapping of the IR building functions. Having less than that, you almost might as well not have it at all. (Which would be sad.)I'd like suggest that the most important thing for the C API is NOT a 100% promise of eternal compatibility, but to _strive_ for compatibility, as much as is realistically possible. If it's not possible, oh well. We're not talking about libc here, so the costs of changing it incompatibly -- with careful deliberation -- are not impossibly huge. I mean, even libstdc++ changes its ABI occassionally! LLVM's C API certainly shouldn't be considered more important to keep stable than libstdc++!That said, incompatible changes ought not be made just for trivial reasons: they should be made when there's a true need, e.g. when an existing LLVM-C function cannot sensibly maintain its existing behavior anymore because the underlying functionality of LLVM was removed, or drastically changed.FWIW we do this (drastically change LLVM) pretty often. See Debug Info metadata, DataLayout, my typeless pointer work, Chandler's pass manager work, etc.I'd propose that the only 100% strict rule should be that if the ABI/API changes, it is done in a way that *loudly* breaks old programs -- e.g. they fail to compile, link, or run (depending on how the other-lang wrappers are accessing the API functions) -- not that you get some random weird misbehavior because a function's argument types or return type has been changed.Ideally, if you're going to remove an API, you'd deprecate it first, if you can see the problem coming. Otherwise, oh well -- it's not reasonable to hold up LLVM development to adhere to deprecation policy on the C API.That is:1) Adding new functions for new LLVM functionality: great.2) Removing old functions: if it's required -- after careful deliberation.3) Modifying the signature of existing functions: no way.A couple of concrete examples:- Let's say you run out of space in an existing enum type (ahem, LLVMAttribute...).You should introduce new function names, taking a better type (perhaps some sort of set type, instead of a fixed-width integer...), mark the old ones deprecated so that users will update to the new functions. But, keep the old ones around so that old code can keep working. There's no real need to remove the old deprecated functions -- they'll keep working as well as they ever did with the smaller-valued attributes.
But does it? What if the code is checking if two functions have the same attributes (perhaps this is an invalid notion in the absence of information about specific attributes) - if you compare the smaller-ranged attributes, you might incorrectly conclude that these two functions have the same attributes. Similarly for "no attributes specified" - you look at the enum, see that none are set & conclude that it's a plain, uninteresting function - so you create another plain, no-attributes function you think you can make equivalent.- Let's say you remove types from pointers.
This is a change that can be seen coming up. So, one should fairly early on add an LLVMBuildGEP2 function that takes the extra type argument. Leave the old function name around for now (deprecated), because with the current state of LLVM, it can continue to work just fine.When LLVM is changed to *actually* remove all pointer types in its core, then the LLVMBuildGEP function cannot reasonably continue to exist. It simply cannot work, if pointers don't have types, and the type isn't provided. So, remove it.
Yep, this is one we /might/ be able to manage - because we'll probably have to keep typed pointer information around for old bitcode deserialization. (but it does make the API awkward - when we finally do remove LLVMBuildGEP, do we rename LLVMBuildGEP2? Do we leave it there? & then we need LLVMBuildGEP3, etc, as things evolve?))
Also this works for writing, but not for reading - if code was expecting to read IR and assumed that pointers had types and bitcasts were present, etc - it's going to have a Bad Time reading new IR... the APIs wouldn't make any sense (there would be no getPointeeType on PointerType anymore - there would be no Type that could be returned in response to that query)
That's part of Eric's point, I think, once the API is low level enough, it will churn with every change in LLVM or possible require some heroics to avoid that churn which will slow down LLVM's API velocity (which is somewhere around "ludicrous speed"), which is something we rather like. The only way to make the C API more stable is to make it higher level (see libLTO for an example) so that we can own the migration & shelter users from it through that abstraction. If it's low level, it's going to churn or slow us down (and probably both).
I'd propose that the only 100% strict rule should be that if the ABI/API changes, it is done in a way that *loudly* breaks old programs -- e.g. they fail to compile, link, or run (depending on how the other-lang wrappers are accessing the API functions) -- not that you get some random weird misbehavior because a function's argument types or return type has been changed.Ideally, if you're going to remove an API, you'd deprecate it first, if you can see the problem coming. Otherwise, oh well -- it's not reasonable to hold up LLVM development to adhere to deprecation policy on the C API.That is:1) Adding new functions for new LLVM functionality: great.2) Removing old functions: if it's required -- after careful deliberation.3) Modifying the signature of existing functions: no way.A couple of concrete examples:- Let's say you run out of space in an existing enum type (ahem, LLVMAttribute...).You should introduce new function names, taking a better type (perhaps some sort of set type, instead of a fixed-width integer...), mark the old ones deprecated so that users will update to the new functions. But, keep the old ones around so that old code can keep working. There's no real need to remove the old deprecated functions -- they'll keep working as well as they ever did with the smaller-valued attributes.
But does it? What if the code is checking if two functions have the same attributes (perhaps this is an invalid notion in the absence of information about specific attributes) - if you compare the smaller-ranged attributes, you might incorrectly conclude that these two functions have the same attributes. Similarly for "no attributes specified" - you look at the enum, see that none are set & conclude that it's a plain, uninteresting function - so you create another plain, no-attributes function you think you can make equivalent.
- Let's say you remove types from pointers.
This is a change that can be seen coming up. So, one should fairly early on add an LLVMBuildGEP2 function that takes the extra type argument. Leave the old function name around for now (deprecated), because with the current state of LLVM, it can continue to work just fine.When LLVM is changed to *actually* remove all pointer types in its core, then the LLVMBuildGEP function cannot reasonably continue to exist. It simply cannot work, if pointers don't have types, and the type isn't provided. So, remove it.
Yep, this is one we /might/ be able to manage - because we'll probably have to keep typed pointer information around for old bitcode deserialization. (but it does make the API awkward - when we finally do remove LLVMBuildGEP, do we rename LLVMBuildGEP2? Do we leave it there? & then we need LLVMBuildGEP3, etc, as things evolve?))
Also this works for writing, but not for reading - if code was expecting to read IR and assumed that pointers had types and bitcasts were present, etc - it's going to have a Bad Time reading new IR... the APIs wouldn't make any sense (there would be no getPointeeType on PointerType anymore - there would be no Type that could be returned in response to that query)
That's part of Eric's point, I think, once the API is low level enough, it will churn with every change in LLVM or possible require some heroics to avoid that churn which will slow down LLVM's API velocity (which is somewhere around "ludicrous speed"), which is something we rather like. The only way to make the C API more stable is to make it higher level (see libLTO for an example) so that we can own the migration & shelter users from it through that abstraction. If it's low level, it's going to churn or slow us down (and probably both).
+1 from me, with the additional "no changing existing functions' signatures, replace with new function if necessary" rule.
Perhaps you can make a patch to the DeveloperPolicy document actually writing down your view on the Developer Policy for the C API? Then we never have to debate it again, because it'll be written down for future reference. And, reviewing that patch will give people one last opportunity to object and/or bikeshed. :)
James
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org