LadybirdBrowser / ancient-history

The Ladybird web browser
BSD 2-Clause "Simplified" License
1.62k stars 109 forks source link

macOS build fails due to being unable to dynamically load liblagom-webview.0.dylib #130

Closed TomasHubelbauer closed 1 year ago

TomasHubelbauer commented 1 year ago

Hi, I wanted to try out Ladybird so I checked out the build instructions and figured out that I could be cheeky and take a shortcut by instead of setting up all of the environment and dependencies, I could just fork the repository, update the CI workflow file to add a step to drop the built binary as an artifact and then download it and try it out as a user. So that's what I did!

https://github.com/TomasHubelbauer/ladybird/actions/runs/3483468763#artifacts Here's my run with the Ubuntu and macOS artifacts.

After downloading the macOS artifact and making the application executable by running chmod +x ladybird.app/Contents/MacOS/ladybird and enabling Ladybird to run in macOS Security settings, I was greeted with a crash screen.

The crash screen mentioned that this dynamic library was not found: liblagom-webview.0.dylib. I wanted to copy the rest of the details, but now when I run Ladybird again, it doesn't come up anymore, it just silently exits.

I didn't realize Ladybird would be dynamically linking stuff that I'd only have if I set up the build environment beforehand. That's a fair thing to happen so if there is no way to run Ladybird without doing that, that's my loss. However I noticed that the Lagom related mentions in the build instructions are all Android specific? So I wonder if I can make Ladybird run without it, somehow?

ADKaster commented 1 year ago

That likely won't work. You'd need to apply some version of my patches from the open "make macOS happier" PR, and copy the entire prefix result of a ninja install. Lagom libraries are the implementation of the actual web engine, ladybird is just a GUI frontend. Lagom in this case is just the name for the non-serenity build of all the serenity libraries.

TomasHubelbauer commented 1 year ago

Ah, okay! Seems like a dead-end, then, to try in this direction. Thanks for letting me know! I am going to close this issue as it doesn't seem like there is much use in keeping it open.

ADKaster commented 1 year ago

I mean you could specify -DBUILD_SHARED_LIBS=OFF to CMake in the CI steps, but you'd still need

1) ladybird (obv) 2) WebContent, the helper process that runs sandboxed rendering 3) the resources from /res that get copied from serenity/Base/res/ (or set via env variable) such as icons, fonts, etc.

So while making a distribution/bundle for macOS using the current CI as a base is certainly possible, it's probably faster to just make sure you have xcode 14 installed and build from source

TomasHubelbauer commented 1 year ago

I am too unfamiliar with the existing tooling to have confidence I'd be able to get this done, frankly. Trying to build from source seems like a better strategy. I don't like to install too many random and for my purposes essentially one-off tools to my main macOS installation thought, so I will set up a parallel partition and installation for this, first. Then I should be good to go.

mabis commented 1 year ago

FWIW I have no problems in building it daily on macOS (currently on Ventura, previously on Maverick, both on M1 cpu) with the simple steps found in https://github.com/SerenityOS/ladybird/blob/master/Documentation/BuildInstructions.md

Since I already had everything xcode and cmake installed I only needed to install one thing (ninja) and nothing else

TomasHubelbauer commented 1 year ago

@ADKaster I decided to try passing DBUILD_SHARED_LIBS to cmake but I got this error:

cmake --build build -DBUILD_SHARED_LIBS=OFF
Unknown argument -DBUILD_SHARED_LIBS=OFF
Usage: …
Options: …

I saw a reference to this option in #56 as well. The person there was passing it the same way. Is this the right way to pass it to CMake?

Also, what did you mean by steps 2 and 3 in your message? For 1, I am building the binary, so that's fine. For 2, how do I get WebContent? And for 3, what do I do with those resources in terms of getting a runnable build off the CI script? Do I need to place them side by side with the compiled binary because it looks for them based on their relative paths?

TomasHubelbauer commented 1 year ago

@mabis Thanks, I will eventually look into the local build, I just don't want to install Ninja to my main installation so I am planning on setting up a separate partition for this.

ADKaster commented 1 year ago

That's not how CMake works

There's two phases of using CMake: configure, and build. At a high level the configure stage sets build flags, and the build stage actually runs the build. The configuration stage creates a build with your chosen build system (Makefiles, ninja, xcode, etc) in the binary directory with a "cache" of flags that were set at configure time.

BUILD_SHARED_LIBS is a configuration flag. Have a look at serenity/Documentation/AdvancedBuildInstructions.md for a more detailed overview on how to set those with some more references.

What I really meant was, don't try to hack up the build without understanding the pieces. Run cmake --install build --prefix=$PWD/ladybird-install and look at the files that are dropped into bundle/ladybird.app. every single file there is required