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

llvmPackages_*.clang: bind linker on compiling clang #220595

Draft
wants to merge 1 commit into
base: staging
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/10/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -37,6 +38,8 @@ let
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
Comment on lines +41 to +42
Copy link

@ghost ghost Nov 2, 2023

Choose a reason for hiding this comment

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

Are you sure targetPackages is the right thing to use here?

targetPackages means pkgsTargetTarget, which is the packages which run on the targetPlatform and emit binaries for the targetPlatform.

When you're building a (build==host)!=target compiler, its linker will run on the hostPlatform

But I don't know clang very well so maybe I am misreading the meaning of -DCLANG_DEFAULT_LINKER. @Ericson2314 would know for sure.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, I agree with @amjoseph-nixpkgs here.

I would expect rather pkgsBuildTarget to be used here, but maybe there's some splicing surprises… ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might look suprising. Yes targetPackages is the packages that run on targetPlatform and emit binaries for the targetPlatform, but targetPackages.stdenv is something else. It is the environment that produces targetPackages. Now that targetPackages is the cross packages, targetPackages.stdenv.cc.bintools is the bintools that runs on host platform and emit target platform binaries.

];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/10/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -208,7 +210,9 @@ let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/11/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -42,6 +43,8 @@ let
] ++ lib.optionals enablePolly [
"-DWITH_POLLY=ON"
"-DLINK_POLLY_INTO_TOOLS=ON"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];


Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -223,7 +225,9 @@ let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/12/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -40,6 +41,8 @@ let
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/12/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -223,7 +225,9 @@ let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/13/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -30,6 +31,8 @@ let
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/13/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -236,7 +238,9 @@ let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/14/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -38,6 +39,8 @@ let
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/14/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -240,7 +242,9 @@ let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/15/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -44,6 +45,8 @@ let
# `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7
"-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen"
"-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ in let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -288,7 +290,9 @@ in let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/16/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -44,6 +45,8 @@ let
# `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7
"-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen"
"-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/16/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ in let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -293,7 +295,9 @@ in let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/5/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -38,6 +39,8 @@ let
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/6/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
, targetPackages
}:

let
Expand Down Expand Up @@ -38,6 +39,8 @@ let
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/7/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false # TODO: get this info from llvm (passthru?)
, targetPackages
}:

let
Expand Down Expand Up @@ -42,6 +43,8 @@ let
] ++ lib.optionals enablePolly [
"-DWITH_POLLY=ON"
"-DLINK_POLLY_INTO_TOOLS=ON"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -210,7 +212,9 @@ let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/8/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false # TODO: get this info from llvm (passthru?)
, targetPackages
}:

let
Expand Down Expand Up @@ -42,6 +43,8 @@ let
] ++ lib.optionals enablePolly [
"-DWITH_POLLY=ON"
"-DLINK_POLLY_INTO_TOOLS=ON"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
"-DCLANG_DEFAULT_LINKER=${targetPackages.stdenv.cc.bintools}/bin/${stdenv.targetPlatform.config}-ld"
];

patches = [
Expand Down
8 changes: 6 additions & 2 deletions pkgs/development/compilers/llvm/8/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ let
};

clangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [
Expand All @@ -211,7 +213,9 @@ let
};

clangNoCompilerRt = wrapCCWith rec {
cc = tools.clang-unwrapped;
cc = tools.clang-unwrapped.override {
targetPackages.stdenv.cc.bintools = bintoolsNoLibc';
};
libcxx = null;
bintools = bintoolsNoLibc';
extraPackages = [ ];
Expand Down
Loading