!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

513 Members
112 Servers

Load older messages


SenderMessageTime
3 Nov 2021
@AleXoundOS:matrix.org@AleXoundOS:matrix.orgAlso, "Cross-compilation infrastructure" section of nixpkgs gives no clear insight on how to handle this.19:57:39
@AleXoundOS:matrix.org@AleXoundOS:matrix.org * Also, "Cross-compilation infrastructure" section of nixpkgs manual gives no clear insight on how to handle this.19:57:49
@symphorien:xlumurb.eusymphorienit might be a case of trading build time for sanity.20:01:11
@symphorien:xlumurb.eusymphorienbut if you PR to nixpkgs --disable-libsanitizer on mips, the native gcc will be provided by hydra ;)20:02:43
@AleXoundOS:matrix.org@AleXoundOS:matrix.orgYeah. Just I thought having a robust theoretical background with depsXY system it's possible to tune this without patching nixpkgs directly. It's not only build time but incompatibilities between build options for different platforms. Also disk space.20:07:23
@AleXoundOS:matrix.org@AleXoundOS:matrix.org * Yeah. Just I thought having a robust theoretical background with depsXY system it's possible to tune this without patching nixpkgs directly. It's not only build time but incompatibilities between build options for different platforms. It wouldn't work if disabling libsanitizer broke native compiler. Also disk space. 20:08:27
@AleXoundOS:matrix.org@AleXoundOS:matrix.org * Yeah. Just I thought having a robust theoretical background with depsXY system it's possible to tune this without patching nixpkgs directly. It's not only build time but incompatibilities between build options for different platforms. It wouldn't work if disabling libsanitizer broke native compiler. Also disk space... 20:08:49
@symphorien:xlumurb.eusymphorienagain, I believe patching nixpkgs is the right way to tune it. Doing it by overlays is hard, not always possible, and will likely break in a backward incompatible manner as often as a patch20:09:16
@symphorien:xlumurb.eusymphorienhere you need to inspect targetPlatform I think20:09:58
@symphorien:xlumurb.eusymphorienhostPlatform is the platform that runs the compiler you are building20:10:26
@symphorien:xlumurb.eusymphorienso it's likely to be x86 6420:11:03
@AleXoundOS:matrix.org@AleXoundOS:matrix.org
In reply to @symphorien:xlumurb.eu
hostPlatform is the platform that runs the compiler you are building
Hmm. When I patched boost for mips32r2, the code after optionals (stdenv.hostPlatform != stdenv.buildPlatform) was significant and responsible to setting the architecture.
20:14:22
@AleXoundOS:matrix.org@AleXoundOS:matrix.org
In reply to @symphorien:xlumurb.eu
hostPlatform is the platform that runs the compiler you are building
* Hmm. When I patched boost for mips32r2, the code after optionals (stdenv.hostPlatform != stdenv.buildPlatform) was significant and responsible fpr setting the architecture.
20:14:38
@symphorien:xlumurb.eusymphorienboost is not a compiler20:14:48
@AleXoundOS:matrix.org@AleXoundOS:matrix.org * Hmm. When I patched boost for mips32r2, the code after optionals (stdenv.hostPlatform != stdenv.buildPlatform) was significant and responsible for setting the architecture. 20:15:00
@symphorien:xlumurb.eusymphorienhost platform is the platform the code you compile runs on -> for a lib, it's where you put the .so so mips20:15:21
@AleXoundOS:matrix.org@AleXoundOS:matrix.orgIn my mind these two statements about what is host platform come into conflict :)20:17:22
@symphorien:xlumurb.eusymphorienwhen you compile a compiler for mips but that runs on x86, hostplatform = x86 and target = mips20:18:59
@symphorien:xlumurb.eusymphorienwhen you compile boost for mips, hostplatform = mips, target = whatever20:19:15
@symphorien:xlumurb.eusymphorienbecause $out/bin/gcc is x86 and $out/lib/boost is mips20:19:31
@symphorien:xlumurb.eusymphorienphrased differently, hostplatform is the platform of executables that go in $out20:20:28
@symphorien:xlumurb.eusymphorienmodulo the fact that gcc contains some libs for the target platforms but let's keep it simple and approximate20:21:14
@AleXoundOS:matrix.org@AleXoundOS:matrix.org Btw, if somebody interested getting ldd for host platform when cross-compiling I managed to get this with (pkgs.glibcCross.overrideAttrs (_: { preFixup = null; })).bin. Full command:
nix-build --dry-run -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/d4590d21006387dcb190c516724cb1e41c0f8fdf.tar.gz -E 'with import <nixpkgs> { overlays = [ (self: super: { wrapCC = cc: super.wrapCC (cc.overrideAttrs (def: { configureFlags = def.configureFlags ++ [ "--disable-libsanitizer" ]; })); }) ]; crossSystem = { config = "mipsel-linux"; gcc.arch = "mips32r2"; gcc.abi = "32"; }; }; (glibcCross.overrideAttrs (_: { preFixup = null; })).bin'.
And it runs fine on the hardware.
21:45:00
@AleXoundOS:matrix.org@AleXoundOS:matrix.org The trick is to use glibcCross instead of glibc. 21:45:59
@AleXoundOS:matrix.org@AleXoundOS:matrix.org * Btw, if somebody interested getting ldd for host platform when cross-compiling I managed to get this with (pkgs.glibcCross.overrideAttrs (_: { preFixup = null; })).bin. Full command:
nix-build -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/d4590d21006387dcb190c516724cb1e41c0f8fdf.tar.gz -E 'with import <nixpkgs> { overlays = [ (self: super: { wrapCC = cc: super.wrapCC (cc.overrideAttrs (def: { configureFlags = def.configureFlags ++ [ "--disable-libsanitizer" ]; })); }) ]; crossSystem = { config = "mipsel-linux"; gcc.arch = "mips32r2"; gcc.abi = "32"; }; }; (glibcCross.overrideAttrs (_: { preFixup = null; })).bin'.
And it runs fine on the hardware.
21:55:38
@piegames:matrix.orgpiegames set a profile picture.22:01:14
@trofi:matrix.orgtrofi @AleXoundOS:matrix.org: yeah, I think you should be able to apply --disable-libsanitizer only for cross-compiler (or set more specific constraints). def is a set of known attributes being evaluated. Probably something like if (def.stdenv.buildPlatform != def.stdenv.hostPlatform) then [ "--disable-libsanitizer" ] else []. Totally untested. 22:31:23
@sandro:supersandro.deSandrolib.optional is shorter for this usecase22:38:32
4 Nov 2021
@sternenseemann:systemli.orgsterni @AleXoundOS:matrix.org: btw I looked into it and it seems fine to install ldd etc in the cross case as well: https://github.com/NixOS/nixpkgs/pull/144417 01:10:13
@sternenseemann:systemli.orgsterni * @AleXoundOS:matrix.org: btw I looked into it and it seems fine to install ldd etc in the cross case for the normal derivation as well: https://github.com/NixOS/nixpkgs/pull/144417 01:10:24

There are no newer messages yet.


Back to Room ListRoom Version: 6