From 5474272067063b084c3a57635ef72e2822a27c47 Mon Sep 17 00:00:00 2001 From: Tomas Antonio Lopez Date: Thu, 30 May 2024 00:21:56 +0200 Subject: [PATCH] openjdk: configure build to support a Clang-based stdenv --- pkgs/development/compilers/openjdk/11.nix | 16 +++++++++++++--- pkgs/development/compilers/openjdk/17.nix | 11 +++++++++-- pkgs/development/compilers/openjdk/19.nix | 11 +++++++++-- pkgs/development/compilers/openjdk/20.nix | 11 +++++++++-- pkgs/development/compilers/openjdk/21.nix | 13 ++++++++++--- pkgs/development/compilers/openjdk/22.nix | 6 ++++++ 6 files changed, 56 insertions(+), 12 deletions(-) diff --git a/pkgs/development/compilers/openjdk/11.nix b/pkgs/development/compilers/openjdk/11.nix index 04df2d28a45c..cd176c2f90ec 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 1c9aee9af5e9..c54bedbca679 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 187d724b57b5..5a94f496898f 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 bdb7d057f263..e4d1749eb2fb 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 160b3da4c8ee..d8e61bf1e5fb 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 97d1a3b3b44d..7678e836c626 100644 --- a/pkgs/development/compilers/openjdk/22.nix +++ b/pkgs/development/compilers/openjdk/22.nix @@ -160,6 +160,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}";