!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

398 Members
92 Servers

Load older messages


SenderMessageTime
6 Oct 2024
@suskeyhose:matrix.orgsrasuwould a git link be useful? It's not a very large project, just a personal template I use for building C projects16:20:14
@k900:0upti.meK900If it's your own project, you probably want to just use Meson16:21:23
@k900:0upti.meK900And Meson will do the right thing16:21:28
@suskeyhose:matrix.orgsrasuI've been told to use meson before and not had a good time16:22:18
@artturin:matrix.orgArtturin
In reply to @suskeyhose:matrix.org

doing a devShell

          devShells.default = pkgs.mkShell {
            packages = with pkgs; [
              bear
              doxygen
              nodejs
              lldb_18
              llvmPackages_18.bintools
              clang-tools_18
              valgrind
              man-pages
              man-pages-posix
            ];

            nativeBuildInputs = with pkgs; [
              llvmPackages_18.clang
              pkg-config
              wine64
            ] ++ (with windows-pkgs.pkgsCross.mingwW64.buildPackages; [
              llvmPackages_18.clang
            ]);

            buildInputs = with pkgs; [
              libblocksruntime
            ] ++ (with windows-pkgs.pkgsCross.mingwW64.buildPackages; [
              libblocksruntime
            ]);

            NOVENDOR = "yes";
            DEBUG = "yes";
            LEAKCHECK = "yes";
            UBSAN_OPTIONS="suppressions=template.supp";
            hardeningDisable = [ "all" ];
            CPATH = "${pkgs.llvmPackages_18.clang}/resource-root/include:${pkgs.glibc.dev}/include";
            WINCPATH = with pkgs.pkgsCross.mingwW64.buildPackages;
              "${llvmPackages_18.clang}/resource-root/include";
          };
You'll want to get everything from the cross set and it's __splicedPackages so dependency attributes work correctly pkgsCross.mingwW64.__splicedPackages
It's also best to avoid packages when you're doing cross compilation as it can obscure which packages are being talked about, instead use nativeBuildInputs directly https://github.com/NixOS/nixpkgs/blob/85813b7cfeb12a87da5506035f73b5b18a0a50c3/pkgs/build-support/mkshell/default.nix#L41
16:23:26
@suskeyhose:matrix.orgsrasupackages only has stuff that's not actually used by the build process, just build tooling16:24:20
@suskeyhose:matrix.orgsrasu * packages only has stuff that's not actually used by the build process, just dev tooling16:24:26
@suskeyhose:matrix.orgsrasuI can give that a go though16:25:03
@artturin:matrix.orgArtturin You should put tooling that does not care about target to depsBuildBuild, that way you won't have to rebuild them as for rarer platforms their depsBuildHost versions aren't usually cached 16:25:39
@artturin:matrix.orgArtturin

Probably something like this

  devShells.default =
    let
      pkgs = pkgsCross.mingwW64.__splicedPackages;
    in
    pkgs.mkShell {
      packages = with pkgs; [
        bear
        doxygen
        nodejs
        man-pages
        man-pages-posix
      ];

      nativeBuildInputs = with pkgs; [
        llvmPackages_18.clang
        llvmPackages_18.bintools
        lldb_18
        clang-tools_18
        valgrind
        pkg-config
        wine64
      ];

      buildInputs =
        with pkgs;
        [
          libblocksruntime
        ]
        ++ (with windows-pkgs.pkgsCross.mingwW64.buildPackages; [
          libblocksruntime
        ]);

      NOVENDOR = "yes";
      DEBUG = "yes";
      LEAKCHECK = "yes";
      UBSAN_OPTIONS = "suppressions=template.supp";
      hardeningDisable = [ "all" ];
      CPATH = "${pkgs.llvmPackages_18.clang}/resource-root/include:${pkgs.glibc.dev}/include";
      WINCPATH =
        with pkgs.pkgsCross.mingwW64.buildPackages;
        "${llvmPackages_18.clang}/resource-root/include";
    };
16:26:56
@artturin:matrix.orgArtturin *

Probably something like this

  devShells.default =
    let
      pkgs = pkgsCross.mingwW64.__splicedPackages;
    in
    pkgs.mkShell {
      depsBuildBuild = with pkgs; [
        bear
        doxygen
        nodejs
        man-pages
        man-pages-posix
      ];

      nativeBuildInputs = with pkgs; [
        llvmPackages_18.clang
        llvmPackages_18.bintools
        lldb_18
        clang-tools_18
        valgrind
        pkg-config
        wine64
      ];

      buildInputs =
        with pkgs;
        [
          libblocksruntime
        ]
        ++ (with windows-pkgs.pkgsCross.mingwW64.buildPackages; [
          libblocksruntime
        ]);

      NOVENDOR = "yes";
      DEBUG = "yes";
      LEAKCHECK = "yes";
      UBSAN_OPTIONS = "suppressions=template.supp";
      hardeningDisable = [ "all" ];
      CPATH = "${pkgs.llvmPackages_18.clang}/resource-root/include:${pkgs.glibc.dev}/include";
      WINCPATH =
        with pkgs.pkgsCross.mingwW64.buildPackages;
        "${llvmPackages_18.clang}/resource-root/include";
    };
