MuseScore icon indicating copy to clipboard operation
MuseScore copied to clipboard

[MU4 Task] Make cmake build `crashpad_handler`?

Open doronbehar opened this issue 2 years ago • 8 comments

Describe the bug

Here on NixOS, we can't run executables that are dynamically linked to libraries located at generic places, such as /lib/libcrypto.so.1.1. We consider this behavior a feature, and not a bug, as it allows us to know precisely what are the inputs and what are the dependencies of all of our packages.

From some reason, when we try to update to MU4 in our distribution, the crashpad_handler binary doesn't link well when we compile MU4. See https://github.com/NixOS/nixpkgs/pull/206559 .

To Reproduce

  1. Install Nix
  2. git clone https://github.com/doronbehar/nixpkgs -b pkg/musescore
  3. Remove the CRASHPAD_CLIENT=OFF line somewhere at: https://github.com/doronbehar/nixpkgs/blob/pkg/musescore/pkgs/applications/audio/musescore/default.nix#L30
  4. Compile MU4 with nix build -Lf. musescore
  5. Run ./result/bin/mscore.

Expected behavior

mscore would not fail to launch as described here:

https://github.com/NixOS/nixpkgs/pull/206559#issue-1501436429

Platform information

  • OS: NixOS

Additional context

We currently chose to disable the usage of crashpad_handler, via -DBUILD_CRASHPAD_CLIENT=OFF but we noticed cmake still installs it. We would like to make it either compile on NixOS, or not get installed at all if it's not mandatory.

doronbehar avatar Dec 24 '22 19:12 doronbehar

@doronbehar Please see #15577; does that help?

cbjeukendrup avatar Dec 25 '22 00:12 cbjeukendrup

@doronbehar Please see #15577; does that help?

It helps, but it'd still be nice if we could debug why does the crashpad client doesn't link properly on NixOS, and not close this issue.

doronbehar avatar Dec 25 '22 15:12 doronbehar

Maybe the problem is that crashpad_handler is a precompiled binary file that lives in our repo. So even if you compile MuseScore in a special way to work without /lib/libcrypto.so.1.1 etc, this won't help for crashpad.

Does that bring you any further? I'm not sure I understand enough about NixOS and what's needed to make apps work on it to say sensible things about it...

cbjeukendrup avatar Dec 25 '22 15:12 cbjeukendrup

Where does the crashpad_handler precompiled binary live in the repo? I tried ldd-ing every file but I can’t find one.

schuelermine avatar Dec 25 '22 16:12 schuelermine

Oh, nevermind, I found it. It’s in src/diagnostics/crashpad_handler/linux/x86-64/crashpad_handler

schuelermine avatar Dec 25 '22 16:12 schuelermine

Does that bring you any further?

Yes, thanks very much! This is precisely the source of our issues. Precompiled binaries don’t work on NixOS (usually). Also, we don’t compile MuseScore to work without these dynamically linked libraries, we just compile it to link to specific content-addressed locations in the Nix store.

schuelermine avatar Dec 25 '22 16:12 schuelermine

It'd be nice (since crahspad is open source), to make Musescore's build system build it. I changed the title of the issue.

doronbehar avatar Dec 25 '22 17:12 doronbehar

There was a reason that we're not doing that, but I don't know what it was... I think @igorkorsukov knows.

Anyway, for me one reason would be that it would make MuseScore's build time even longer, which is not very convenient for development, and for most people not necessary because for them the binaries work fine. (Of course, in local incremental builds it won't need to be recompiled often, but it does make pull request checks more time consuming.)

However, I can try if we can make it optional, for example by adding a CMake option like BUILD_CRASHPAD_HANDLER_FROM_SOURCE.

cbjeukendrup avatar Dec 25 '22 17:12 cbjeukendrup

Or maybe the crashpad binary could be provided from outside, and an option similar to USE_SYSTEM_FREETYPE could exist.

schuelermine avatar Dec 25 '22 18:12 schuelermine

It looks like it is possible to include building the crashpad_handler in MuseScore's build system, but it's gonna be a lot of work (I guess that's also why the solution with the binaries was chosen). Biggest problem is that they use a custom build system, so we need to rewrite that in CMake. It looks like their build logic is not hugely complicated, so it is doable, but still quite a bit of work.

Would it be helpful if I add an option to specify the path to a custom crashpad_handler executable, so that you guys can create one for NixOS and let MuseScore use that? I'm sorry to ask you to do the "dirty work" of compiling crashpad_handler, but for MuseScore this seems the best solution.

cbjeukendrup avatar Dec 25 '22 18:12 cbjeukendrup

Yeah, we’re happy to do the dirty work of compiling crashpad_handler

schuelermine avatar Dec 25 '22 19:12 schuelermine

I was also wondering, what functionality do we lose when we disable crashpad?

On 25 December 2022 21:58:22 GMT+02:00, "Anselm Schüler" @.***> wrote:

Yeah, we’re happy to do the dirty work of compiling crashpad_handler! That’s the whole point of nixpkgs, our package repository.

-- > Reply to this email directly or view it on GitHub:

https://github.com/musescore/MuseScore/issues/15571#issuecomment-1364731166

You are receiving this because you were mentioned.

Message ID: @.***>

doronbehar avatar Dec 25 '22 20:12 doronbehar

It's only an automatic crash reporting tool that runs in the background, so disabling it is probably not a great loss for users.

cbjeukendrup avatar Dec 25 '22 23:12 cbjeukendrup

Anyway, I've added the option to specify a custom crashpad_handler path in #15577. So when that is merged, you can choose what to do.

cbjeukendrup avatar Dec 26 '22 00:12 cbjeukendrup

Thank you very much

schuelermine avatar Dec 26 '22 01:12 schuelermine

It looks like it is possible to include building the crashpad_handler in MuseScore's build system, but it's gonna be a lot of work (I guess that's also why the solution with the binaries was chosen). Biggest problem is that they use a custom build system, so we need to rewrite that in CMake. It looks like their build logic is not hugely complicated, so it is doable, but still quite a bit of work.

yes, it is for this reason that precompiled binary files are used, and not the source code build. And it is also true that most of the build sources of this tool are not needed, and the build time will be longer for everyone.

I approved and merged https://github.com/musescore/MuseScore/pull/15577

igorkorsukov avatar Dec 26 '22 15:12 igorkorsukov