r/cpp • • Sep 24 '26

Why we should standardise on CPS

To enable any collaboration in the industry, some "social contract" must be signed by all of us.

One of the rules of this contract is binary packaging, to put it simply, if you are a library author you need to either have clean definition on what package you expect to consume or have a "scriptless" implementation like imgui.

If the library exports a pkgconf package, but its dependency exports something else your build will not work. Why should it, what you do makes no sense.

Currently I'm literally forced to package every single dependency I have, which is fine in principle as you want to own your dependencies for security and licensing reasons... But I CAN'T UPSTREAM MY CHANGES which is not fine.

The current situation is a disease, please do remember my talk when you try to build a library like dawn or SDL and it vendors dozens of libraries to create a giant shared library after a long slow build.

0 Upvotes

70 comments sorted by

4

u/fortsnek274 Sep 24 '26

Yeah, I'm also a CPS fan. It could separate package management and dependency management. That OO principle of separation of concerns, reduce coupling.

It would be great if you could have your package manager in one window, and all your IDE cares about is the CPS files it dumps somewhere. Thereby untangling your project from what package manager is used.

But package names would need to be the same. And what if you have two package managers that provide the same lib.

1

u/TheRavagerSw Sep 24 '26

You use only one package manager

4

u/fortsnek274 Sep 24 '26

What if your package manager doesn't have all the things you want.

2

u/Expert-Map-1126 vcpkg maintainer BillyONeal Sep 25 '26

Package management is a global, not a local problem, given that the ODR exists. You get diamond situations where both package managers would want to provide, for example, zlib, and then the resulting solution isn't link compatible because there can be only one.

I understand why this is a thing people want but as long as the ODR is a thing I don't think it's in the cards.

1

u/fortsnek274 Sep 25 '26

Not that I want to have duplicate libs, but I guess the ideal is being able to mix and match package managers still wouldn't be possible with CPS.

3

u/Expert-Map-1126 vcpkg maintainer BillyONeal Sep 25 '26 edited Sep 25 '26

I don't understand why you think CPS does anything about this. Let's say we have components ABC of which AB are in package manager x, and AC are in package manager y. In your "downstream" app you want all of ABC. Each package manager does a solve for what versions to provide, what compiler settings to use, etc. and don't agree on literally everything. So now you have Bx depends on Ax, and Cy depends on Ay, and there is nothing any system, CPS or otherwise, can do afterwards to make this work. Trying to link Ax and Ay in the same link breaks the ODR. CPS documents for all of Ax Bx Ay Cy might help your downstream build system tell you what you're doing is impossible without horrible linker errors, but it can't fix the ODR issue here.

If you change the package managers x and y such that they can globally resolve this situation and pick a single A, you haven't mixed and matched package managers, you've produced a new package manager that tries to subsume the originals because it would need to obey all the versioning / constraints / policy etc. for the union of what x and y support in order to make that answer be consistent.

1

u/fortsnek274 Sep 26 '26

What I mean is that CPS allows build systems to consume packages generically, so I might wish that you could mix and match package managers. But you can't because of this problem. Have to avoid conflicts.

At least if you had some system like a CPS search order, it could be detected.

1

u/Expert-Map-1126 vcpkg maintainer BillyONeal Sep 26 '26

It conveys build system settings but build systems can't workaround this ODR situation either. You could do your search order, but no order to visit Ax or Ay in my above example can make it work.

0

u/TheRavagerSw Sep 25 '26

Package managers are for having a global view over your dependency chain, you can't mix them both.

If you do that, you will link some dependencies twice or maybe not at all, you can't do stuff like statically linking tbb etc.

4

u/johannes1971 Sep 24 '26

Isn't the whole point of this to decentralize package management?

2

u/fortsnek274 Sep 24 '26

It seems rather decentralised already. There are many package managers.

I hope that CPS will make it so that a project or build script is not tied to any particular package manager. Such that you could use any package manager or no package manager for somebody else's project.

But I don't know how well that could work in practice.

3

u/johannes1971 Sep 24 '26

That's not decentralized, that's a collection of little fiefdoms, each jealously guarding its borders. A true decentralized package manager should not have a central repository (or a collection of such things), but instead operate directly on the basic infrastructure of the web itself. A URL should be enough to consume a package. If it has dependencies, those should also be specified as URLs as well. The build instructions in the downloaded data should also be uniformly understood, rather than be specific to one build system or another. This is what I hope the CPS is trying to achieve.

2

u/fortsnek274 Sep 24 '26 edited Sep 24 '26

Afaik, CPS is not to describe the sources or how to build anything, not something you would have on your github, but to list the flags and dependencies needed to consume the compiled library. Like pkgconfig and cmake package config. CPS would be a build/install output.

