Skip to content

Commit

Permalink
rustc: Fix cross build for FreeBSD (NixOS#339909)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored Nov 2, 2024
2 parents b2c036c + 7f179a1 commit d4f265a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pkgs/development/compilers/rust/1_82.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
pkgsBuildTarget,
pkgsBuildBuild,
pkgsBuildHost,
pkgsHostTarget,
pkgsTargetTarget,
makeRustPlatform,
wrapRustcWith,
Expand All @@ -40,7 +41,7 @@ let
# Force LLVM to compile using clang + LLVM libs when targeting pkgsLLVM
stdenv = pkgSet.stdenv.override {
allowedRequisites = null;
cc = pkgSet.llvmPackages_18.clangUseLLVM;
cc = pkgSet.pkgsBuildHost.llvmPackages_18.clangUseLLVM;
};
}
);
Expand All @@ -55,7 +56,7 @@ import ./default.nix
llvmSharedForTarget = llvmSharedFor pkgsBuildTarget;

# For use at runtime
llvmShared = llvmSharedFor { inherit llvmPackages_18 stdenv; };
llvmShared = llvmSharedFor pkgsHostTarget;

# Expose llvmPackages used for rustc from rustc via passthru for LTO in Firefox
llvmPackages =
Expand All @@ -74,7 +75,7 @@ import ./default.nix
pkg.override {
stdenv = stdenv.override {
allowedRequisites = null;
cc = llvmPackages.clangUseLLVM;
cc = pkgsBuildHost.llvmPackages_18.clangUseLLVM;
};
};
in
Expand All @@ -87,7 +88,7 @@ import ./default.nix
libcxx = llvmPackages.libcxx.override {
stdenv = stdenv.override {
allowedRequisites = null;
cc = llvmPackages.clangNoLibcxx;
cc = pkgsBuildHost.llvmPackages_18.clangNoLibcxx;
hostPlatform = stdenv.hostPlatform // {
useLLVM = !stdenv.hostPlatform.isDarwin;
};
Expand Down Expand Up @@ -142,5 +143,6 @@ import ./default.nix
"wrapCCWith"
"overrideCC"
"fetchpatch"
"pkgsHostTarget"
]
)
4 changes: 2 additions & 2 deletions pkgs/development/compilers/rust/rustc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ in stdenv.mkDerivation (finalAttrs: {
] ++ optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
# https://github.com/rust-lang/rust/issues/92173
"--set rust.jemalloc"
] ++ optionals useLLVM [
] ++ optionals (useLLVM && !stdenv.targetPlatform.isFreeBSD) [
# https://github.com/NixOS/nixpkgs/issues/311930
"--llvm-libunwind=${if withBundledLLVM then "in-tree" else "system"}"
"--enable-use-libcxx"
Expand Down Expand Up @@ -262,7 +262,7 @@ in stdenv.mkDerivation (finalAttrs: {
buildInputs = [ openssl ]
++ optionals stdenv.hostPlatform.isDarwin [ libiconv Security zlib ]
++ optional (!withBundledLLVM) llvmShared.lib
++ optional (useLLVM && !withBundledLLVM) [
++ optional (useLLVM && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD) [
llvmPackages.libunwind
# Hack which is used upstream https://github.com/gentoo/gentoo/blob/master/dev-lang/rust/rust-1.78.0.ebuild#L284
(runCommandLocal "libunwind-libgcc" {} ''
Expand Down

0 comments on commit d4f265a

Please sign in to comment.