Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm: fix cross compiling for v4, v5, v6. #40604

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkgs/development/compilers/llvm/4/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lowPrio, newScope, stdenv, targetPlatform, cmake, libstdcxxHook
, libxml2, python2, isl, fetchurl, overrideCC, wrapCC, ccWrapperFun
, darwin
, darwin, hostLLVM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should definitely be called buildLLVM.

}:

let
Expand All @@ -23,7 +23,7 @@ let
drv // { man = drv-manpages.out; /*outputs = drv.outputs ++ ["man"];*/ };

llvm = callPackage ./llvm.nix {
inherit compiler-rt_src stdenv;
inherit compiler-rt_src stdenv hostLLVM;
};

clang-unwrapped = callPackage ./clang {
Expand Down
8 changes: 7 additions & 1 deletion pkgs/development/compilers/llvm/4/llvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
, enableManpages ? false
, enableSharedLibraries ? true
, darwin
, hostLLVM
}:

let
Expand All @@ -40,7 +41,8 @@ in stdenv.mkDerivation (rec {
++ stdenv.lib.optional enableSharedLibraries "lib";

nativeBuildInputs = [ cmake python ]
++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
++ stdenv.lib.optional enableManpages python.pkgs.sphinx
++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) hostLLVM;

buildInputs = [ libxml2 libffi ]
++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ];
Expand Down Expand Up @@ -122,6 +124,10 @@ in stdenv.mkDerivation (rec {
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
"-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
]
++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
"-DLLVM_TABLEGEN=${hostLLVM}/bin/llvm-tblgen"
];

postBuild = ''
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/compilers/llvm/5/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lowPrio, newScope, stdenv, targetPlatform, cmake, libstdcxxHook
, libxml2, python2, isl, fetchurl, overrideCC, wrapCC, ccWrapperFun
, darwin
, darwin, hostLLVM
}:

let
Expand All @@ -23,7 +23,7 @@ let
drv // { man = drv-manpages.out; /*outputs = drv.outputs ++ ["man"];*/ };

llvm = callPackage ./llvm.nix {
inherit compiler-rt_src stdenv;
inherit compiler-rt_src stdenv hostLLVM;
};

clang-unwrapped = callPackage ./clang {
Expand Down
13 changes: 11 additions & 2 deletions pkgs/development/compilers/llvm/5/llvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
, enableManpages ? false
, enableSharedLibraries ? true
, darwin
, hostLLVM
}:

let
Expand All @@ -40,7 +41,9 @@ in stdenv.mkDerivation (rec {
++ stdenv.lib.optional enableSharedLibraries "lib";

nativeBuildInputs = [ cmake python ]
++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
++ stdenv.lib.optional enableManpages python.pkgs.sphinx
++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform)
hostLLVM;

buildInputs = [ libxml2 libffi ]
++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ];
Expand Down Expand Up @@ -115,6 +118,10 @@ in stdenv.mkDerivation (rec {
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
"-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
]
++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
"-DLLVM_TABLEGEN=${hostLLVM}/bin/llvm-tblgen"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this is the way forward given how we use cmake for cross--which unfortunately is "wrong" and means we aren't taken advantage of any of LLVM / cmake's infrastructure for these things.

More outside review ....

];

postBuild = ''
Expand Down Expand Up @@ -148,7 +155,9 @@ in stdenv.mkDerivation (rec {
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
'';

doCheck = stdenv.isLinux && (!stdenv.isi686);
doCheck = stdenv.isLinux
&& (!stdenv.isi686)
&& (stdenv.buildPlatform == stdenv.hostPlatform);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is handled by default/already? Please LMK if that's not what you're seeing!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, you're right, thanks!


checkTarget = "check-all";

Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/compilers/llvm/6/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lowPrio, newScope, stdenv, targetPlatform, cmake, libstdcxxHook
, libxml2, python2, isl, fetchurl, overrideCC, wrapCC, ccWrapperFun
, darwin
, darwin, hostLLVM
}:

let
Expand All @@ -23,7 +23,7 @@ let
drv // { man = drv-manpages.out; /*outputs = drv.outputs ++ ["man"];*/ };

llvm = callPackage ./llvm.nix {
inherit compiler-rt_src stdenv;
inherit compiler-rt_src stdenv hostLLVM;
};

clang-unwrapped = callPackage ./clang {
Expand Down
13 changes: 10 additions & 3 deletions pkgs/development/compilers/llvm/6/llvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
, enableSharedLibraries ? true
, enableWasm ? true
, darwin
, hostLLVM
}:

let
Expand All @@ -41,7 +42,8 @@ in stdenv.mkDerivation (rec {
++ stdenv.lib.optional enableSharedLibraries "lib";

nativeBuildInputs = [ cmake python ]
++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
++ stdenv.lib.optional enableManpages python.pkgs.sphinx
++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) hostLLVM;

buildInputs = [ libxml2 libffi ]
++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ];
Expand Down Expand Up @@ -114,8 +116,13 @@ in stdenv.mkDerivation (rec {
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
"-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
] ++ stdenv.lib.optional enableWasm
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly"
]
++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform)[
"-DCMAKE_CROSSCOMPILING=True"
"-DLLVM_TABLEGEN=${hostLLVM}/bin/llvm-tblgen"
]
++ stdenv.lib.optional enableWasm
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly"
;

postBuild = ''
Expand Down
3 changes: 3 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6708,12 +6708,14 @@ with pkgs;

llvmPackages_4 = callPackage ../development/compilers/llvm/4 ({
inherit (stdenvAdapters) overrideCC;
hostLLVM = buildPackages.llvmPackages_4.llvm;
} // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
stdenv = overrideCC stdenv gcc6;
});

llvmPackages_5 = callPackage ../development/compilers/llvm/5 ({
inherit (stdenvAdapters) overrideCC;
hostLLVM = buildPackages.llvmPackages_5.llvm;
} // stdenv.lib.optionalAttrs stdenv.isDarwin {
cmake = cmake.override {
isBootstrap = true;
Expand All @@ -6727,6 +6729,7 @@ with pkgs;

llvmPackages_6 = callPackage ../development/compilers/llvm/6 ({
inherit (stdenvAdapters) overrideCC;
hostLLVM = buildPackages.llvmPackages_6.llvm;
} // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4'
});
Expand Down