16:27:04
@suskeyhose:matrix.orgsrasuoh thanks!16:27:26
@artturin:matrix.orgArtturin You want to use llvm tools so do (mkShell.override { stdenv = pkgs.llvmPackages_18.stdenv; }) 16:29:30
@artturin:matrix.orgArtturinAnd remove the llvmPackages from the dependency attributes16:29:53
@artturin:matrix.orgArtturin * And remove the llvmPackages stuff from the dependency attributes16:29:57
@artturin:matrix.orgArtturin* You want to use llvm tools so do (pkgs.mkShell.override { stdenv = pkgs.llvmPackages_18.stdenv; })16:35:06
@suskeyhose:matrix.orgsrasu I've started to get this weird mktemp failed to create directory via template with /tmp/nix-shell.JtWooZ/nix-shell.XXXXXX 16:36:27
@suskeyhose:matrix.orgsrasuno such file or directory16:36:40
@suskeyhose:matrix.orgsrasugoogle is being no help16:36:43
@suskeyhose:matrix.orgsrasuRedacted or Malformed Event16:43:38
@suskeyhose:matrix.orgsrasuRedacted or Malformed Event16:43:41
@suskeyhose:matrix.orgsrasuOk, that went away with a reboot, which is weird, but ok16:45:17
@suskeyhose:matrix.orgsrasuTrying to set things up like you posted, but I seem to be running into weird errors presumably because I had originally wanted the devshell to work for both cross compilation and usual compilation. I think I'll separate them out into different devshells though and hopefully that'll work itself out.16:48:24
@artturin:matrix.orgArtturinYou can add the build compiler to depsBuildBuild16:49:35
@artturin:matrix.orgArtturinit'll be non prefixed16:49:57
@artturin:matrix.orgArtturin$CC_FOR_BUILD16:50:08
@artturin:matrix.orgArtturin* And in $CC_FOR_BUILD16:50:16
@artturin:matrix.orgArtturinIt'll look for libraries in nativeBuildInputs16:50:36
@artturin:matrix.orgArtturin
In reply to @artturin:matrix.org

Probably something like this

  devShells.default =
    let
      pkgs = pkgsCross.mingwW64.__splicedPackages;
    in
    pkgs.mkShell {
      depsBuildBuild = with pkgs; [
        bear
        doxygen
        nodejs
        man-pages
        man-pages-posix
      ];

      nativeBuildInputs = with pkgs; [
        llvmPackages_18.clang
        llvmPackages_18.bintools
        lldb_18
        clang-tools_18
        valgrind
        pkg-config
        wine64
      ];

      buildInputs =
        with pkgs;
        [
          libblocksruntime
        ]
        ++ (with windows-pkgs.pkgsCross.mingwW64.buildPackages; [
          libblocksruntime
        ]);

      NOVENDOR = "yes";
      DEBUG = "yes";
      LEAKCHECK = "yes";
      UBSAN_OPTIONS = "suppressions=template.supp";
      hardeningDisable = [ "all" ];
      CPATH = "${pkgs.llvmPackages_18.clang}/resource-root/include:${pkgs.glibc.dev}/include";
      WINCPATH =
        with pkgs.pkgsCross.mingwW64.buildPackages;
        "${llvmPackages_18.clang}/resource-root/include";
    };

Oh and do

buildInputs = (
  with windows-pkgs.pkgsCross.mingwW64.__splicedPackages;
  [
    libblocksruntime
  ]
)
16:55:41
@artturin:matrix.orgArtturin
In reply to @artturin:matrix.org

Probably something like this

  devShells.default =
    let
      pkgs = pkgsCross.mingwW64.__splicedPackages;
    in
    pkgs.mkShell {
      depsBuildBuild = with pkgs; [
        bear
        doxygen
        nodejs
        man-pages
        man-pages-posix
      ];

      nativeBuildInputs = with pkgs; [
        llvmPackages_18.clang
        llvmPackages_18.bintools
        lldb_18
        clang-tools_18
        valgrind
        pkg-config
        wine64
      ];

      buildInputs =
        with pkgs;
        [
          libblocksruntime
        ]
        ++ (with windows-pkgs.pkgsCross.mingwW64.buildPackages; [
          libblocksruntime
        ]);

      NOVENDOR = "yes";
      DEBUG = "yes";
      LEAKCHECK = "yes";
      UBSAN_OPTIONS = "suppressions=template.supp";
      hardeningDisable = [ "all" ];
      CPATH = "${pkgs.llvmPackages_18.clang}/resource-root/include:${pkgs.glibc.dev}/include";
      WINCPATH =
        with pkgs.pkgsCross.mingwW64.buildPackages;
        "${llvmPackages_18.clang}/resource-root/include";
    };
*

Oh and do

buildInputs = (
  with windows-pkgs.pkgsCross.mingwW64.__splicedPackages;
  [
    libblocksruntime
  ]
)

The buildPackages would give you the dep for placement in nativeBuildInputs

16:57:31

Show newer messages


Back to Room ListRoom Version: 6