55 meson ,
66 ninja ,
77 nix-update-script ,
8+ pkgsCross ,
89
910 # General Build Options
11+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L40-L57
1012 multilib ? true ,
13+ sanitize-bounds ? false ,
14+ sanitize-trap-on-error ? false ,
15+ profile ? false ,
16+ analyzer ? false ,
17+ assert-verbose ? true ,
18+ fast-strcmp ? true ,
19+
20+ # Testing options
21+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L75
22+ picolib ? stdenv . hostPlatform . isNone ,
23+ semihost ? stdenv . hostPlatform . isNone ,
24+
25+ # Stdio Options
26+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L114
27+ tinystdio ? true ,
28+ io-c99-formats ? true ,
29+ io-long-long ? false ,
30+ io-pos-args ? false ,
31+ io-long-double ? false ,
32+
33+ # Tinystdio options
34+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L129
35+ io-float-exact ? true ,
36+ atomic-ungetc ? true ,
37+ posix-console ? ! stdenv . hostPlatform . isNone ,
38+ format-default ? "double" ,
39+ printf-aliases ? true ,
40+ io-percent-b ? false ,
41+ printf-small-ultoa ? true ,
42+ printf-percent-n ? false ,
43+ minimal-io-long-long ? false ,
44+ fast-bufio ? false ,
45+ io-wchar ? false ,
46+
47+ # Internaltionalization options
48+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L181
49+ mb-capable ? false ,
50+ mb-extended-charsets ? false ,
51+ mb-ucs-charsets ? "auto" ,
52+ mb-iso-charsets ? "auto" ,
53+ mb-jis-charsets ? "auto" ,
54+ mb-windows-charsets ? "auto" ,
55+
56+ # Startup/shutdown options
57+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L198
58+ picocrt ? stdenv . hostPlatform . isNone ,
59+ picocrt-enable-mmu ? true ,
60+ picocrt-lib ? true ,
61+ picoexit ? true ,
62+ initfini-array ? true ,
63+ crt-runtime-size ? false ,
64+
65+ # Legacy (non-picoexit) startup/shutdown options
66+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L217
67+ newlib-atexit-dynamic-alloc ? false ,
68+ newlib-global-atexit ? ! stdenv . hostPlatform . isNone ,
69+ newlib-register-fini ? false ,
70+
71+ # Malloc options
72+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L228
73+ newlib-nano-malloc ? true ,
74+ nano-malloc-clear-freed ? false ,
75+
76+ # Locking options
77+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L237
78+ single-thread ? false ,
79+
80+ # TLS storage options
81+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L244
82+ thread-local-storage ? "picolibc" ,
83+ tls-model ? if stdenv . hostPlatform . isNone then "local-exec" else "global-dynamic" ,
84+ newlib-global-errno ? false ,
85+ errno-function ? if stdenv . hostPlatform . isNone then "false" else "auto" ,
86+ tls-rp2040 ? false ,
87+
88+ # Math options
89+ # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/meson_options.txt#L261
90+ want-math-errno ? false ,
1191} :
1292let
1393 inherit ( lib . strings ) mesonBool mesonOption ;
94+
95+ canExecute = stdenv . buildPlatform . canExecute stdenv . hostPlatform ;
1496in
1597stdenv . mkDerivation ( finalAttrs : {
16- name = "picolibc" ;
98+ pname = "picolibc" ;
1799 version = "1.8.9" ;
18100 strictDeps = true ;
19101
@@ -24,8 +106,8 @@ stdenv.mkDerivation (finalAttrs: {
24106
25107 src = fetchFromGitHub {
26108 owner = "picolibc" ;
27- repo = "picolibc" ;
28- rev = "db4d0fe5952d5ecd714781e3212d4086d970735a" ;
109+ repo = finalAttrs . pname ;
110+ tag = finalAttrs . version ;
29111 hash = "sha256-W1zK9mLMfi5pbOpbSLxiB2qKdiyNjOSQu96NM94/fcY=" ;
30112 } ;
31113
@@ -34,19 +116,83 @@ stdenv.mkDerivation (finalAttrs: {
34116 ninja
35117 ] ;
36118
119+ # Default values taken from
120+ # Build fails without using them.
37121 # https://github.com/picolibc/picolibc/blob/e57b766cb5d80f23c20d05ab067001d85910f927/doc/os.md?plain=1#L183
38- mesonFlags = [
39- ( mesonBool "multilib" multilib )
40- ( mesonOption "specsdir" "${ placeholder "dev" } /lib" )
41- ( mesonOption "tls-model" "global-dynamic" )
42- ( mesonOption "errno-function" "auto" )
43- ( mesonBool "picolib" false )
44- ( mesonBool "picocrt" false )
45- ( mesonBool "semihost" false )
46- ( mesonBool "use-stdlib" true )
47- ( mesonBool "posix-console" true )
48- ( mesonBool "newlib-global-atexit" true )
49- ] ;
122+ mesonFlags =
123+ [
124+ ( mesonBool "multilib" multilib )
125+ ( mesonBool "sanitize-bounds" sanitize-bounds )
126+ ( mesonBool "sanitize-trap-on-error" sanitize-trap-on-error )
127+ ( mesonBool "profile" profile )
128+ ( mesonBool "analyzer" analyzer )
129+ ( mesonBool "assert-verbose" assert-verbose )
130+ ( mesonBool "fast-strcmp" fast-strcmp )
131+
132+ # Testing options
133+ ( mesonBool "picolib" picolib )
134+ ( mesonBool "semihost" semihost )
135+ ( mesonBool "use-stdlib" true )
136+
137+ # Install options
138+ ( mesonOption "specsdir" "${ placeholder "dev" } /lib" )
139+
140+ ( mesonBool "tinystdio" tinystdio )
141+ ( mesonBool "io-c99-formats" io-c99-formats )
142+ ( mesonBool "io-long-long" io-long-long )
143+ ( mesonBool "io-pos-args" io-pos-args )
144+ ( mesonBool "io-long-double" io-long-double )
145+
146+ ( mesonBool "io-float-exact" io-float-exact )
147+ ( mesonBool "atomic-ungetc" atomic-ungetc )
148+ ( mesonBool "posix-console" posix-console )
149+ ( mesonOption "format-default" format-default )
150+ ( mesonBool "printf-aliases" printf-aliases )
151+ ( mesonBool "io-percent-b" io-percent-b )
152+ ( mesonBool "printf-small-ultoa" printf-small-ultoa )
153+ ( mesonBool "printf-percent-n" printf-percent-n )
154+ ( mesonBool "minimal-io-long-long" minimal-io-long-long )
155+ ( mesonBool "fast-bufio" fast-bufio )
156+ ( mesonBool "io-wchar" io-wchar )
157+
158+ ( mesonBool "mb-capable" mb-capable )
159+ ( mesonBool "mb-extended-charsets" mb-extended-charsets )
160+ ( mesonOption "mb-ucs-charsets" mb-ucs-charsets )
161+ ( mesonOption "mb-iso-charsets" mb-iso-charsets )
162+ ( mesonOption "mb-jis-charsets" mb-jis-charsets )
163+ ( mesonOption "mb-windows-charsets" mb-windows-charsets )
164+
165+ ( mesonBool "picocrt" picocrt )
166+ ( mesonBool "picocrt-enable-mmu" picocrt-enable-mmu )
167+ ( mesonBool "picocrt-lib" picocrt-lib )
168+ ( mesonBool "picoexit" picoexit )
169+ ( mesonBool "newlib-initfini-array" initfini-array )
170+ ( mesonBool "crt-runtime-size" crt-runtime-size )
171+
172+ ( mesonBool "newlib-atexit-dynamic-alloc" newlib-atexit-dynamic-alloc )
173+ ( mesonBool "newlib-global-atexit" newlib-global-atexit )
174+ ( mesonBool "newlib-register-fini" newlib-register-fini )
175+
176+ ( mesonBool "newlib-nano-malloc" newlib-nano-malloc )
177+ ( mesonBool "nano-malloc-clear-freed" nano-malloc-clear-freed )
178+
179+ ( mesonBool "newlib-multithread" ( ! single-thread ) )
180+
181+ ( mesonOption "thread-local-storage" thread-local-storage )
182+ ( mesonOption "tls-model" tls-model )
183+ ( mesonBool "newlib-global-errno" newlib-global-errno )
184+ ( mesonOption "errno-function" errno-function )
185+ ( mesonBool "tls-rp2040" tls-rp2040 )
186+
187+ ( mesonBool "want-math-errno" want-math-errno )
188+ ]
189+ ++ lib . optionals finalAttrs . doCheck [
190+ ( mesonBool "tests" true )
191+ # Something is broken with this and I'm not sure what.
192+ ( mesonOption "tests-cdefs" "false" )
193+ ] ;
194+
195+ doCheck = canExecute ;
50196
51197 passthru = {
52198 updateScript = nix-update-script { } ;
0 commit comments