Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to build fully static toolchain #377

Open
leoluk opened this issue Feb 25, 2025 · 2 comments
Open

Attempt to build fully static toolchain #377

leoluk opened this issue Feb 25, 2025 · 2 comments
Assignees

Comments

@leoluk
Copy link
Member

leoluk commented Feb 25, 2025

We need to get rid of sandboxroot in order to make the monorepo externally consumable. The current list of dependencies lives here: https://github.com/monogon-dev/monogon/blob/main/third_party/sandboxroot/regenerate.sh

This issue explores the approach of using a fully static toolchain. Other possibilities include NixOS/rules_nixpkgs (which is less desirable due to extra host deps and complexity).

Deps we no longer need:

# Things we no longer need with Lorenz' new LLVM toolchain

  "binutils"
  "gcc"
  "glibc-static"
  "libstdc++-static"
  "clang"
  "llvm"
  "lld"
  "rsync"
  "xz"

# Bazel now ships with a static Python toolchain

  "python3"
  "python-unversioned-command"

# image_gcp rule

  "tar"

We still need:

# Kernel build

  "flex"        # pkgsStatic works
  "bison"     # pkgsStatic works
  "diffutils"  # pkgsStatic works (?)
  "bc"         # pkgsStatic works / build internally?
  "lz4"        # build internally
  "perl"       # TBD - difficult

  "elfutils-libelf-devel"   # figure out what the dep is
  "openssl-devel"         # figure out what the dep is

# EDK2

  "libuuid-devel"  # trivial
  "util-linux"         # static probably OK
  "nasm"             # build internal?
  "acpica-tools"   # static probably OK

# patch tool, as used by gazelle

  "patch"

# ktest

  "qemu-system-x86-core"  # https://github.com/ziglang/qemu-static?
  "qemu-img"                       # https://github.com/ziglang/qemu-static?
)

Related issues:

@leoluk
Copy link
Member Author

leoluk commented Feb 25, 2025

