22 Apr 2025 |
dramforever | you might need to write your own `crossSystem` while importing nixpkgs | 14:36:35 |
rosssmyth | I tried that well earlier and it did not work with the same error | 20:52:34 |
rosssmyth | * I tried that as well earlier and it did not work with the same error | 20:52:40 |
rosssmyth | I believe I have found the issue. While narrowing down to a minimal reproducer, it seems that passing -mthumb -mcpu=cortex-m0 -march=armv6-m with the cross-file, which should just be redundant with the armv6m toolchain, somehow messes up linking. Removing the cross file results in it compiling with the armv6m toolchain. But if the arm-embedded toolchain isn't thumb compatible, then what needs to be done to get multilib working? | 22:38:59 |
rosssmyth | Cause an embedded toolchain that only works for a specific architecture is kind of silly | 22:39:40 |
rosssmyth | Especially if it doesn't support thumb. And I would prefer not to spend 30 minutes building GCC in github actions every time CI runs | 22:40:15 |
rosssmyth | For anyone curious, here's a reproducer
https://github.com/RossSmyth/armRepro | 22:50:34 |
rosssmyth | With a patch that can be applied that should fix it | 22:50:50 |
23 Apr 2025 |
dramforever | In reply to @rosssmyth:matrix.org Cause an embedded toolchain that only works for a specific architecture is kind of silly unfortunately, this is how nixpkgs gcc works | 00:02:52 |
dramforever | the doesn't support thumb part shouldn't be happening though, that one i should take a look | 00:13:32 |
dramforever | ... are you sure pkgsCross.arm-embedded.stdenv.cc ever worked for armv6-m? | 01:04:52 |
dramforever | i'm throwing in the towel for now i have no idea how the arm embedded stuff works | 01:13:03 |
dramforever | does -march=armv6-m and -mcpu=cortex-m0 even work? | 01:41:18 |
wucke13 | @dramforever:matrix.org: you can build a GCC for a tailored target, if that helps. Takes half an hour, but the Nix infra is there | 08:42:25 |
wucke13 | If you take look at
https://github.com/NixOS/nixpkgs/blob/master/lib/systems/examples.nix
You can see that you can specify quite detailed what your target system is like. This information is passed to the GCC build for your stdenv, so even obscure targets can be built like this.
Sometimes you need some extra flags for gcc's build, these are passed via the gcc attr:
https://github.com/NixOS/nixpkgs/blob/7636fe33eae59738f5cdace9d257fb3c727a9898/lib/systems/examples.nix#L227
Once you have a sufficient target description, you can compile it all together into a nix-shell to get the toolchain, for example like this:
https://www.linkedin.com/safety/go?url=https%3A%2F%2Fgist.github.com%2Fwucke13%2F123536af7cfdab7083a2173a064489d2
| 08:53:36 |
wucke13 | * If you take look at
https://github.com/NixOS/nixpkgs/blob/master/lib/systems/examples.nix
You can see that you can specify quite detailed what your target system is like. This information is passed to the GCC build for your stdenv, so even obscure targets can be built like this.
Sometimes you need some extra flags for gcc's build, these are passed via the gcc attr:
https://github.com/NixOS/nixpkgs/blob/7636fe33eae59738f5cdace9d257fb3c727a9898/lib/systems/examples.nix#L227
Once you have a sufficient target description, you can compile it all together into a nix-shell to get the toolchain, for example like this:
https://gist.github.com/wucke13/123536af7cfdab7083a2173a064489d2 | 08:54:25 |
| tomas joined the room. | 09:22:41 |
rosssmyth | It doesn't have to. Multilib exists. | 14:12:23 |
rosssmyth | Taking a look at the disassembly, no it does not. Because the libc functions are all arm. | 14:12:50 |
rosssmyth | I never flashed the firmware produced by nix so I never checked | 14:13:11 |
rosssmyth | That's how I always pass the flags, though the latter is not really needed. | 14:13:34 |
rosssmyth | Which is unfortunate because the arm-embedded gcc does state it supports armv6-m. But in reality this is not true. | 14:16:07 |
rosssmyth | * Which is unfortunate because the arm-embedded gcc does state it supports armv6-m. But in reality this is not true because of libc. | 14:16:18 |
rosssmyth | Oh yeah I did find another issue where if you use the config armv6m-none-eabi the compiler doesn't actually target armv6-m, it targets arm6kz. To actually target armv6-m you must specify gcc.float-abi = "softfp" . | 14:18:06 |
rosssmyth | * It is required for the assembler to accept the correct asm. | 15:39:50 |
rosssmyth | Well testing it, even without the cross file it still fails on the real firmware. I give up and am just reverting back to the arm provided binary gcc as I already wasted a day of working messing with this. | 15:41:05 |
dramforever | In reply to @rosssmyth:matrix.org It doesn't have to. Multilib exists. multilib does not exist in nixpkgs's stdenv.cc | 16:23:41 |
dramforever | In reply to @wucke13:matrix.org
If you take look at
https://github.com/NixOS/nixpkgs/blob/master/lib/systems/examples.nix
You can see that you can specify quite detailed what your target system is like. This information is passed to the GCC build for your stdenv, so even obscure targets can be built like this.
Sometimes you need some extra flags for gcc's build, these are passed via the gcc attr:
https://github.com/NixOS/nixpkgs/blob/7636fe33eae59738f5cdace9d257fb3c727a9898/lib/systems/examples.nix#L227
Once you have a sufficient target description, you can compile it all together into a nix-shell to get the toolchain, for example like this:
https://gist.github.com/wucke13/123536af7cfdab7083a2173a064489d2 i've been trying to go all in on the configurification and used gcc.cpu = "cortex-m0" . newlib fails to compile | 16:24:28 |
dramforever | i don't have the logs conveniently available but it's something like "sorry, unimplemented" for a few random functions | 16:25:56 |
rosssmyth | Then something is messed up with how newlib is being built because I ship firmware that uses those exact flags. | 16:27:16 |