!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

553 Members
119 Servers

Load older messages


SenderMessageTime
10 Dec 2021
@symphorien:xlumurb.eusymphorienare you looking for "cc=${stdenv.cc.targetPrefix}cc" ?13:50:27
@mic92:nixos.devMic92You can use shellHook though13:50:33
@pepe:matrix.giugl.ioErPepone yep I'm using shellHook now but CMake is complaining 13:51:10
@pepe:matrix.giugl.ioErPeponeI have to setup also the CMake flags13:51:17
@pepe:matrix.giugl.ioErPepone
In reply to @symphorien:xlumurb.eu
are you looking for "cc=${stdenv.cc.targetPrefix}cc" ?
Thanks!
13:51:22
@pepe:matrix.giugl.ioErPepone CMake looks for cc and c++ 13:51:47
@pepe:matrix.giugl.ioErPepone Hmm, gccWithLldStdenv seems not to have any .cc.targetPrefix! 13:53:48
@pepe:matrix.giugl.ioErPepone So maybe is overrideCC that is not working properly? 13:54:03
@pepe:matrix.giugl.ioErPepone
      shellHook = ''
        export CC=${gccWithLldStdenv.cc.targetPrefix}cc
        export CXX=${gccWithLldStdenv.cc.targetPrefix}c++
        '';

ends up in

$ echo $CC
cc
$ echo $CXX
c++
13:54:47
@mic92:nixos.devMic92 ErPepone: maybe gccWithLldStdenv.cc.targetPrefix is empty? 13:57:33
@pepe:matrix.giugl.ioErPepone I was just trying with what symphorien suggested me earlier 13:58:04
@pepe:matrix.giugl.ioErPeponeIt shouldn't be empty though, right?13:58:16
@pepe:matrix.giugl.ioErPepone Because I'm overriding the stdenv of gnu32 13:58:28
@mic92:nixos.devMic92Usually it's not empty, only if it is not a cross compiler13:58:37
@pepe:matrix.giugl.ioErPepone

Just to be sure, this is what I'm using now:

  gccWithLld = pkgsCross32.wrapCCWith {
    cc = pkgsCross32.buildPackages.gcc-unwrapped;
    bintools = pkgsCross32.buildPackages.llvmPackages_13.bintools;
  };

  gccWithLldStdenv = pkgsCross32.overrideCC pkgsCross32.stdenv gccWithLld;
13:59:18
@mic92:nixos.devMic92 I mean maybe wrapCCWith does not apply the target prefix correctly 13:59:56
@pepe:matrix.giugl.ioErPepone Is there another way to force LLVM's bintools onto a stdenv? 14:00:19
@mic92:nixos.devMic92You could also hard code the correct prefix for now14:00:58
@mic92:nixos.devMic92 or use pkgsCross.gnu32.stdenv.cc.targetPrefix 14:01:25
@mic92:nixos.devMic92
                                           (targetPlatform.config + "-");
14:04:39
@mic92:nixos.devMic92Somehow this condition does not set the prefix in your case: https://github.com/NixOS/nixpkgs/blob/d0d209fd591c40ac8a2be4a0379ee14ab5b556bb/pkgs/build-support/cc-wrapper/default.nix#L3814:05:39
@pepe:matrix.giugl.ioErPeponeIt's because I'm on x86-64 "cross-compiling" for x8614:06:24
@pepe:matrix.giugl.ioErPeponeProbably14:06:28
@pepe:matrix.giugl.ioErPepone I am compiling a fork of LLVM with the pkgsCross set but it seems that when linking one of the buildInputs, the file format is not correct 14:18:45
@pepe:matrix.giugl.ioErPepone
/nix/store/g876mcfvkd6h80s28z5p1czvdcsxr3q3-i686-unknown-linux-gnu-binutils-2.35.2/bin/i686-unknown-linux-gnu-ld: /nix/store/2q3qzdrx1pka5gb93si9wca2a5b1qgx6-z3-4.8.12-lib/lib/libz3.so: error adding symbols: file in wrong format
14:20:37
@pepe:matrix.giugl.ioErPepone
    gccWithLldStdenv.mkDerivation {
      pname = "mypkg";
      version = "0.1.0";
      enableParallelBuilding = true;
      nativeBuildInputs = [
        cmake
        git
        curl
        pkg-config
        ninja
      ] ++ lib.optional (use_ccache == true) [ ccache ];
      buildInputs = [ z3 libxml2 python ];
14:21:20
@pepe:matrix.giugl.ioErPepone (if I put the deps in buildInputs into nativeBuildInputs, LLVM doesn't find them when configuring the build) 14:21:53
@mic92:nixos.devMic92 do you take packages from pkgsCross? 14:22:26
@mic92:nixos.devMic92 At least the stuff in buildInputs should come from pkgsCross 14:23:04
@pepe:matrix.giugl.ioErPepone
In reply to @pepe:matrix.giugl.io
let
  gccWithLld = pkgsCross32.wrapCCWith {
    cc = pkgsCross32.buildPackages.gcc;
    bintools = pkgsCross32.buildPackages.llvmPackages_13.bintools;
  };

  gccWithLldStdenv = pkgsCross32.overrideCC pkgsCross32.stdenv gccWithLld;

  derivation_function = { llvmPackages_13, cmake, git, curl, pkg-config, z3
    , libxml2, ninja, ccache, ocaml, use_ccache ? false, debug ? false }:
    gccWithLldStdenv.mkDerivation {
     ....
}
This: shall I call derivation_function with pkgs or pkgsCross?
14:23:11

There are no newer messages yet.


Back to Room ListRoom Version: 6