diff --git a/pkgs/development/compilers/openjdk/11.nix b/pkgs/development/compilers/openjdk/11.nix index d4fde704985b..089e8411210c 100644 --- a/pkgs/development/compilers/openjdk/11.nix +++ b/pkgs/development/compilers/openjdk/11.nix @@ -74,9 +74,19 @@ let "--with-lcms=system" "--with-stdc++lib=dynamic" "--disable-warnings-as-errors" - ] ++ lib.optional stdenv.isx86_64 "--with-jvm-features=zgc" - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + ] + # Cannot be built by recent versions of Clang, as far as I can tell (see + # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260319). Known to + # compile with LLVM 12. + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] + ++ lib.optional stdenv.isx86_64 "--with-jvm-features=zgc" + ++ lib.optional headless "--enable-headless-only" + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; separateDebugInfo = true; diff --git a/pkgs/development/compilers/openjdk/17.nix b/pkgs/development/compilers/openjdk/17.nix index 09f3518880ef..6716f443bdb1 100644 --- a/pkgs/development/compilers/openjdk/17.nix +++ b/pkgs/development/compilers/openjdk/17.nix @@ -98,8 +98,15 @@ let "--with-zlib=system" "--with-lcms=system" "--with-stdc++lib=dynamic" - ] ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + ] + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] + ++ lib.optional headless "--enable-headless-only" + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; separateDebugInfo = true; diff --git a/pkgs/development/compilers/openjdk/19.nix b/pkgs/development/compilers/openjdk/19.nix index dd01d19bcfbd..8a28a6851a35 100644 --- a/pkgs/development/compilers/openjdk/19.nix +++ b/pkgs/development/compilers/openjdk/19.nix @@ -100,8 +100,15 @@ let "--with-zlib=system" "--with-lcms=system" "--with-stdc++lib=dynamic" - ] ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + ] + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] + ++ lib.optional headless "--enable-headless-only" + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; separateDebugInfo = true; diff --git a/pkgs/development/compilers/openjdk/20.nix b/pkgs/development/compilers/openjdk/20.nix index 9726be71293f..1f2216b1a292 100644 --- a/pkgs/development/compilers/openjdk/20.nix +++ b/pkgs/development/compilers/openjdk/20.nix @@ -98,8 +98,15 @@ let "--with-zlib=system" "--with-lcms=system" "--with-stdc++lib=dynamic" - ] ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + ] + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] + ++ lib.optional headless "--enable-headless-only" + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; separateDebugInfo = true; diff --git a/pkgs/development/compilers/openjdk/21.nix b/pkgs/development/compilers/openjdk/21.nix index ad7c789c0bf5..9c403fb2755d 100644 --- a/pkgs/development/compilers/openjdk/21.nix +++ b/pkgs/development/compilers/openjdk/21.nix @@ -91,9 +91,16 @@ let "--with-zlib=system" "--with-lcms=system" "--with-stdc++lib=dynamic" - ] ++ lib.optional stdenv.isx86_64 "--with-jvm-features=zgc" - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + ] + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] + ++ lib.optional stdenv.isx86_64 "--with-jvm-features=zgc" + ++ lib.optional headless "--enable-headless-only" + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; separateDebugInfo = true; diff --git a/pkgs/development/compilers/openjdk/22.nix b/pkgs/development/compilers/openjdk/22.nix index 9d682c30be43..18ab52f089d3 100644 --- a/pkgs/development/compilers/openjdk/22.nix +++ b/pkgs/development/compilers/openjdk/22.nix @@ -156,6 +156,12 @@ stdenv.mkDerivation (finalAttrs: { "--with-lcms=system" "--with-stdc++lib=dynamic" ] + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] ++ lib.optional headless "--enable-headless-only" ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}";