https://cps-org.github.io/cps/sample.html

The package manager will still have to figure out where to find dependencies and how to build them. But the CPS output should be Standard. So a build system or IDE should be able to consume that agnostically.

*But maybe a central repository could be used, but the lib would have to be pre-built, like for a system package manager. But that's basically standardising a package system. You need a standard way of resolving dependencies.

1

u/Expert-Map-1126 vcpkg maintainer BillyONeal Sep 25 '26

No. CPS is just another build system bindings format like CMake configs or pkg-config to allow build systems to communicate the shape of already built things to each other. The main advantage over CMake configs is just being a JSON format which makes it easier for other build systems like meson to adopt without needing to write a CMake parser.

Unfortunately to my understanding only CMake implements it right now so I'm not sure what the future holds.

1

u/TheRavagerSw Sep 24 '26

Package manager just invoces your build system and stores it's output. What feature do you want?

4

u/fortsnek274 Sep 24 '26

It has to get the source from somewhere doesn't it? If it also builds from source. System package manager won't do that.

Like, if one package manager has lib A and another has lib B, and they both depend on spdlog, where does spdlog come from. What do the package managers do and which version does the compiler use.

Because if I wanted an IDE to have a list of CPS directories to find CPS files in, it will find that there is an ambiguity if you point it to two package managers with the same lib. So how do I fix that design. I'll need to put it into practice.

0

u/TheRavagerSw Sep 24 '26

all repos should come from some directory in your system. For conan at least you just install an existing source tree. You don't want IDE in here at all

3

u/fortsnek274 Sep 24 '26

The IDE has to consume dependencies somehow. That's what CPS could be used for. A VS props file that works with any CPS-compatible build system.

-3

u/TheRavagerSw Sep 24 '26

You shouldn't use an IDE to build software, you should use the latest cli tools

1

u/TrashboxBobylev Sep 25 '26

So you are expecting us to wait for GitHub to wake up and download every single new build to debug things locally?

0

u/TheRavagerSw Sep 25 '26

How did you come to this conclusion?

1

u/pjmlp Sep 25 '26

Some of us rather use an IDE, since the old glory Borland days for MS-DOS, OS/2 and Windows 3.1.

0

u/TheRavagerSw Sep 25 '26

I'm sorry, but collaboration with IDE users is not possible. How can anyone help you if you don't even know the compiler version when you are developing?

→ More replies

3

u/13steinj Sep 24 '26

The committee had the opportunity to get an Ecosystem IS off the ground, and while it is unclear if the tooling group got fed up or if the rest of the committee made it clear that it won't happen, at the end of the day in somewhat dramatic fashion one day all the papers were withdrawn.

I will admit, I felt that the original goals of the Ecosystem IS were shortsighted and contradictory, I left a comment here about that at the time.

The current situation is a disease, please do remember my talk when you try to build a library like dawn or SDL and it vendors dozens of libraries to create a giant shared library after a long slow build.

There is slow movement in some Discords and GitHub organizations and Slack spaces that I don't have the links to. At one point one of the people here told me to get involved last year to which my response was along the lines of "yeah... maybe..." but reality is I don't have the energy to expend on something moving this slowly (if at all).

All that said and done CPS is a package manager spec, not a build system spec: you'll still have difficulty upstreaming your changes because many problems exist at the build system level.

1

u/TheRavagerSw Sep 24 '26

Well I would love to get involved, if anyone wants me in these spaces DM me

2

u/Minimonium Sep 24 '26

For context why Ecosystem papers were withdrawn, Herb Sutter pushed them out of agenda in favour of a nonbinding vote to ban the "safe" keyword.

2

u/13steinj Sep 24 '26

That feels like a very partial piece of context that raises more questions than answers on both sides. I don't remember this being the reason some of the authors stated, but I can totally see it being a slap in the face.

-1

u/Minimonium Sep 24 '26

3

u/13steinj Sep 24 '26

Yeah, this I knew. It's far less harsh than the original picture you portrayed.

2

u/Minimonium Sep 25 '26

I am not harsh enough towards Sutter for wasting everyone's time on that circus. The picture I describe is what happened, what do you believe is misleading in my description of what happened?

3

u/13steinj Sep 26 '26

From what you linked:

