Unverified Commit 8766d9c4 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

rerun: fix wasm --no-modules build failure (#434890)

parents da45bf9a a0c17836
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
  # nativeBuildInputs
  binaryen,
  lld,
  llvmPackages,
  pkg-config,
  protobuf,
  rustfmt,
@@ -31,7 +32,6 @@
    "map_view"
  ],
}:

rustPlatform.buildRustPackage (finalAttrs: {
  pname = "rerun";
  version = "0.24.0";
@@ -99,6 +99,24 @@ rustPlatform.buildRustPackage (finalAttrs: {
    nasm
  ];

  # NOTE: Without setting these environment variables the web-viewer
  # preBuild step uses the nix wrapped CC which doesn't support
  # multiple targets including wasm32-unknown-unknown. These are taken
  # from the following issue discussion in the rust ring crate:
  # https://github.com/briansmith/ring/discussions/2581#discussioncomment-14096969
  env =
    let
      inherit (llvmPackages) clang-unwrapped;
      major-version = builtins.head (builtins.splitVersion clang-unwrapped.version);
      # resource dir + builtins from the unwrapped clang
      resourceDir = "${lib.getLib clang-unwrapped}/lib/clang/${major-version}";
      includeDir = "${lib.getLib llvmPackages.libclang}/lib/clang/${major-version}/include";
    in
    {
      CC_wasm32_unknown_unknown = lib.getExe clang-unwrapped;
      CFLAGS_wasm32_unknown_unknown = "-isystem ${includeDir} -resource-dir ${resourceDir}";
    };

  buildInputs = [
    freetype
    glib