September 6th, 2024

QtCS2024 Compile once. Run everywhere

Cristian Adam discussed using Cosmopolitan libc for cross-platform C++ applications at QtCS2024, addressing deployment challenges and encouraging community contributions to enhance support for Qt Creator.

Read original articleLink Icon
CuriositySkepticismAdmiration
QtCS2024 Compile once. Run everywhere

Cristian Adam from the Qt Creator team presented a session titled "Compile Once, Run Everywhere" at QtCS2024, focusing on the use of Cosmopolitan libc for C++ applications. The session highlighted the challenges of compiling and deploying applications across various platforms, including Windows, Linux, and macOS for both x86_64 and arm64 architectures. Cosmopolitan libc serves as a solution by detecting the host machine at runtime and providing appropriate system calls, allowing for a unified compilation process. Applications are compiled for both architectures and packaged similarly to Linux installers. Adam demonstrated successful builds of CMake, Qt Base, and Qt GUI using Cosmopolitan libc on macOS and Linux, although he faced difficulties on Windows due to limitations in Cosmopolitan's POSIX implementation. Key challenges discussed included integration with native platforms, application launching, and WebSocket support for the Qt QPA VNC platform. The Qt Creator binary size was noted to be around 230 megabytes, with no significant performance differences from the native version. Adam expressed his intention to further develop Cosmopolitan support for Qt Creator and encouraged community contributions and feedback.

- Cristian Adam presented on using Cosmopolitan libc for cross-platform C++ application deployment.

- Cosmopolitan libc allows applications to be compiled once and run on multiple platforms.

- Challenges include integration with native systems and limitations on Windows.

- The size of the Cosmopolitan Qt Creator binary is approximately 230 megabytes.

- Adam encourages community involvement in improving Cosmopolitan support for Qt Creator.

AI: What people are saying
Cristian Adam's discussion on Cosmopolitan libc for cross-platform C++ applications at QtCS2024 generated diverse reactions among commenters.
  • Many commenters expressed curiosity about the practical applications and user experiences of the Cosmopolitan Qt Creator.
  • There were concerns regarding the size of the binaries produced and the implications for software distribution.
  • Some participants highlighted the challenges of building third-party libraries across different platforms, noting that Qt itself is generally easier to work with.
  • Philosophical objections were raised about the approach of binary distribution versus source compilation, emphasizing a preference for building from source.
  • Several comments suggested exploring alternatives like WebAssembly (WASM) for better cross-platform compatibility.
Link Icon 16 comments
By @TimSchumann - 4 months
Made possible using Cosmopolitan Libc.

Justine writes some pretty cool software.

https://justine.lol/cosmopolitan/index.html

By @norir - 4 months
I have a philosophical objection to this approach, while respecting the technical achievement. For me, the ideal distribution of software is always by source. The only reason I wouldn't want this is if compilation is prohibitively expensive. But I have found that usually this is only the case for truly massive projects like chrome or projects with heavy dependencies. Most c programs can be compiled in at most a few minutes but usually just a few seconds (luajit and sqlite come to mind as being in the seconds camp). The big problem is that culturally we have accepted too many dependencies in libraries and this has made building too slow and has made binary distribution feel necessary. It is actually much faster on my computer to build neovim from source than upgrading it from homebrew if the upgrade triggers a cascade of dependency updates (which basically seems to happen every time I update anything using homebrew).

I also can't envision a common scenario in which I would have a machine that doesn't have a c compiler but I would be able to run an APE executable. Even in that uncommon case, I still think I would be better off using software that I could compile with a standards compliant c compiler and ship the binary that _I_ built myself to the machine that lacked a c compiler.

By @comex - 4 months
Key point:

> running with the vnc QPA

The demo they have running has no native display or input support; it just serves the interface over a socket via VNC.

By @justinclift - 4 months
> The size of the Cosmopolitan Qt Creator binary is around 230 megabytes

While it's kind of expected it'd be big... that's really large. :(

By @mseepgood - 4 months
The title: "Compile once" The transcript: "Cosmopolitan applications are compiled twice"
By @al2o3cr - 4 months
Interesting approach, but the results seem as rough as they usually are regarding cross-platform UX.

For instance, check out the demo on slide 10: now you can have janky sliders that don't match the platform's version on every platform!

By @zorgmonkey - 4 months
The codereview of the WIP patches are a nice read. They do a good job of showing how quirky Cosmopolitan Libc is. To be clear I think it is awesome, just don't expect porting to it to be pain-free.

https://codereview.qt-project.org/c/qt/qtbase/+/581112

By @api - 4 months
I respect this a lot as an impressive hack, but it's really sad that in 2024 we are headed toward a "statically link the entire universe" approach to software distribution because OSes have failed to provide good consistency, stability, or portability.

WASM could solve all this, but that would mean all OSes would need WASM runtimes that supported a consistent set of standards and APIs. Have fun getting that to happen.

By @SebaSeba - 4 months
Should there be a link to some video or podcast somewhere there? I can only see a link to a pdf file.
By @jlarocco - 4 months
This is a neat idea.

Generally, though, third party libraries are the biggest problem I've had building Qt apps on different platforms. Qt itself "just works," but getting arbitrary open source libraries building on OSX and Windows can be a pain.

By @metadat - 4 months
> Qt QPA VNC platform.

I've not heard of this before. Who is using it and for what? And how?

Also, who / what is .Adam?

By @notorandit - 4 months
Why? To make it simpler to distribute binaries? What is the use case share for portable binaries across platforms? The platform check is to be run at every single run, not just once, if I am not mistaken. I thought we were aiming at efficiency.

It is an interesting and intriguing technology, but pretty useless if not even dangerous, IMHO.

By @CrendKing - 4 months
The page 8 ("Building") of the slides has the badger picture to the right. His right hand has some weird "nails". Another example of AI-generated image.
By @jenadine - 4 months
Why not wasm?