cppalliance / mrdocs

MrDocs: A Clang/LLVM tool for building reference documentation from C++ code and javadoc comments.
https://mrdocs.com
Other
66 stars 16 forks source link

Statically linked executable #547

Closed alandefreitas closed 1 month ago

alandefreitas commented 3 months ago

Because of how time-consuming it is to build mrdocs, the way mrdocs is supposed to be used is with scripts that download portable executables and run the tool. These scripts will usually be run in CI on some ubuntu-X container. So we need to provide portable executables people can use.

The problem is we're using recent versions of ubuntu (ubuntu 23.04 now) because of the C++ features we need but users (including the boost release scripts) are usually using earlier versions of ubuntu (usually from 18.04 to 22.04) for a variety of reasons. And binaries built on ubuntu X (say 23.04) don't work under ubuntu <X (say 20.04).

I read about the solutions people proposed in #boost and wrote this summary of alternatives to the problem. I'm initially tempted to experiment with musl and a system libs wrapper.

Most solutions above would require us to rebuild all dependencies with -static/musl/cosmopolitan/-ffreestanding and might end up depending on other tools. Each solution is also quite complex and with lots of caveats. There's no way to know if it's going to work before testing.

1) Some people reported -static/-static-libgcc worked sometimes

alandefreitas commented 3 months ago

Update:

1) ❌ -static-libgcc won't work for us because libc is part of the kernel. 2) ❌musl won't work with the C++ version we need. The latest C++/musl toolchain is GCC 11. 3) ❌Cosmopolitan is very experimental and attempts to be much more general than what we need 4) A wrapper is still an option 5) ❌ffreestanding won't work for us because we need access to all C++ features 6) ❌Mrdocs downgrading ubuntu is still an option but it's very hard to achieve (I tried to achieve this for weeks in https://github.com/cppalliance/mrdocs/pull/562) 7) ❌ApBuild is not being maintained

So we're left with 4) the wrapper and 6) adjusting Ubuntu versions.

I'll first experiment with the possibility of installing a recent version of Clang and libc++ on Ubuntu 20.04 and building MrDocs this way. MrDocs would use libc++. If that works, we can use that as the official Linux release, which will work on Ubuntu >20.04. This should solve the problem with Boost release-tools.

alandefreitas commented 2 months ago

As described in https://github.com/cppalliance/mrdocs/pull/562#issuecomment-2052609850, solution 6 (Mrdocs downgrading ubuntu) didn't work very well: it's overly complex, hard to maintain, slow to test, not general enough, and it just failed to work properly.

Considering these limitations, the next idea I'll explore to solve #547 is solution (4) a wrapper overriding system libs. This strategy is somewhat similar to what APBuild does but it's manual and more stable. It's similar to how CMake provides its binaries. It basically consists of patching the release so that:

This has the following benefits: