SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.54k stars 3.19k forks source link

Build: Nix flakes don't seem to setup rpath for glibc or lbstdc++ correctly #22618

Open ADKaster opened 9 months ago

ADKaster commented 9 months ago

With an Ubuntu single-user install of nix, and updated via nix-channel --update; nix-env --install --attr nixpkgs.nix nixpkgs.cacert

nix (Nix) 2.18.1

Running the command from the Ladybird build docs:

nix --extra-experimental-features nix-command --extra-experimental-features flakes -- develop ./Toolchain#ladybird

and then trying to build ladybird via serenity.sh

./Meta/serenity.sh run lagom ladybird

Gives a bunch of errors about finding libstdc++

[1/2317] Generating Userland/Services/RequestServer/RequestClientEndpoint.h
FAILED: Userland/Services/RequestServer/RequestClientEndpoint.h /home/andrew/serenity/Build/lagom/Userland/Services/RequestServer/RequestClientEndpoint.h 
cd /home/andrew/serenity/Build/lagom && /home/andrew/serenity/Build/lagom/bin/IPCCompiler /home/andrew/serenity/Userland/Services/RequestServer/RequestClient.ipc -o Userland/Services/RequestServer/RequestClientEndpoint.h.tmp && /nix/store/vnhl4zdy7igx9gd3q1d548vwzz15a9ma-cmake-3.27.7/bin/cmake -E copy_if_different Userland/Services/RequestServer/RequestClientEndpoint.h.tmp Userland/Services/RequestServer/RequestClientEndpoint.h && /nix/store/vnhl4zdy7igx9gd3q1d548vwzz15a9ma-cmake-3.27.7/bin/cmake -E remove Userland/Services/RequestServer/RequestClientEndpoint.h.tmp
/home/andrew/serenity/Build/lagom/bin/IPCCompiler: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
[2/2317] Generating Userland/Services/RequestServer/RequestServerEndpoint.h
FAILED: Userland/Services/RequestServer/RequestServerEndpoint.h /home/andrew/serenity/Build/lagom/Userland/Services/RequestServer/RequestServerEndpoint.h 
cd /home/andrew/serenity/Build/lagom && /home/andrew/serenity/Build/lagom/bin/IPCCompiler /home/andrew/serenity/Userland/Services/RequestServer/RequestServer.ipc -o Userland/Services/RequestServer/RequestServerEndpoint.h.tmp && /nix/store/vnhl4zdy7igx9gd3q1d548vwzz15a9ma-cmake-3.27.7/bin/cmake -E copy_if_different Userland/Services/RequestServer/RequestServerEndpoint.h.tmp Userland/Services/RequestServer/RequestServerEndpoint.h && /nix/store/vnhl4zdy7igx9gd3q1d548vwzz15a9ma-cmake-3.27.7/bin/cmake -E remove Userland/Services/RequestServer/RequestServerEndpoint.h.tmp
/home/andrew/serenity/Build/lagom/bin/IPCCompiler: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
[3/2317] Generating Userland/Services/WebSocket/WebSocketClientEndpoint.h

Looking at the RPATH of the created binaries:

~/serenity$ readelf -d Build/lagom/bin/IPCCompiler | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:$ORIGIN/../lib:/home/andrew/serenity/outputs/out/lib]

vs one created by g++ manually

~/serenity$ readelf -d a.out | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [/home/andrew/serenity/Toolchain/outputs/out/lib:/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib:/nix/store/1z0lkblksl7niy2w5rfv265hw0fn9p1q-gcc-13.2.0-lib/lib]

We are missing the glibc and gcc paths.

So two questions:

The same errors occur with the serenity flake

cc @networkException

ADKaster commented 9 months ago

@Alizter perhaps you've got some thoughts on this as well?

linusg commented 9 months ago

Works here on NixOS:

➜  serenity git:(master) nix --version
nix (Nix) 2.18.1
➜  serenity git:(master) nixos-version
24.05.20240102.bd645e8 (Uakari)
➜  serenity git:(master) git rev-parse HEAD
63de4d3ada9effbb6a26951193a3edd4eeec7145
➜  serenity git:(master) nix develop ./Toolchain#ladybird

[linus@linus-framework:~/Dev/serenity]$ ./Meta/serenity.sh build lagom ladybird
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /nix/store/0p9jh36fqsl3pjxjrxhlvmhdj218nkgc-gcc-wrapper-13.2.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/0p9jh36fqsl3pjxjrxhlvmhdj218nkgc-gcc-wrapper-13.2.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Performing Test LAGOM_LINKER_SUPPORTS_LINKER:--gdb-index
-- Performing Test LAGOM_LINKER_SUPPORTS_LINKER:--gdb-index - Failed
-- Performing Test LAGOM_LINKER_SUPPORTS_LINKER:-Bsymbolic-non-weak-functions
-- Performing Test LAGOM_LINKER_SUPPORTS_LINKER:-Bsymbolic-non-weak-functions - Failed
-- Looking for pulse/pulseaudio.h
-- Looking for pulse/pulseaudio.h - not found
-- Removing outdated /home/linus/Dev/serenity/Build/caches/TZDB for version 2023d
-- Downloading file tzdb.tar.gz from https://data.iana.org/time-zones/releases/tzdata2023d.tar.gz
-- Extracting using cmake africa
-- Extracting using cmake antarctica
-- Extracting using cmake asia
-- Extracting using cmake australasia
-- Extracting using cmake backward
-- Extracting using cmake etcetera
-- Extracting using cmake europe
-- Extracting using cmake northamerica
-- Extracting using cmake southamerica
-- Extracting using cmake zone1970.tab
-- Found Python: /nix/store/qp5zys77biz7imbk6yy85q5pdv7qk84j-python3-3.11.6/bin/python3.11 (found version "3.11.6") found components: Interpreter 
-- Removing outdated /home/linus/Dev/serenity/Build/caches/CLDR for version 44.1.0
-- Downloading file cldr.zip from https://github.com/unicode-org/cldr-json/releases/download/44.1.0/cldr-44.1.0-json-modern.zip
-- Extracting using cmake cldr-bcp47/**
-- Extracting using cmake cldr-core/**
-- Extracting using cmake cldr-dates-modern/**
-- Extracting using cmake cldr-localenames-modern/**
-- Extracting using cmake cldr-misc-modern/**
-- Extracting using cmake cldr-numbers-modern/**
-- Extracting using cmake cldr-units-modern/**
-- Removing outdated /home/linus/Dev/serenity/Build/caches/CACERT for version 2023-12-12
-- Downloading file cacert-2023-12-12.pem from https://curl.se/ca/cacert-2023-12-12.pem
-- Removing outdated /home/linus/Dev/serenity/Build/caches/UCD for version 15.1.0
-- Downloading file UCD.zip from https://www.unicode.org/Public/15.1.0/ucd/UCD.zip
-- Extracting using cmake UnicodeData.txt
-- Extracting using cmake SpecialCasing.txt
-- Extracting using cmake CaseFolding.txt
-- Extracting using cmake extracted/DerivedGeneralCategory.txt
-- Extracting using cmake PropList.txt
-- Extracting using cmake DerivedCoreProperties.txt
-- Extracting using cmake extracted/DerivedBinaryProperties.txt
-- Extracting using cmake PropertyAliases.txt
-- Extracting using cmake PropertyValueAliases.txt
-- Extracting using cmake NameAliases.txt
-- Extracting using cmake Scripts.txt
-- Extracting using cmake ScriptExtensions.txt
-- Extracting using cmake Blocks.txt
-- Extracting using cmake emoji/emoji-data.txt
-- Extracting using cmake DerivedNormalizationProps.txt
-- Extracting using cmake auxiliary/GraphemeBreakProperty.txt
-- Extracting using cmake auxiliary/WordBreakProperty.txt
-- Extracting using cmake auxiliary/SentenceBreakProperty.txt
-- Downloading file emoji-test.txt from https://www.unicode.org/Public/emoji/15.1/emoji-test.txt
-- Downloading file IdnaMappingTable.txt from https://www.unicode.org/Public/idna/15.1.0/IdnaMappingTable.txt
-- Found Python3: /nix/store/qp5zys77biz7imbk6yy85q5pdv7qk84j-python3-3.11.6/bin/python3.11 (found version "3.11.6") found components: Interpreter 
-- Downloading file public_suffix_list.dat from https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE  
-- Found OpenGL: /nix/store/a39i17gd56l2s41j66djwz2r9yr905ja-libGL-1.7.0/lib/libOpenGL.so   
-- Found WrapOpenGL: TRUE  
-- Found XKB: /nix/store/z50cdic3kw9c0qnjyxwcx8qvv22xlgci-libxkbcommon-1.5.0/lib/libxkbcommon.so (found suitable version "1.5.0", minimum required is "0.5.0") 
-- Found WrapVulkanHeaders: /nix/store/hg6l41qmw9pl5qi24lpvhyx65c1szaxa-vulkan-headers-1.3.268.0/include  
-- Performing Test ASSERT_FAIL_HAS_INT
-- Performing Test ASSERT_FAIL_HAS_INT - Failed
-- Downloading file commonmark.spec.json from https://spec.commonmark.org/0.30/spec.json
-- Configuring done (147.6s)
-- Generating done (0.6s)
CMake Warning:
  Manually-specified variables were not used by the project:

    SERENITY_TOOLCHAIN

-- Build files have been written to: /home/linus/Dev/serenity/Build/lagom
-- Configuring done (1.2s)
-- Generating done (0.6s)
-- Build files have been written to: /home/linus/Dev/serenity/Build/lagom
ninja: Entering directory `/home/linus/Dev/serenity/Build/lagom'
[0/2] Re-checking globbed directories...
[2470/2470] Linking CXX executable bin/Ladybird

[linus@linus-framework:~/Dev/serenity]$ readelf -d Build/lagom/bin/IPCCompiler | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:$ORIGIN/../lib64:/home/linus/Dev/serenity/outputs/out/lib:/nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/lib:/nix/store/1z0lkblksl7niy2w5rfv265hw0fn9p1q-gcc-13.2.0-lib/lib]

[linus@linus-framework:~/Dev/serenity]$ 

Also works with nix develop --ignore-environment (after adding git to ladybird.nix), FWIW.