Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# runtime dependencies
, cups
# runtime dependencies for GTK+ Look and Feel
, gtkSupport ? true
, headless ? false
, cairo
, glib
, gtk3
Expand All @@ -26,7 +26,7 @@ let
cpuName = stdenv.hostPlatform.parsed.cpu.name;
runtimeDependencies = [
cups
] ++ lib.optionals gtkSupport [
] ++ lib.optionals (!headless) [
cairo glib gtk3
];
runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
, zlib
# extra params
, extraCLibs ? [ ]
, gtkSupport ? stdenv.isLinux
, headless ? !stdenv.isLinux
, useMusl ? false
, ...
} @ args:
Expand All @@ -45,7 +45,7 @@ let
"xorg"
"zlib"
"extraCLibs"
"gtkSupport"
"headless"
"useMusl"
"passthru"
"meta"
Expand All @@ -66,7 +66,7 @@ let
binPath = lib.makeBinPath (lib.optionals useMusl [ musl-gcc ] ++ [ stdenv.cc ]);

runtimeLibraryPath = lib.makeLibraryPath
([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]);
([ cups ] ++ lib.optionals (!headless) [ cairo glib gtk3 ]);

graalvm-ce = stdenv.mkDerivation ({
pname = "graalvm-ce";
Expand Down
175 changes: 175 additions & 0 deletions pkgs/development/compilers/openjdk/10/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{ stdenv, lib, pkgs, fetchurl, bash, cpio, pkg-config, file, which, unzip, zip, cups, freetype
, alsaLib, openjdk10-bootstrap, perl, liberation_ttf, fontconfig, zlib, lndir
, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr
, libjpeg, giflib
, gnumake42
, setJavaClassPath
, headless ? false
, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf
}:

let

# when building a headless jdk, also bootstrap it with a headless jdk
openjdk-bootstrap' = openjdk10-bootstrap.override { inherit headless; };

openjdk10 = stdenv.mkDerivation rec {
pname = "openjdk" + lib.optionalString headless "-headless";
version = "10.0.2+13";

src = pkgs.fetchFromGitHub {
owner = "openjdk";
repo = "jdk10u";
rev = "jdk-${version}";
sha256 = "sha256-BsSTX7WkyVOX6OjO1WDI8RnH9j065nG8gC9Wlo6p9gY=";
};

outputs = [ "out" "jre" ];

nativeBuildInputs = [ pkg-config gnumake42 ];
buildInputs = [
cpio file which unzip zip perl openjdk-bootstrap' zlib cups freetype alsaLib
libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst
libXi libXinerama libXcursor libXrandr lndir fontconfig
] ++ lib.optionals (!headless && enableGnome2) [
gtk3 gnome_vfs GConf glib
];

patches = [
./patches/fix-java-home-jdk10.patch
./patches/read-truststore-from-env-jdk10.patch
./patches/openjdk-10-idlj-reproducibility.patch
./patches/openjdk-10-pointer-comparison.patch
./patches/openjdk-10-setsignalhandler.patch
./patches/openjdk-currency-time-bomb2.patch
] ++ lib.optionals (!headless && enableGnome2) [
./patches/swing-use-gtk-jdk10.patch
];

preConfigure = ''
chmod +x configure
substituteInPlace configure --replace /bin/bash "${bash}/bin/bash"

configureFlagsArray=(
"--with-boot-jdk=${openjdk-bootstrap'.home}"
"--enable-unlimited-crypto"
"--disable-debug-symbols"
"--disable-freetype-bundling"
"--with-zlib=system"
"--with-giflib=system"
"--with-stdc++lib=dynamic"

# glibc 2.24 deprecated readdir_r so we need this
# See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html
"--with-extra-cflags=-Wno-error=deprecated-declarations -Wno-error=format-contains-nul -Wno-error=unused-result"
''
+ lib.optionalString headless "\"--enable-headless-only\""
+ ");"
# https://bugzilla.redhat.com/show_bug.cgi?id=1306558
# https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716
+ lib.optionalString stdenv.cc.isGNU ''
NIX_CFLAGS_COMPILE+=" -fcommon -fno-lifetime-dse -fno-delete-null-pointer-checks -std=gnu++98 -Wno-error"
'';

NIX_LDFLAGS= lib.optionals (!headless) [
"-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic"
] ++ lib.optionals (!headless && enableGnome2) [
"-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
];

buildFlags = [ "images" ];

installPhase = ''
mkdir -p $out/lib/openjdk $out/share $jre/lib/openjdk

cp -av build/*/images/jdk/* $out/lib/openjdk

# Remove some broken manpages.
rm -rf $out/lib/openjdk/man/ja*

# Mirror some stuff in top-level.
mkdir $out/include $out/share/man
ln -s $out/lib/openjdk/include/* $out/include/
ln -s $out/lib/openjdk/man/* $out/share/man/

# jni.h expects jni_md.h to be in the header search path.
ln -s $out/include/linux/*_md.h $out/include/

# Copy the JRE to a separate output and setup fallback fonts
cp -av build/*/images/jre $jre/lib/openjdk/
mkdir $out/lib/openjdk/jre
${lib.optionalString (!headless) ''
mkdir -p $jre/lib/openjdk/jre/lib/fonts/fallback
lndir ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback
''}

# Remove crap from the installation.
rm -rf $out/lib/openjdk/demo
${lib.optionalString headless ''
for d in $out/lib/openjdk/lib $jre/lib/openjdk/jre/lib; do
rm ''${d}/{libjsound,libjsoundalsa,libfontmanager}.so
done
''}

lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre

# Remove duplicate binaries.
for i in $(cd $out/lib/openjdk/bin && echo *); do
if [ "$i" = java ]; then continue; fi
if cmp -s $out/lib/openjdk/bin/$i $jre/lib/openjdk/jre/bin/$i; then
ln -sfn $jre/lib/openjdk/jre/bin/$i $out/lib/openjdk/bin/$i
fi
done

ln -s $out/lib/openjdk/bin $out/bin
ln -s $jre/lib/openjdk/jre/bin $jre/bin
ln -s $jre/lib/openjdk/jre $out/jre
'';

preFixup = ''
# Set JAVA_HOME automatically.
mkdir -p $out/nix-support
cat <<EOF > $out/nix-support/setup-hook
if [ -z "\$\{JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi
EOF
'';

postFixup = ''
# Build the set of output library directories to rpath against
LIBDIRS=""
for output in $outputs; do
LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS"
done

# Add the local library paths to remove dependencies on the bootstrap
for output in $outputs; do
OUTPUTDIR=$(eval echo \$$output)
BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)
echo "$BINLIBS" | while read i; do
patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true
patchelf --shrink-rpath "$i" || true
done
done

# Test to make sure that we don't depend on the bootstrap
for output in $outputs; do
if grep -q -r '${openjdk-bootstrap'}' $(eval echo \$$output); then
echo "Extraneous references to ${openjdk-bootstrap'} detected"
exit 1
fi
done
'';

meta = with lib; {
homepage = http://openjdk.java.net/;
license = licenses.gpl2;
description = "The open-source Java Development Kit";
maintainers = with maintainers; [ edwtjo ];
platforms = ["i686-linux" "x86_64-linux"];
};

passthru = {
home = "${openjdk10}/lib/openjdk";
};
};
in openjdk10
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From a0a0c6a43b88d946f2b5484892cf0209bd7c0e68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Boskovits?= <boskovits@gmail.com>
Date: Sat, 8 Dec 2018 21:25:31 +0100
Subject: [PATCH] Make idlj respect SOURCE_DATE_EPOCH.

---
.../sun/tools/corba/se/idl/toJavaPortable/Util.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/java.corba/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Util.java b/src/java.corba/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Util.java
index 7397619f2..583d6b8e4 100644
--- a/src/java.corba/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Util.java
+++ b/src/java.corba/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Util.java
@@ -1146,7 +1146,18 @@ public class Util extends com.sun.tools.corba.se.idl.Util
else
formatter.setTimeZone (java.util.TimeZone.getDefault ());

- stream.println ("* " + formatter.format (new Date ()));
+ try {
+ String epoch = System.getenv("SOURCE_DATE_EPOCH");
+ if(epoch != null) {
+ long unixTime = Long.parseLong(epoch);
+ stream.println ("* " + formatter.format (new Date (unixTime*1000L)));
+ } else {
+ stream.println ("* " + formatter.format (new Date ()));
+ }
+ } catch (Exception e) {
+ //in case of error fall back to default
+ stream.println ("* " + formatter.format (new Date ()));
+ }

// <daz>
///////////////
--
2.19.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Patch inspired by file comparison with openjdk@19.

diff -u -r openjdk-10.alt/src/hotspot/os/linux/os_linux.cpp openjdk-10/src/hotspot/os/linux/os_linux.cpp
--- openjdk-10.alt/src/hotspot/os/linux/os_linux.cpp 2023-04-05 15:02:56.994779480 +0200
+++ openjdk-10/src/hotspot/os/linux/os_linux.cpp 2023-04-05 15:07:47.267537301 +0200
@@ -2155,7 +2155,7 @@
}

p = OSContainer::cpu_cpuset_memory_nodes();
- if (p < 0)
+ if (p == NULL)
st->print("cpu_memory_nodes() failed\n");
else {
st->print("cpu_memory_nodes: %s\n", p);
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Patch inspired by file comparison with openjdk@19.

diff -u -r openjdk-10.alt/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c openjdk-10/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c
--- openjdk-10.alt/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c 2023-04-05 15:03:00.070787628 +0200
+++ openjdk-10/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c 2023-04-05 15:29:51.379824348 +0200
@@ -67,8 +67,17 @@
longjmp(context, 1);
}

-void set_signal_handler() {
- static char altstack[SIGSTKSZ];
+static char* altstack = NULL;
+
+ void set_signal_handler() {
+ if (altstack == NULL) {
+ // Dynamically allocated in case SIGSTKSZ is not constant
+ altstack = (char*)malloc(SIGSTKSZ);
+ if (altstack == NULL) {
+ fprintf(stderr, "Test ERROR. Unable to malloc altstack space\n");
+ exit(7);
+ }
+ }

stack_t ss = {
.ss_size = SIGSTKSZ,
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Fix a time bomb present in the OpenJDK tools.

--- a/make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
+++ b/make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
@@ -285,7 +285,7 @@ public class GenerateCurrencyData {
String timeString = currencyInfo.substring(4, length - 4);
long time = format.parse(timeString).getTime();
if (Math.abs(time - System.currentTimeMillis()) > ((long) 10) * 365 * 24 * 60 * 60 * 1000) {
- throw new RuntimeException("time is more than 10 years from present: " + time);
+ System.err.println("note: time is more than 10 years from \"present\": " + time);
}
specialCaseCutOverTimes[specialCaseCount] = time;
specialCaseOldCurrencies[specialCaseCount] = oldCurrency;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
build = "9";

# when building a headless jdk, also bootstrap it with a headless jdk
openjdk-bootstrap = openjdk11-bootstrap.override { gtkSupport = !headless; };
openjdk-bootstrap = openjdk11-bootstrap.override { inherit headless; };

openjdk = stdenv.mkDerivation rec {
pname = "openjdk" + lib.optionalString headless "-headless";
Expand All @@ -38,11 +38,11 @@ let
];

patches = [
./fix-java-home-jdk10.patch
./read-truststore-from-env-jdk10.patch
./currency-date-range-jdk10.patch
./increase-javadoc-heap.patch
./fix-library-path-jdk11.patch
./patches/fix-java-home-jdk10.patch
./patches/read-truststore-from-env-jdk10.patch
./patches/currency-date-range-jdk10.patch
./patches/increase-javadoc-heap.patch
./patches/fix-library-path-jdk11.patch

# Fix build for gnumake-4.4.1:
# https://github.com/openjdk/jdk/pull/12992
Expand All @@ -52,7 +52,7 @@ let
hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg=";
})
] ++ lib.optionals (!headless && enableGnome2) [
./swing-use-gtk-jdk10.patch
./patches/swing-use-gtk-jdk10.patch
];

preConfigure = ''
Expand Down Expand Up @@ -160,7 +160,7 @@ let

disallowedReferences = [ openjdk-bootstrap ];

meta = import ./meta.nix lib version;
meta = import ../meta.nix lib version;

passthru = {
architecture = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/src/hotspot/os/linux/os_linux.cpp 2017-07-04 23:09:02.533972226 -0400
+++ b/src/hotspot/os/linux/os_linux.cpp 2017-07-04 23:07:52.118338845 -0400
@@ -2270,8 +2270,5 @@
assert(ret, "cannot locate libjvm");
char *rp = NULL;
if (ret && dli_fname[0] != '\0') {
- rp = os::Posix::realpath(dli_fname, buf, buflen);
- }
- if (rp == NULL) {
- return;
+ snprintf(buf, buflen, "%s", dli_fname);
}

if (Arguments::sun_java_launcher_is_altjvm()) {
Loading