Things that appear to "just work" using pkgsStatic:

  • flex
  • bison
  • lz4
  • util-linux
  • perl (but it's going to need more than a binary)
  • nasm
  • acpica-tools
  • patch

Things that do not:

  • diffutils (binary compiles, some tests fail - probably OK)
  • qemu (nixpkgs error)

TBD:

  • elfutils-libelf-devel
  • openssl-devel

@fionera
Copy link
Contributor

fionera commented Feb 27, 2025

perl-static doesnt build too

error: builder for '/nix/store/k2kviabkrip2vsbw71n5i6p4r4a2cgvn-perl-static-x86_64-unknown-linux-musl-5.38.2.drv' failed with exit code 2;
       last 25 log lines:
       >       | ^~~~~~~~~~~~~~~~~~~~~~
       > rm -f "../../lib/auto/threads/shared/shared.a"
       > x86_64-unknown-linux-musl-ar cr "../../lib/auto/threads/shared/shared.a" shared.o
       > x86_64-unknown-linux-musl-ranlib "../../lib/auto/threads/shared/shared.a"
       > chmod 755 ../../lib/auto/threads/shared/shared.a
       > make[2]: Leaving directory '/build/perl-5.38.2/dist/threads-shared'
       > ./miniperl_top statars B Devel::Peek Fcntl File::DosGlob File::Glob Hash::Util Hash::Util::FieldHash I18N::Langinfo Opcode POSIX PerlIO::encoding PerlIO::mmap PerlIO::scalar PerlIO::via SDBM_File Sys::Hostname XS::APItest XS::Typemap attributes mro re Compress::Raw::Bzip2 Compress::Raw::Zlib Digest::MD5 Digest::SHA Encode Filter::Util::Call IPC::SysV MIME::Base64 Math::BigInt::FastCalc List::Util Socket Sys::Syslog Time::Piece Unicode::Collate Data::Dumper Devel::PPPort IO Cwd Storable Time::HiRes Unicode::Normalize threads threads::shared > static.list
       > ./miniperl_top extlibs B Devel::Peek Fcntl File::DosGlob File::Glob Hash::Util Hash::Util::FieldHash I18N::Langinfo Opcode POSIX PerlIO::encoding PerlIO::mmap PerlIO::scalar PerlIO::via SDBM_File Sys::Hostname XS::APItest XS::Typemap attributes mro re Compress::Raw::Bzip2 Compress::Raw::Zlib Digest::MD5 Digest::SHA Encode Filter::Util::Call IPC::SysV MIME::Base64 Math::BigInt::FastCalc List::Util Socket Sys::Syslog Time::Piece Unicode::Collate Data::Dumper Devel::PPPort IO Cwd Storable Time::HiRes Unicode::Normalize threads threads::shared > ext.libs
       > x86_64-unknown-linux-musl-gcc -Wl,-E -o perl perlmain.o libperl.a lib/auto/B/B.a lib/auto/Devel/Peek/Peek.a lib/auto/Fcntl/Fcntl.a lib/auto/File/DosGlob/DosGlob.a lib/auto/File/Glob/Glob.a lib/auto/Hash/Util/Util.a lib/auto/Hash/Util/FieldHash/FieldHash.a lib/auto/I18N/Langinfo/Langinfo.a lib/auto/Opcode/Opcode.a lib/auto/POSIX/POSIX.a lib/auto/PerlIO/encoding/encoding.a lib/auto/PerlIO/mmap/mmap.a lib/auto/PerlIO/scalar/scalar.a lib/auto/PerlIO/via/via.a lib/auto/SDBM_File/SDBM_File.a lib/auto/Sys/Hostname/Hostname.a lib/auto/XS/APItest/APItest.a lib/auto/XS/Typemap/Typemap.a lib/auto/attributes/attributes.a lib/auto/mro/mro.a lib/auto/re/re.a lib/auto/Compress/Raw/Bzip2/Bzip2.a lib/auto/Compress/Raw/Zlib/Zlib.a lib/auto/Digest/MD5/MD5.a lib/auto/Digest/SHA/SHA.a lib/auto/Encode/Encode.a lib/auto/Filter/Util/Call/Call.a lib/auto/IPC/SysV/SysV.a lib/auto/MIME/Base64/Base64.a lib/auto/Math/BigInt/FastCalc/FastCalc.a lib/auto/List/Util/Util.a lib/auto/Socket/Socket.a lib/auto/Sys/Syslog/Syslog.a lib/auto/Time/Piece/Piece.a lib/auto/Unicode/Collate/Collate.a lib/auto/Data/Dumper/Dumper.a lib/auto/Devel/PPPort/PPPort.a lib/auto/IO/IO.a lib/auto/Cwd/Cwd.a lib/auto/Storable/Storable.a lib/auto/Time/HiRes/HiRes.a lib/auto/Unicode/Normalize/Normalize.a lib/auto/threads/threads.a lib/auto/threads/shared/shared.a -lm -lcrypt -lpthread -ldl -lm -L/nix/store/s6xdi5khzw1i3394y5k6n7d7k64g3adp-zlib-static-x86_64-unknown-linux-musl-1.3.1/lib -lz -lrt -lpthread
       > /nix/store/yaqfbyivgpvvk74w2xj8jajw0047abrs-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: lib/auto/re/re.a(re_comp.o): in function `Perl_reg_add_data':
       > re_comp.c:(.text+0xa390): multiple definition of `Perl_reg_add_data'; libperl.a(regcomp.o):regcomp.c:(.text+0x70a0): first defined here
       > /nix/store/yaqfbyivgpvvk74w2xj8jajw0047abrs-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: lib/auto/re/re.a(re_comp.o): in function `Perl_populate_anyof_bitmap_from_invlist':
       > re_comp.c:(.text+0xa8e0): multiple definition of `Perl_populate_anyof_bitmap_from_invlist'; libperl.a(regcomp.o):regcomp.c:(.text+0x7b60): first defined here
       > /nix/store/yaqfbyivgpvvk74w2xj8jajw0047abrs-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: lib/auto/re/re.a(re_comp.o): in function `Perl_add_above_Latin1_folds':
       > re_comp.c:(.text+0xab10): multiple definition of `Perl_add_above_Latin1_folds'; libperl.a(regcomp.o):regcomp.c:(.text+0x7ce0): first defined here
       > /nix/store/yaqfbyivgpvvk74w2xj8jajw0047abrs-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: lib/auto/re/re.a(re_comp.o): in function `Perl_set_ANYOF_arg':
       > re_comp.c:(.text+0xb020): multiple definition of `Perl_set_ANYOF_arg'; libperl.a(regcomp.o):regcomp.c:(.text+0x8160): first defined here
       > /nix/store/yaqfbyivgpvvk74w2xj8jajw0047abrs-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: lib/auto/re/re.a(re_comp.o): in function `Perl_get_ANYOFM_contents':
       > re_comp.c:(.text+0xcf50): multiple definition of `Perl_get_ANYOFM_contents'; libperl.a(regcomp.o):regcomp.c:(.text+0x9d70): first defined here
       > /nix/store/yaqfbyivgpvvk74w2xj8jajw0047abrs-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: lib/auto/re/re.a(re_comp.o): in function `Perl_get_ANYOFHbbm_contents':
       > re_comp.c:(.text+0xd020): multiple definition of `Perl_get_ANYOFHbbm_contents'; libperl.a(regcomp.o):regcomp.c:(.text+0x9e40): first defined here
       > collect2: error: ld returned 1 exit status
       > make[1]: *** [Makefile:154: perl] Error 1
       > make[1]: Leaving directory '/build/perl-5.38.2'
       > make: *** [Makefile:87: all] Error 2
       For full logs, run 'nix log /nix/store/k2kviabkrip2vsbw71n5i6p4r4a2cgvn-perl-static-x86_64-unknown-linux-musl-5.38.2.drv'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants