diff --git a/pkgs/by-name/pi/picolibc/package.nix b/pkgs/by-name/pi/picolibc/package.nix index a77b0bbb5873..b3e2d3f2fd91 100644 --- a/pkgs/by-name/pi/picolibc/package.nix +++ b/pkgs/by-name/pi/picolibc/package.nix @@ -8,101 +8,12 @@ nix-update-script, pkgsCross, - # General Build Options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L40 multilib ? true, multilib-list ? [ ], multilib-exclude ? [ ], - sanitize-bounds ? false, - sanitize-undefined ? false, - sanitize-trap-on-error ? false, - sanitize-allow-missing ? false, - profile ? false, - analyzer ? false, - assert-verbose ? true, - fast-strcmp ? true, - sanitize ? "none", - - # Testing options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L87 - picolib ? stdenvNoLibc.hostPlatform.isNone, - semihost ? stdenvNoLibc.hostPlatform.isNone, - fake-semihost ? true, - - # Stdio Options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L125 - io-c99-formats ? true, - io-long-long ? false, - io-pos-args ? false, - io-long-double ? false, - - # Tinystdio options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L129 - io-float-exact ? true, - atomic-ungetc ? true, - posix-console ? !stdenvNoLibc.hostPlatform.isNone, - format-default ? "double", - printf-aliases ? true, - io-percent-b ? false, - printf-small-ultoa ? true, - printf-percent-n ? false, - minimal-io-long-long ? false, - fast-bufio ? false, - io-wchar ? false, - stdio-locking ? false, - have-fcntl ? false, - fstat-bufsiz ? false, - - # Internationalization options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L166 - mb-capable ? false, - mb-extended-charsets ? false, - mb-ucs-charsets ? "auto", - mb-iso-charsets ? "auto", - mb-jis-charsets ? "auto", - mb-windows-charsets ? "auto", - - # Startup/shutdown options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L180 - picocrt ? stdenvNoLibc.hostPlatform.isNone, - picocrt-enable-mmu ? true, - picocrt-lib ? true, - initfini-array ? true, - initfini ? false, - crt-runtime-size ? false, - - # Legacy (non-picoexit) startup/shutdown options - - # Malloc options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L194 - enable-malloc ? true, - malloc-clear-freed ? false, - internal-heap ? 0, - - # Locking options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L206 - single-thread ? false, - - # TLS storage options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L209 - thread-local-storage ? "picolibc", - thread-local-storage-api ? true, - tls-model ? if stdenvNoLibc.hostPlatform.isNone then "local-exec" else "global-dynamic", - newlib-global-errno ? false, - errno-function ? if stdenvNoLibc.hostPlatform.isNone then "false" else "auto", - tls-rp2040 ? false, - stack-protector-guard ? "auto", - - # Math options - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/meson_options.txt#L225 - newlib-obsolete-math ? "auto", - newlib-obsolete-math-float ? "auto", - newlib-obsolete-math-double ? "auto", - want-math-errno ? false, }: -let - inherit (lib.strings) mesonBool mesonOption; +let canExecute = stdenvNoLibc.buildPlatform.canExecute stdenvNoLibc.hostPlatform; in stdenvNoLibc.mkDerivation (finalAttrs: { @@ -122,7 +33,7 @@ stdenvNoLibc.mkDerivation (finalAttrs: { hash = "sha256-9xFkUZJJ2ikyi4/m5B+oDa5Zznm/1aPa8El2JLEZBE8="; }; - depsBuildBuild = lib.optionals (stdenvNoLibc.buildPlatform.canExecute stdenvNoLibc.hostPlatform) [ + depsBuildBuild = lib.optionals canExecute [ buildPackages.stdenv.cc ]; @@ -131,94 +42,38 @@ stdenvNoLibc.mkDerivation (finalAttrs: { ninja ]; - # Default values taken from - # Build fails without using them. - # https://github.com/picolibc/picolibc/blob/95869670fb165e7c43e85c3d384a1e5682505244/doc/os.md?plain=1#L183 mesonFlags = [ - (mesonBool "multilib" multilib) - (mesonOption "multilib-list" (lib.concatStringsSep "," multilib-list)) - (mesonOption "multilib-exclude" (lib.concatStringsSep "," multilib-exclude)) - (mesonBool "sanitize-bounds" sanitize-bounds) - (mesonBool "sanitize-undefined" sanitize-undefined) - (mesonBool "sanitize-trap-on-error" sanitize-trap-on-error) - (mesonBool "sanitize-allow-missing" sanitize-allow-missing) - (mesonBool "profile" profile) - (mesonBool "analyzer" analyzer) - (mesonBool "assert-verbose" assert-verbose) - (mesonBool "fast-strcmp" fast-strcmp) - (mesonOption "sanitize" sanitize) + # Always non-default from upstream + (lib.mesonBool "use-stdlib" true) + (lib.mesonOption "specsdir" "${placeholder "dev"}/lib") - # Testing options - (mesonBool "picolib" picolib) - (mesonBool "semihost" semihost) - (mesonBool "fake-semihost" fake-semihost) - (mesonBool "use-stdlib" true) + # Multi-lib (cross-compilation) + (lib.mesonBool "multilib" multilib) + (lib.mesonOption "multilib-list" (lib.concatStringsSep "," multilib-list)) + (lib.mesonOption "multilib-exclude" (lib.concatStringsSep "," multilib-exclude)) - # Install options - (mesonOption "specsdir" "${placeholder "dev"}/lib") - - (mesonBool "io-c99-formats" io-c99-formats) - (mesonBool "io-long-long" io-long-long) - (mesonBool "io-pos-args" io-pos-args) - (mesonBool "io-long-double" io-long-double) - - (mesonBool "io-float-exact" io-float-exact) - (mesonBool "atomic-ungetc" atomic-ungetc) - (mesonBool "posix-console" posix-console) - (mesonOption "format-default" format-default) - (mesonBool "printf-aliases" printf-aliases) - (mesonBool "io-percent-b" io-percent-b) - (mesonBool "printf-small-ultoa" printf-small-ultoa) - (mesonBool "printf-percent-n" printf-percent-n) - (mesonBool "minimal-io-long-long" minimal-io-long-long) - (mesonBool "fast-bufio" fast-bufio) - (mesonBool "io-wchar" io-wchar) - (mesonBool "stdio-locking" stdio-locking) - (mesonBool "have-fcntl" have-fcntl) - (mesonBool "fstat-bufsiz" fstat-bufsiz) - - (mesonBool "mb-capable" mb-capable) - (mesonBool "mb-extended-charsets" mb-extended-charsets) - (mesonOption "mb-ucs-charsets" mb-ucs-charsets) - (mesonOption "mb-iso-charsets" mb-iso-charsets) - (mesonOption "mb-jis-charsets" mb-jis-charsets) - (mesonOption "mb-windows-charsets" mb-windows-charsets) - - (mesonBool "picocrt" picocrt) - (mesonBool "picocrt-enable-mmu" picocrt-enable-mmu) - (mesonBool "picocrt-lib" picocrt-lib) - (mesonBool "initfini-array" initfini-array) - (mesonBool "initfini" initfini) - (mesonBool "crt-runtime-size" crt-runtime-size) - - (mesonBool "enable-malloc" enable-malloc) - (mesonBool "malloc-clear-freed" malloc-clear-freed) - (mesonOption "internal-heap" (toString internal-heap)) - - (mesonBool "single-thread" single-thread) - - (mesonOption "thread-local-storage" thread-local-storage) - (mesonBool "thread-local-storage-api" thread-local-storage-api) - (mesonOption "tls-model" tls-model) - (mesonBool "newlib-global-errno" newlib-global-errno) - (mesonOption "errno-function" errno-function) - (mesonBool "tls-rp2040" tls-rp2040) - (mesonOption "stack-protector-guard" stack-protector-guard) - - (mesonOption "newlib-obsolete-math" newlib-obsolete-math) - (mesonOption "newlib-obsolete-math-float" newlib-obsolete-math-float) - (mesonOption "newlib-obsolete-math-double" newlib-obsolete-math-double) - (mesonBool "want-math-errno" want-math-errno) + # Platform-dependent: picolibc defaults are for bare-metal; adjust for + # hosted (non-none) platforms. + (lib.mesonBool "picolib" stdenvNoLibc.hostPlatform.isNone) + (lib.mesonBool "semihost" stdenvNoLibc.hostPlatform.isNone) + (lib.mesonBool "picocrt" stdenvNoLibc.hostPlatform.isNone) + (lib.mesonBool "posix-console" (!stdenvNoLibc.hostPlatform.isNone)) + (lib.mesonOption "tls-model" ( + if stdenvNoLibc.hostPlatform.isNone then "local-exec" else "global-dynamic" + )) + (lib.mesonOption "errno-function" ( + if stdenvNoLibc.hostPlatform.isNone then "false" else "auto" + )) ] - ++ lib.optionals finalAttrs.finalPackage.doCheck [ - (mesonBool "tests" true) - (mesonBool "native-tests" canExecute) - (mesonBool "native-math-tests" canExecute) + ++ lib.optionals finalAttrs.doCheck [ + (lib.mesonBool "tests" true) + (lib.mesonBool "native-tests" canExecute) + (lib.mesonBool "native-math-tests" canExecute) # Something is broken with this and I'm not sure what. - (mesonOption "tests-cdefs" "false") + (lib.mesonOption "tests-cdefs" "false") ]; - doCheck = canExecute; + doCheck = stdenvNoLibc.buildPlatform.canExecute stdenvNoLibc.hostPlatform; passthru = { updateScript = nix-update-script { };