| 17 Jan 2026 |
alexfmpe | can one use gcc instead of clang on aarch64-darwin? tried nix-build -E "with import ./. {}; pkgs.hello.override { stdenv = pkgs.gccStdenv; }" which fails with
configure:5654: checking whether the C compiler works
configure:5676: gcc conftest.c >&5
ld: library not found for -liconv
collect2: error: ld returned 1 exit status
...
configure:5728: error: C compiler cannot create executables
See 'config.log' for more details
| 16:35:46 |
K900 | Not well | 16:36:00 |
Randy Eckenrode | Does the GCC stdenv not include the SDK? It should, and libiconv should be propagated. | 16:38:25 |
Randy Eckenrode | But using GCC is a bad idea unless you have no choice. It doesn’t support availability annotations. It’s not set up to use libc++, which everything C++ on Darwin is linked against. (GCC can use it, but we don’t support that AFAIK.) | 16:40:05 |
alexfmpe | hmm I mainly wanted it to test some stuff that is currently broken ish with clang and didn't want to investigate/fix right now | 16:41:39 |
alexfmpe | it's more of a "would unlock progress on current task immediately" rather than a "I'll actually rely on this for anything" | 16:42:31 |
alexfmpe | at any rate, the libiconv error seems odd | 16:43:06 |
alexfmpe | is the expression even right? should I be overriding stdenv for hello only? | 16:44:12 |
Randy Eckenrode | The expression seems right. | 16:47:04 |
Randy Eckenrode | Can you nix develop (or whatever the equivalent is for the old CLI) the failing drv to check that the path to libiconv is there and that ld is wrapped? | 16:48:00 |
alexfmpe | $ nix-shell -E "with import ./. {}; pkgs.hello.override { stdenv = pkgs.gccStdenv; }"
Using versionCheckHook
# echo $NIX_LDFLAGS
-liconv
# which ld
/nix/store/cjkf5fm587xv34pz9zfs3q2qpvij61fz-gcc-wrapper-15.2.0/bin/ld
| 16:54:10 |
alexfmpe | fwiw, with gnuStdenv I get /usr/bin/ld | 16:56:43 |
alexfmpe | * $ nix-shell -E "with import ./. {}; pkgs.hello.override { stdenv = pkgs.gccStdenv; }"
Using versionCheckHook
# echo $NIX_LDFLAGS
-liconv
# which ld
/nix/store/cjkf5fm587xv34pz9zfs3q2qpvij61fz-gcc-wrapper-15.2.0/bin/ld
# ld
ld: library not found for -liconv
| 16:57:25 |
alexfmpe | * $ nix-shell -E "with import ./. {}; pkgs.hello.override { stdenv = pkgs.gccStdenv; }"
Using versionCheckHook
# env | grep iconv
NIX_LDFLAGS=-liconv
# which ld
/nix/store/cjkf5fm587xv34pz9zfs3q2qpvij61fz-gcc-wrapper-15.2.0/bin/ld
# ld
ld: library not found for -liconv
| 16:59:57 |
alexfmpe | * fwiw, with gnuStdenv I get /usr/bin/ld (or rather, it's unchanged) | 17:01:19 |
Randy Eckenrode | That’s definitely not right. | 17:13:04 |
alexfmpe | no clue how to debug/fix this, but up for legwork if that helps | 17:22:37 |
alexfmpe | I'm waiting for builds anyway on the next best thing to work on | 17:23:38 |
Randy Eckenrode | SDKROOT is missing, which means there is no SDK. Hmm. | 17:45:22 |
Randy Eckenrode |
gccStdenv =
if stdenv.cc.isGNU then
stdenv
else
stdenv.override {
cc = buildPackages.gcc;
allowedRequisites = null;
# Remove libcxx/libcxxabi, and add clang for AS if on darwin (it uses
# clang's internal assembler).
extraBuildInputs = lib.optional stdenv.hostPlatform.isDarwin clang.cc;
};
| 17:46:16 |
Randy Eckenrode | That’s probably not right. I guess this has been broken since the SDK rework. | 17:46:28 |
Randy Eckenrode | Should be extraBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ clang.cc apple-sdk ]. | 17:47:13 |
alexfmpe | testing | 17:47:50 |
Randy Eckenrode | Though I don’t think the clang.cc is needed anymore for as. That’s done as a script with an absolute path to clang. | 17:48:50 |
Randy Eckenrode | (Not unless something expects to invoke clang explicitly as the assembler, so it may not be worth dropping it.) | 17:50:13 |
alexfmpe | adding apple-sdk there causes -L to be passed with libiconv
echo $NIX_LDFLAGS
-liconv -L/nix/store/6nmmi317rg2bnybndbgc944dpg5cnl5a-libiconv-109.100.2/lib -L/nix/store/lgcr7kswpb1hap1vsjwrzzcqjks0xal6-libresolv-91/lib -L/nix/store/0x1fcnqb9lf6x3vcn53rxn7ijv7skg7y-libsbuf-14.1.0/lib -L/nix/store/fq0jizzyjkilz0rj3kvc1hskc7ry84ds-libutil-72/lib -L/nix/store/6nmmi317rg2bnybndbgc944dpg5cnl5a-libiconv-109.100.2/lib -L/nix/store/lgcr7kswpb1hap1vsjwrzzcqjks0xal6-libresolv-91/lib -L/nix/store/0x1fcnqb9lf6x3vcn53rxn7ijv7skg7y-libsbuf-14.1.0/lib -L/nix/store/fq0jizzyjkilz0rj3kvc1hskc7ry84ds-libutil-72/lib
| 17:51:57 |
alexfmpe | building hello now gets through configure but fails with several errors on string.h
lib/string.h:754:20: error: expected declaration specifiers or '...' before '__builtin_object_size'
754 | _GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n)
| 17:52:48 |
emily | note that GCC does not even support aarch64-darwin upstream | 17:56:47 |
emily | we basically only use it at all because nobody's gotten around to integrating Flang for Fortran yet | 17:57:17 |
alexfmpe | ouch | 17:57:27 |