Instead the draft, and a few other papers, got bumped in favor of discussing, and eventually voting on, what is now SD-10 (https://isocpp.org/std/standing-documents/sd-10-language-evolution-principles). In addition there was also a vote to re-prioritize WG21 towards working to include profiles for C++26.

I dislike SD-10 as much as, maybe even more than you. I agree that the existence of the document is a circus act, and it honestly brings quite a bit of shame to the C++ community IMO.

That said, I would not reduce it down to "ban the 'safe' keyword," even if SD-10 was only pretext in order to do so. The end-state consequences of SD-10, IMO, are much worse than just banning 'safe.' Simultaneously, it is my recollection that on several occasions SG-15 in some way shape or form, was wronged by WG21 procedure (by which I mean, the wider committee just does not care about tooling / see it as enough of a problem). Which, much more closely matches the disposition mentioned:

I always understood that there were two basic requirements for solving the C++ tooling ecosystem problems:

  1. WG21 needed to buy in to the position that the work was needed.
  2. The solutions (and adoption) needed to include parties external to WG21.

...
==> Again, it did not progress. And now we missed a deadline from our schedule.

What I concluded from those meetings, is that the (1) requirement was not resolved. WG21 prioritized profiles above the tooling ecosystem work.

WG21 will always, consistently, prioritize something else above tooling ecosystem work, it seems. When it doesn't, it pushes through tooling ecosystem work through far too early (see: modules).

This was just the straw that broke the camel's back.

14

u/crowbarous Sep 24 '26

This poster is becoming tiring.

16

u/no-sig-available Sep 24 '26 edited Sep 24 '26

CPS?

Clicks Per Second

Collaborative & Proactive Solutions

Cyber-Physical Systems

Cost Profit System

Child Protective Services

Clean Pipe System? https://www.cps.se/

9

u/robertahleahy WG21, SCC, std::execution, Finance Sep 24 '26

Continuation-Passing Style?

9

u/xiao_sa Sep 24 '26

Mom, can we have Continuation-Passing Style?
No. There is Continuation-Passing Style at home.
Co_ntinuation-Passing Style at home:

1

u/alfps Oct 02 '26

I believe the lazy poster intended to refer to

https://cps-org.github.io/cps/overview.html

1

u/pdp10gumby Sep 26 '26

only clocked on the post (I read Reddit via RSS) because that’s what I immediately thought was meant by CPS.

1

u/TheRavagerSw Sep 26 '26

Common Package Specification

1

u/equeim Oct 02 '26

Does it support modules yet?

5

u/epasveer Sep 24 '26

I ain't signing shit.

2

u/_a4z Sep 25 '26

Last time I looked, CPS missed a section to tie requirements to build flavors.
E.g., tell it to check that the package has the expected sanitizer (or, in the future, contract) flags.
To my knowledge, this is only possible in the 'open for adoptions' section.
Sadly, even though some people discussed this at the very first ecosystem evolution meeting.

WG21 is unlikely to look at the topic; they only involve SG15 when they want to confirm something is possible.
Then one of is the expert who says, sure, it works, and then people write that their experts in tooling confirm ... see contracts, for example. But in reality, everything in this direction is implementation-defined and 'vendors will figure it out'.

Also, the most active people from SG15 have not been active there for years, for various reasons.

So while I agree that infrastructure is important to target in a standard way, and doesn't have to be an ISO standard, seeing something actually happen that isn't driven by a customer-vendor relationship doesn't seem to be on the horizon anywhere. And customer-vendor relationships give you what one customer, the one who pays, needs. Not necessarily what makes sense for a larger part of the industry,

1

u/Expert-Map-1126 vcpkg maintainer BillyONeal Sep 25 '26

I don't understand how CPS would possibly support that sort of thing. It's an attestation, not an audit, and generally only describes bits that are relevant for downstream customers. "What flags I was built with" are usually not part of that set.

If you want to audit you need to audit the actual build environment and how it works, not a random text file that happened to be dropped next to the binaries that anyone can change to say anything.

2

u/_a4z Sep 26 '26

If something was built with memory sanitizer, debug, or release , or both is information should exist. In vcpkg, you also know what you want or expect based on the triplet.
And yesterday, at the ecostd meeting, components vs. configuration was a discussion in this direction. It's kind of sad that nobody from the vcpkg people is anymore at those meetings. It would be so valuable to have your pov and knowledge contributions.

1

u/Expert-Map-1126 vcpkg maintainer BillyONeal Sep 26 '26

It will be in the debug information but you don’t need CPS for that. What actually happened when producing the actual binary is always better than an attestation.

1

u/_a4z Sep 26 '26

I hope an attestation documents what actually happened.
CPS should include info about what a package contains: whether it/there is a debug build or not. For the simplest case.
Because my program might request a debug build of a library, and if there is none, I would like to know. If CPS will be able to provide that, I don't know.
Atm, when it comes to CMake, I just use vcpkg and triplets, and assume that is always correct ;)

2

u/Flimsy_Complaint490 Sep 24 '26

