7 Dec 2024 |
Alexandros Liarokapis | That's great, what is the high-level way to cross-compile with clang currently? pkgsLLVM? | 20:01:52 |
Alexandros Liarokapis | so something like
let pkgs = (import nixpkgs {
localSystem = inherit system;
crossSystem = {
config = "arm-none-eabi";
rust.rustcTarget = "thumbv7em-none-eabi";
};
}).pkgsLLVM;
| 20:55:32 |
Alexandros Liarokapis | ? | 20:55:36 |
Alexandros Liarokapis | * ? Not sure how to pass the target and target-cpu flags to all clang invocations though. | 20:56:19 |
Artturin | useLLVM = true | 20:56:22 |
Artturin | Which is the same as pkgsLLVM | 20:56:35 |
Artturin | * useLLVM = true in crossSystem | 20:56:42 |
Artturin | Oh pkgsLLVM specifies lld as the linker too https://github.com/NixOS/nixpkgs/blob/b3281241647d6353fd54a9265aa2fe50290629b4/pkgs/top-level/stage.nix#L206 | 20:57:12 |
Artturin | nevermind | 20:57:54 |
Artturin | https://github.com/NixOS/nixpkgs/blob/b3281241647d6353fd54a9265aa2fe50290629b4/lib/systems/default.nix#L121 lld is used when useLLVM | 20:58:01 |
Artturin | so dunno why it's duplicated | 20:58:06 |
Alexandros Liarokapis | hmm I will dig in. Do you know how to set the default llvm target ? | 20:59:14 |
Artturin | There's a reason why it's duplicated which is explained here https://github.com/nixos/nixpkgs/commit/148d73fc746a52c3ec0a71eea989021d160fab89 | 20:59:24 |
Artturin | * There's a reason why it's duplicated in stage.nix which is explained here https://github.com/nixos/nixpkgs/commit/148d73fc746a52c3ec0a71eea989021d160fab89 | 20:59:37 |
Artturin | No need to duplicate it in your own uses | 20:59:43 |
Alexandros Liarokapis | eg I need to set thumbv7em-none-eabi target to all invocations. | 21:00:18 |
Alexandros Liarokapis | (and ideally also set "target-cpu=cortex-m7") | 21:04:34 |
Artturin | There's no support for setting target-cpu globally, if you want it in rust https://github.com/search?q=%2Ftarget-cpu%2F+lang%3Anix+NOT+is%3Afork&type=code | 21:08:19 |
Alexandros Liarokapis | * (and ideally also set target-cpu=cortex-m7 ) | 21:08:26 |
Artturin | Support for setting it would be added in https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/cc-wrapper/default.nix | 21:09:12 |
Alexandros Liarokapis | yea I guess that's to be expected, I could probably overlay it to the stdenv, I don't need deep dependency trees anyway but yes adding first-class supported would be very useful. | 21:09:34 |
Alexandros Liarokapis | any idea about the llvm target? | 21:09:45 |
Artturin | just setting config should be enough | 21:09:55 |
Alexandros Liarokapis | do you where the config -> llvm mapping occurs ? | 21:10:24 |
Alexandros Liarokapis | * do you know where the config -> llvm mapping occurs ? | 21:10:34 |
Alexandros Liarokapis | I think it was somewhere in the elaboration part, but I don't recall properly. | 21:11:15 |
Artturin | https://github.com/NixOS/nixpkgs/blob/1e56a3b5efd3c4c1451f891863cfb72e471687f7/pkgs/build-support/cc-wrapper/default.nix#L717
https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh | 21:17:55 |
Alexandros Liarokapis | thanks a ton! | 21:18:16 |
Artturin | nix-repl> import ./. { crossSystem = "thumbv7em-none-eabi" ;}
error: Unknown CPU type: thumbv7em
| 21:20:22 |
Artturin | You'll have to add the cpu type | 21:21:01 |