diff --git a/pkgs/development/compilers/llvm/common/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix index be106b3db295..ce35c039fc8c 100644 --- a/pkgs/development/compilers/llvm/common/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -13,9 +13,6 @@ , python3 , python3Packages , libffi - # TODO: Can this memory corruption bug still occur? - # -, enableGoldPlugin ? libbfd.hasPluginAPI , ld64 , libbfd , libpfm @@ -373,8 +370,13 @@ stdenv.mkDerivation (finalAttrs: { "-DSPHINX_OUTPUT_MAN=ON" "-DSPHINX_OUTPUT_HTML=OFF" "-DSPHINX_WARNINGS_AS_ERRORS=OFF" - ] ++ optionals (enableGoldPlugin) [ - "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ] ++ optionals (libbfd != null) [ + # LLVM depends on binutils only through libbfd/include/plugin-api.h, which + # is meant to be a stable interface. Depend on that file directly rather + # than through a build of BFD to break the dependency of clang on the target + # triple. The result of this is that a single clang build can be used for + # multiple targets. + "-DLLVM_BINUTILS_INCDIR=${libbfd.plugin-api-header}/include" ] ++ optionals stdenv.hostPlatform.isDarwin [ "-DLLVM_ENABLE_LIBCXX=ON" "-DCAN_TARGET_i386=false" diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 4d90fa66ea7d..d9c814dd41b5 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -12,6 +12,7 @@ in , lib , noSysDirs , perl +, runCommand , zlib , CoreServices @@ -238,11 +239,18 @@ stdenv.mkDerivation (finalAttrs: { inherit targetPrefix; hasGold = enableGold; isGNU = true; - # Having --enable-plugins is not enough, system has to support - # dlopen() or equivalent. See config/plugins.m4 and configure.ac - # (around PLUGINS) for cases that support or not support plugins. - # No platform specific filters yet here. - hasPluginAPI = enableGold; + + # The plugin API is not a function of any targets. Expose it separately, + # currently only used by LLVM for enabling BFD to do LTO with LLVM bitcode. + # (Tar will exit with an error if there are no matches). + plugin-api-header = runCommand "libbfd-plugin-api-header" {} '' + mkdir -p $out + tar --directory=$out \ + --extract \ + --file=${finalAttrs.src} \ + --strip-components=1 \ + --wildcards '*'/include/plugin-api.h + ''; }; meta = with lib; { diff --git a/pkgs/development/tools/misc/binutils/libbfd.nix b/pkgs/development/tools/misc/binutils/libbfd.nix index c6ab2a6431d0..f8dc8b5473a7 100644 --- a/pkgs/development/tools/misc/binutils/libbfd.nix +++ b/pkgs/development/tools/misc/binutils/libbfd.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation { ]; passthru = { - inherit (binutils-unwrapped-all-targets) dev hasPluginAPI; + inherit (binutils-unwrapped-all-targets) src dev plugin-api-header; }; meta = with lib; { diff --git a/pkgs/development/tools/misc/binutils/libopcodes.nix b/pkgs/development/tools/misc/binutils/libopcodes.nix index c8d3b78b29eb..423ab850737d 100644 --- a/pkgs/development/tools/misc/binutils/libopcodes.nix +++ b/pkgs/development/tools/misc/binutils/libopcodes.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation { ]; passthru = { - inherit (binutils-unwrapped-all-targets) dev hasPluginAPI; + inherit (binutils-unwrapped-all-targets) dev; }; meta = with lib; {