Commit 8ff6850f authored by nixdrin's avatar nixdrin
Browse files

jetbrains: drop libstdc++.so.6 from LD_LIBRARY_PATH

Most of the libraries listed in the LD_LIBRARY_PATH for the Jetbrains
IDEs are loaded indirectly using JNA in Java code, e.g.

  myLibNotify = Native.load("libnotify.so.4", LibNotify.class); [1]
  private val library = Native.load("secret-1", SecretLibrary::class.java) [2]

In this case the typical patching mechanism with Nix does not work
because JNA does the library lookup at runtime with its own mechanism.

However, there is one outlier: stdenv.cc.cc.lib is also added to the
LD_LIBRARY_PATH for libstdc++.so.6 because it is reportedly needed
for some "internals". It does not make sense to access libstdc++
from Java code so it feels like this one was added to work around
some native library or executable that should be patched instead
of using LD_LIBRARY_PATH.

Unfortunately, having libstdc++ in LD_LIBRARY_PATH can also easily
cause ABI conflicts. This is because this variable is inherited into
terminals opened within the IDE. Using a Nix environment there with
different versions of libstdc++ easily causes errors such as

  libstdc++.so.6: version `GLIBCXX_3.4.29' not found

Most of the IDEs work just fine without having libstdc++ in
LD_LIBRARY_PATH. Since it's not really clear why it has to be in
there let's just drop it to avoid the ABI conflicts.

[1]: https://github.com/JetBrains/intellij-community/blob/c0a703267a671bbbac2384fc226c82b2203db72b/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java#L40
[2]: https://github.com/JetBrains/intellij-community/blob/c0a703267a671bbbac2384fc226c82b2203db72b/platform/credential-store/src/linuxSecretLibrary.kt#L38
parent 87828a0e
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -107,9 +107,7 @@ with stdenv; lib.makeOverridable mkDerivation (rec {
    wrapProgram  "$out/$pname/bin/${loName}.sh" \
      --prefix PATH : "$out/libexec/${pname}:${lib.makeBinPath [ jdk coreutils gnugrep which git python3 ]}" \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath ([
        # Some internals want libstdc++.so.6
        stdenv.cc.cc.lib libsecret e2fsprogs
        libnotify
        libsecret e2fsprogs libnotify
        # Required for Help -> Collect Logs
        # in at least rider and goland
        udev