!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

426 Members
96 Servers

Load older messages


SenderMessageTime
7 Dec 2024
@aliarokapis:matrix.orgAlexandros Liarokapis That's great, what is the high-level way to cross-compile with clang currently? pkgsLLVM? 20:01:52
@aliarokapis:matrix.orgAlexandros 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
@aliarokapis:matrix.orgAlexandros Liarokapis?20:55:36
@aliarokapis:matrix.orgAlexandros Liarokapis * ? Not sure how to pass the target and target-cpu flags to all clang invocations though.20:56:19
@artturin:matrix.orgArtturin useLLVM = true 20:56:22
@artturin:matrix.orgArtturin Which is the same as pkgsLLVM 20:56:35
@artturin:matrix.orgArtturin * useLLVM = true in crossSystem 20:56:42
@artturin:matrix.orgArtturinOh pkgsLLVM specifies lld as the linker too https://github.com/NixOS/nixpkgs/blob/b3281241647d6353fd54a9265aa2fe50290629b4/pkgs/top-level/stage.nix#L20620:57:12
@artturin:matrix.orgArtturinnevermind20:57:54
@artturin:matrix.orgArtturinhttps://github.com/NixOS/nixpkgs/blob/b3281241647d6353fd54a9265aa2fe50290629b4/lib/systems/default.nix#L121 lld is used when useLLVM20:58:01
@artturin:matrix.orgArtturinso dunno why it's duplicated20:58:06
@aliarokapis:matrix.orgAlexandros Liarokapishmm I will dig in. Do you know how to set the default llvm target ?20:59:14
@artturin:matrix.orgArtturinThere's a reason why it's duplicated which is explained here https://github.com/nixos/nixpkgs/commit/148d73fc746a52c3ec0a71eea989021d160fab8920:59:24
@artturin:matrix.orgArtturin * There's a reason why it's duplicated in stage.nix which is explained here https://github.com/nixos/nixpkgs/commit/148d73fc746a52c3ec0a71eea989021d160fab8920:59:37
@artturin:matrix.orgArtturinNo need to duplicate it in your own uses20:59:43
@aliarokapis:matrix.orgAlexandros Liarokapis eg I need to set thumbv7em-none-eabi target to all invocations. 21:00:18
@aliarokapis:matrix.orgAlexandros Liarokapis(and ideally also set "target-cpu=cortex-m7")21:04:34
@artturin:matrix.orgArtturinThere'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=code21:08:19
@aliarokapis:matrix.orgAlexandros Liarokapis * (and ideally also set target-cpu=cortex-m7) 21:08:26
@artturin:matrix.orgArtturinSupport for setting it would be added in https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/cc-wrapper/default.nix21:09:12
@aliarokapis:matrix.orgAlexandros Liarokapisyea 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
@aliarokapis:matrix.orgAlexandros Liarokapisany idea about the llvm target?21:09:45
@artturin:matrix.orgArtturin just setting config should be enough 21:09:55
@aliarokapis:matrix.orgAlexandros Liarokapisdo you where the config -> llvm mapping occurs ?21:10:24
@aliarokapis:matrix.orgAlexandros Liarokapis * do you know where the config -> llvm mapping occurs ?21:10:34
@aliarokapis:matrix.orgAlexandros LiarokapisI think it was somewhere in the elaboration part, but I don't recall properly.21:11:15
@artturin:matrix.orgArtturinhttps://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.sh21:17:55
@aliarokapis:matrix.orgAlexandros Liarokapisthanks a ton!21:18:16
@artturin:matrix.orgArtturin
nix-repl> import ./. { crossSystem = "thumbv7em-none-eabi" ;}
  error: Unknown CPU type: thumbv7em
21:20:22
@artturin:matrix.orgArtturinYou'll have to add the cpu type21:21:01

Show newer messages


Back to Room ListRoom Version: 6