ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

NixOS build broken

Open quentinmit opened this issue 1 year ago • 18 comments

I think as a result of b36ab480bf2c46ae9b327dc091d2e0813e3c8197 and/or 1e3e36af11bafd1f8a6fbdd4b5a6f9c93b3c8a07, the nix develop environment no longer functions:

$ ./Meta/ladybird.sh run ladybird
~/Software/ladybird/Toolchain/Tarballs ~/Software/ladybird/Toolchain
Preset CMake variables:

  CMAKE_BUILD_TYPE="RelWithDebInfo"
  CMAKE_TOOLCHAIN_FILE="/home/quentin/Software/ladybird/Toolchain/Tarballs/vcpkg/scripts/buildsystems/vcpkg.cmake"
  SERENITY_CACHE_DIR="/home/quentin/Software/ladybird/Build/caches"
  VCPKG_INSTALL_OPTIONS="--no-print-usage"
  VCPKG_OVERLAY_TRIPLETS="/home/quentin/Software/ladybird/Meta/CMake/vcpkg/release-triplets"

Preset environment variables:

  LADYBIRD_SOURCE_DIR="/home/quentin/Software/ladybird"
  VCPKG_BINARY_SOURCES="clear;files,/home/quentin/Software/ladybird/Toolchain/Build/vcpkg-binary-cache,readwrite"
  VCPKG_ROOT="/home/quentin/Software/ladybird/Toolchain/Tarballs/vcpkg"

-- Running vcpkg install
Could not start dynamically linked executable: /home/quentin/Software/ladybird/Toolchain/Tarballs/vcpkg/vcpkg
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
-- Running vcpkg install - failed
CMake Error at Toolchain/Tarballs/vcpkg/scripts/buildsystems/vcpkg.cmake:899 (message):
  vcpkg install failed.  See logs for more information:
  /home/quentin/Software/ladybird/Build/ladybird/vcpkg-manifest-install.log
Call Stack (most recent call first):
  /nix/store/vnhl4zdy7igx9gd3q1d548vwzz15a9ma-cmake-3.27.7/share/cmake-3.27/Modules/CMakeDetermineSystem.cmake:148 (include)
  CMakeLists.txt:3 (project)


CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!

This appears to be because BuildVcpkg.sh is trying to download and run a pre-compiled executable, which doesn't work on NixOS. It needs to either use the vcpkg from nix (not currently part of the dependencies in Ladybird/default.nix), build vcpkg from source instead of installing a binary, or just use the Nix-provided versions of libraries instead of the vcpkg-provided ones.

quentinmit avatar Jul 02 '24 19:07 quentinmit

Getting the same on Asahi Fedora

PaddiM8 avatar Jul 02 '24 20:07 PaddiM8

Also Alpine which uses musl instead of glibc. Can you confirm that your distros are also musl based?

This might be the same issue: https://github.com/LadybirdBrowser/ladybird/issues/93

jesusmgg avatar Jul 02 '24 23:07 jesusmgg

@jesusmgg Nope, just regular Fedora for arm with some additions/tweaks (incl. 16 KiB pages).

PaddiM8 avatar Jul 02 '24 23:07 PaddiM8

I have fixes for this locally, I can PR

easrng avatar Jul 02 '24 23:07 easrng

Fixing this properly is blocked on https://github.com/microsoft/vcpkg/issues/39641 though

easrng avatar Jul 02 '24 23:07 easrng

NixOS is not musl-based. It just doesn't install libraries in /usr/lib so pre-compiled binaries won't work.

I took a stab at trying to use native libraries instead of vcpkg, but I ran into a couple problems:

  • ladybird apparently requires icu 74 but NixOS currently ships icu 73 as default (74 is packaged as well, but somehow cmake is still finding 73 even if I put 74 in the shell)
  • Skia doesn't have any packaging (NixOS has the skia-aseprite fork packaged, but that's a couple years old and doesn't include CMake rules.)

Both of these could probably be fixed with sufficient CMake-fu, but I don't want to go through the trouble and end up with something that upstream wouldn't merge.

Incidentally, the use of vcpkg will probably also be a blocker for ladybird's inclusion in traditional distros like Debian too, since they have a strict policy of never using vendored dependencies.

quentinmit avatar Jul 02 '24 23:07 quentinmit

Fyi there are fixes for all of that here https://github.com/NixOS/nixpkgs/pull/324050. I'm waiting for icu 7.4 to reach master, then I can update the downstream ladybird package.

edit: downstream tracking issue: https://github.com/NixOS/nixpkgs/issues/325045

fgaz avatar Jul 03 '24 07:07 fgaz

@quentinmit fwiw I just packaged something else that uses skia and didn't really have any of the problems that this skia-asesprite had to work around. However as @fgaz points out in #382 skia is only available to be included via vcpkg, which while it's supported in NixOS, should not be used for actually fetching dependencies of packages (it's there to support dev environments afaict). As such #382 would be the real blocker for this issue.

(As an aside it's funny to me that the objections raised against allowing an escape hatch from vcpkg is that it would prevent reproducible builds, the raison d'être of the nix package manager in the first place)

socksy avatar Jul 05 '24 07:07 socksy

Also broken for me (NixOS) Currently waiting for the changes to propagate.

MikMuellerDev avatar Jul 09 '24 14:07 MikMuellerDev

If folks can verify that the nixpkgs build from ladybird-0-unstable-2024-07-11 works for them locally, we can close this issue with a documentation update explaining how to do that in BuildInstructionsLadybird.md

ADKaster avatar Jul 14 '24 23:07 ADKaster

I tried it and it worked for me. Ubuntu 14.04 LTS in UTM virtual machine.

philip-peterson avatar Jul 29 '24 05:07 philip-peterson

I got it to work merging changes from #738. Don't know how stable this is but it works

thomasqueirozb avatar Sep 05 '24 05:09 thomasqueirozb

I think the last thing needed to resolve this is for a PR to remove the local nix env derivation, and update the nix build instructions documentation to do something like these steps to use the nixpkgs recipe as a baseline:

  1. Enter a nix shell with either nix-shell '' -A ladybird or using the experimental commands nix develop nixpkgs#ladybird.
  2. If this fix https://nixpk.gs/pr-tracker.html?pr=335702 did not reach your channel yet, run patchPhase to work around an issue with our libwebp
  3. Build normally with cmake

There are a few dependencies we've added since the latest nixpkgs update though, and we've removed a lot of our manual downloads. In theory it should be an even simpler .nix script today than it was two months ago (I hope).

ADKaster avatar Oct 07 '24 04:10 ADKaster

git clone [email protected]:LadybirdBrowser/ladybird.git
cd ladybird
nix develop
cmake -GNinja -BBuild/release
-- Could NOT find unofficial-skia (missing: unofficial-skia_DIR)
ninja -CBuild/release
[2825/3233] Linking CXX shared library lib64/liblagom-web.so.0.0.0
FAILED: lib64/liblagom-web.so.0.0.0 
: && /nix/store/3ix5h74n7ar9950vwzp4dxmil70pmx0k-gcc-wrapper-13.3.0/bin/g++ -fPIC   -fstack-protector-strong -Wl,-z,defs -Wl,--no-undefined -Wl,--no-allow-shlib-undefined -shared -Wl,-soname,liblagom-web.so.0 -o lib64/liblagom-web.so.0.0.0 @CMakeFiles/LibWeb.rsp && :
/nix/store/va7kw1i822h95im4jacci19v0cqajfyf-binutils-2.43.1/bin/ld: Lagom/Libraries/LibWeb/CMakeFiles/LibWeb.dir/WebGL/Extensions/OESVertexArrayObject.cpp.o: undefined reference to symbol 'glIsVertexArrayOES'
/nix/store/va7kw1i822h95im4jacci19v0cqajfyf-binutils-2.43.1/bin/ld: /nix/store/ymhcg6x5jrw3hx8ik1cji6awiybgp9f7-libglvnd-1.7.0/lib/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

🥺👉👈

qm3ster avatar Jan 27 '25 17:01 qm3ster

@qm3ster

bad analysis

skia should be built by the nix shell, is that not the case? I would expect that this statement:

https://github.com/LadybirdBrowser/ladybird/blob/05351dfe45e3b7eb4c4d0a0ee69ebaf185571bdc/shell.nix#L6-L16

Instructs nix to gather all the inputs from the ladybird package in nixpkgs, and use special cflags for skia.

Edit: wait, that's not an error. Nix uses pkgconfig to create a skia to find, not unofficial-skia as vcpkg does.

If there's an issue with the .nix files in this repository, a PR or separate issue would be appropriate. Otherwise, please file an issue with nixpkgs.

Your linker error suggests that there's a gl method missing from libGLES or libGL or libEGL that we are expecting to use. Sounds like a bug report for the mesa package? glIsVertexArrayOES is from GLESv2.

ADKaster avatar Jan 27 '25 17:01 ADKaster

Adding -lGL to the linker command fixes the issue (https://github.com/NixOS/nixpkgs/pull/377738). I don't know if this is an issue with the nix libGL package or if there's a missing target_link_libraries in ladybird. Since this isn't a problem outside of nix I guess it's the former?

fgaz avatar Jan 29 '25 12:01 fgaz

-- Found OpenGL: /nix/store/rvlpzcdms824wjg8q31bdfvx35z6zf27-libglvnd-1.7.0/lib/libOpenGL.so

Is it linking against libOpenGL instead of libGL? https://github.com/NVIDIA/libglvnd/issues/63

ttrssreal avatar Feb 01 '25 19:02 ttrssreal

I was able to build Ladybird today using Nix on Ubuntu (not NixOS).

The only changes needed were to remove references to prettier, which I didn't triage. Otherwise, I was able to do nix develop; cmake -GNinja -BBuild/release; ninja -CBuild/release and then I could run the resulting Ladybird binary.

williballenthin avatar Mar 05 '25 20:03 williballenthin