Skip to content

Commit

Permalink
Fix musl TH code using C++ & external interpreter (#1832)
Browse files Browse the repository at this point in the history
* Fix musl TH code using C++ & external interpreter

This makes the gcc_s.so library available to iserv.

* Pass LD_LIBRARY_PATH as nix attr
  • Loading branch information
hamishmack committed Feb 4, 2023
1 parent 78aed6a commit 710b2e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ let
}
// lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc") {
LOCALE_ARCHIVE = "${buildPackages.glibcLocales}/lib/locale/locale-archive";
}
// lib.optionalAttrs stdenv.hostPlatform.isMusl {
# This fixes musl compilation of TH code that depends on C++ (for instance TH code that uses the double-conversion package)
LD_LIBRARY_PATH="${pkgs.buildPackages.gcc-unwrapped.lib}/x86_64-unknown-linux-musl/lib";
};

haddock = haddockBuilder {
Expand Down
15 changes: 12 additions & 3 deletions test/th-dlls/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
with lib;

let
project = project' {
project = externalInterpreter: project' {
inherit compiler-nix-name evalPackages;
src = testSrc "th-dlls";
modules = [({pkgs, ...}: lib.optionalAttrs externalInterpreter {
packages.th-dlls.components.library.ghcOptions = [ "-fexternal-interpreter" ];
# Static openssl seems to fail to load in iserv for musl
packages.HsOpenSSL.components.library.libs = lib.optional pkgs.stdenv.hostPlatform.isMusl (pkgs.openssl.override { static = false; });
})];
};

packages = project.hsPkgs;
packages = (project false).hsPkgs;
packages-ei = (project true).hsPkgs;

in recurseIntoAttrs {
meta.disabled = stdenv.hostPlatform.isGhcjs ||
Expand All @@ -20,10 +26,13 @@ in recurseIntoAttrs {
(stdenv.hostPlatform.isDarwin && __elem compiler-nix-name ["ghc941" "ghc942" "ghc943" "ghc944"]);

ifdInputs = {
inherit (project) plan-nix;
inherit (project true) plan-nix;
};

build = packages.th-dlls.components.library;
build-profiled = packages.th-dlls.components.library.profiled;
just-template-haskell = packages.th-dlls.components.exes.just-template-haskell;
build-ei = packages-ei.th-dlls.components.library;
build-profiled-ei = packages-ei.th-dlls.components.library.profiled;
just-template-haskell-ei = packages-ei.th-dlls.components.exes.just-template-haskell;
}

0 comments on commit 710b2e9

Please sign in to comment.