idk i just point CPM to a github repo and it kinda just works. Conan is nice too.

pkgconf is the problematic space but i've used like 2 libraries that are pkgconf only in the past 3 years.

either way, nobody is adopting shit, this is cpp, the home of NiH syndrome.

1

u/Expert-Map-1126 vcpkg maintainer BillyONeal Sep 25 '26

pkg-config remains the "lowest common denominator" that all systems support.

0

u/ABlockInTheChain Oct 20 '26

CPS might be great someday but it isn't even usable yet.

It sounds ideal as a solution for transitive dependencies. My current clunky-but-working solution is to consolidate all dependencies into a mylib-find-dependencies.cmake. I run that script to configure mylib but also install it alongside the cmake target files and set up some hackery such that find_package(mylib CONFIG) will execute mylib-find-dependencies.cmake.

Inconvenient to set up initially but reliable and low maintenance afterward.

The first thing that happened when I added install(PACKAGE_INFO ... to mylib is a string of errors about things I can't fix and shouldn't need to care about:

CMake Error in CMakeLists.txt:
  Target "mylib" references target "Qt6::Core", which
  comes from the "Qt6Core" package, but does not belong to the package's
  canonical namespace ("Qt6Core::").  This is not allowed.

...

CMake Error in CMakeLists.txt:
  Target "mylib" references target "Boost::headers",
  which comes from the "boost_headers" package, but does not belong to the
  package's canonical namespace ("boost_headers::").  This is not allowed.

That's great. CPS clearly isn't ready to use yet so I guess I'll check back in a year or two.

0

u/TheRavagerSw Oct 20 '26

I packaged like 110 repositories. I assure if you it works if you use it right

0

u/not_a_novel_account cmake dev Oct 20 '26

The thing you're trying to do here will never work with install(PACKAGE_INFO) by design, so it really has no bearing on the readiness of CPS.

There is a very good argument to be made that CPS has deficiencies relative to its goals, but a technology cannot be deficient in something it is designed not to do.

1

u/ABlockInTheChain Oct 20 '26

CMake has shown a consistent trend in recent years of loudly announcing new technologies then declaring NOTABUG/WONTFIX when people actually try to use them and notice what has been delivered does not match what was advertised.

1

u/not_a_novel_account cmake dev Oct 20 '26

PACKAGE_INFO was never advertised to do what you're trying to do here. This will always been the realm of CMakeConfig packages.

1

u/ABlockInTheChain Oct 20 '26

Then document this restriction.

The PACKAGE_INFO form generates and installs a Common Package Specification file which describes installed targets such that they can be consumed by another project. Target installations are associated with the export <export-name> using the EXPORT option of the install(TARGETS) signature documented above. Unlike install(EXPORT), this information is not expressed in CMake code, and can be consumed by tools other than CMake. When imported into another CMake project, the imported targets will be prefixed with <package-name>::. By default, the generated file will be called <package-name>[-<appendix-name>].cps. If LOWER_CASE_FILE is given, the package name as it appears on disk (in both the file name and install destination) will be first converted to lower case.

Nowhere in this description does it mention that it only works for targets that have no dependencies, or possibly only for dependencies that were discovered via perfectly-formatted cps files.

Then in the project blog posts make sure to mention, "Actually if you have any dependencies at all you can't use CPS until all your dependencies also use CPS. We created an unsolvable bootstrapping paradox. Sorry."

1

u/not_a_novel_account cmake dev Oct 20 '26

That's not what's happening here, CPS requires package name and namespace to match.

CMake will bridge the CMakeConfig-CPS divide where that is true. It isn't for your upstream dependencies. If you think that can be better expressed in the docs somewhere, MRs welcome.

But ya, failing to point out everything that fails is not a claim that Qt is useable with PACKAGE_INFO.

1

u/ABlockInTheChain Oct 20 '26

It could just be a single sentence: "All targets included in and referenced by the installed set must conform to Common Package Specification naming rules, including targets discovered via find_package."

1

u/not_a_novel_account cmake dev Oct 20 '26

Agreed, give it a shot.

1

u/ABlockInTheChain Oct 20 '26

What a perfect example of how CMake has earned its reputation.

"Yes, our documentation is incomplete. No, we are not going to fix it. I dare you to contribute a fix and see what happens to the MR."

1

u/not_a_novel_account cmake dev Oct 20 '26

The dark and menacing act of encouraging developers to make the trivial improvements they personally want to see in the open source tools that they use.

→ More replies

0

u/Suitable_Plate4943 Sep 24 '26

atp i just rewrite all vendored cmake otherwise they all spend half a minute looking for pthreads and int size each time i add a source file and need to reconfigure