Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Sep 2013 01:45:19 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Baptiste Daroussin <bapt@FreeBSD.org>
Cc:        java@FreeBSD.org, Greg Lewis <glewis@FreeBSD.org>
Subject:   Building java/openjdk7 with clang
Message-ID:  <108F3771-64B3-40E9-91FA-04C160442608@FreeBSD.org>

next in thread | raw e-mail | index | archive | help

--Apple-Mail=_484484E3-1B53-4A83-A485-8A192C1E3AD7
Content-Type: multipart/mixed;
	boundary="Apple-Mail=_423C12BA-A4B6-4E1B-9D43-BE6CF796B379"


--Apple-Mail=_423C12BA-A4B6-4E1B-9D43-BE6CF796B379
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii

Hi,

I took some time to figure out how to build java/openjdk7 with clang.
There are a few items I changed:

- Change a few instances of "ifneq ($(COMPILER_WARNINGS_FATAL),false)"
  to "ifeq ($(COMPILER_WARNINGS_FATAL),true)", to make sure -Werror is
  *not* used.  There are zillions of warnings in openjdk, and I don't
  think it is worth the trouble to fix them all (even if that is
  possible :).
- Remove -fcheck-new from CFLAGS, since clang does not support it, and
  it does not make sense anyway.  This is the only one that is not
  strictly needed; if -Werror is not enabled, clang will just print a
  warning that the option is unused, but it won't be fatal.
- Change the $(CC) -dumpspecs hack in one of the Makefiles to something
  more portable.  The -dumpspecs is done to figure out if the compiler
  uses --hash-style=gnu when linking, and if it does, it changes the
  option to --hash-style=both.  On FreeBSD, this is basically a no-op,
  so it could also be commented out entirely.
- In jdk/src/solaris/native/java/net/net_util_md.c, change two
  instances of CHECK_NULL() to CHECK_NULL_RETURN(), since the function
  they are in is supposed to return a value.  I chose to return 0,
  since that is what the function seems to use as a default value.

With these fixes, openjdk7 builds and runs fine for me.  I tried to run
"gmake test" in the work directory, but that didn't do much, so I am
not sure if a full test suite will survive anything.  It would be nice
if anybody knows a good way to test the produced binaries more
thoroughly.

-Dimitry

--Apple-Mail=_423C12BA-A4B6-4E1B-9D43-BE6CF796B379
Content-Disposition: attachment;
	filename=java__openjdk7-fix-build-2.diff
Content-Type: application/octet-stream;
	name="java__openjdk7-fix-build-2.diff"
Content-Transfer-Encoding: 7bit

Index: java/openjdk7/Makefile
===================================================================
--- java/openjdk7/Makefile	(revision 327163)
+++ java/openjdk7/Makefile	(working copy)
@@ -29,7 +29,7 @@
 USE_XORG+=	x11 xext xi xrender xt xtst
 MAKE_ARGS=	CC=${CC} CXX=${CXX} HOST_CC=${CC}
 MAKE_JOBS_UNSAFE=	yes
-USE_GCC=	any
+#USE_GCC=	any
 
 OPTIONS_DEFINE=		DEBUG POLICY TZUPDATE
 OPTIONS_DEFAULT=	POLICY TZUPDATE
Index: java/openjdk7/files/patch-set
===================================================================
--- java/openjdk7/files/patch-set	(revision 327163)
+++ java/openjdk7/files/patch-set	(working copy)
@@ -5756,6 +5756,17 @@
  
  # Synonyms for win32-like targets.
  compiler2:  jvmg product
+--- hotspot/make/bsd/makefiles/adlc.make	2012-08-10 18:22:56.000000000 +0200
++++ hotspot/make/bsd/makefiles/adlc.make	2013-09-14 20:38:13.000000000 +0200
+@@ -68,7 +68,7 @@
+ 
+ # CFLAGS_WARN holds compiler options to suppress/enable warnings.
+ # Compiler warnings are treated as errors
+-ifneq ($(COMPILER_WARNINGS_FATAL),false)
++ifeq ($(COMPILER_WARNINGS_FATAL), true)
+   CFLAGS_WARN = -Werror
+ endif
+ CFLAGS += $(CFLAGS_WARN)
 --- hotspot/make/bsd/makefiles/buildtree.make	2012-08-10 09:22:57.000000000 -0700
 +++ hotspot/make/bsd/makefiles/buildtree.make	2013-04-28 16:29:16.000000000 -0700
 @@ -1,5 +1,5 @@
@@ -5975,6 +5986,14 @@
  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  #
  # This code is free software; you can redistribute it and/or modify it
+@@ -111,7 +111,6 @@
+ CFLAGS += -fno-rtti
+ CFLAGS += -fno-exceptions
+ CFLAGS += -pthread
+-CFLAGS += -fcheck-new
+ # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
+ # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
+ ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
 @@ -124,7 +124,11 @@
  ARCHFLAG/ia64    =
  ARCHFLAG/sparc   = -m32 -mcpu=v9
@@ -5987,6 +6006,15 @@
  
  # Darwin-specific build flags
  ifeq ($(OS_VENDOR), Darwin)
+@@ -159,7 +162,7 @@
+ endif
+ 
+ # Compiler warnings are treated as errors
+-ifneq ($(COMPILER_WARNINGS_FATAL),false)
++ifeq ($(COMPILER_WARNINGS_FATAL), true)
+   WARNINGS_ARE_ERRORS = -Werror
+ endif
+ 
 @@ -285,6 +289,26 @@
  DEBUG_CFLAGS += -gstabs
  endif
Index: java/openjdk7/files/patch-set-jdk
===================================================================
--- java/openjdk7/files/patch-set-jdk	(revision 327163)
+++ java/openjdk7/files/patch-set-jdk	(working copy)
@@ -451,7 +451,7 @@
 +
 +# If this is a --hash-style=gnu system, use --hash-style=both
 +#   The gnu .hash section won't work on some Linux systems like SuSE 10.
-+_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
++_HAS_HASH_STYLE_GNU:=$(shell $(CC) -v /dev/null -o /dev/null 2>&1 | $(GREP) -- '--hash-style=gnu')
 +ifneq ($(_HAS_HASH_STYLE_GNU),)
 +  LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
 +endif
@@ -96310,6 +96310,18 @@
  #ifdef __solaris__
  #include <sys/sockio.h>
  #include <stropts.h>
+@@ -114,9 +118,9 @@
+     static jfieldID ni_defaultIndexID;
+     if (ni_class == NULL) {
+         jclass c = (*env)->FindClass(env, "java/net/NetworkInterface");
+-        CHECK_NULL(c);
++        CHECK_NULL_RETURN(c, 0);
+         c = (*env)->NewGlobalRef(env, c);
+-        CHECK_NULL(c);
++        CHECK_NULL_RETURN(c, 0);
+         ni_defaultIndexID = (*env)->GetStaticFieldID(
+             env, c, "defaultIndex", "I");
+         ni_class = c;
 @@ -818,7 +822,7 @@
  NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him,
                            int *len, jboolean v4MappedAddress) {

--Apple-Mail=_423C12BA-A4B6-4E1B-9D43-BE6CF796B379
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii




--Apple-Mail=_423C12BA-A4B6-4E1B-9D43-BE6CF796B379--

--Apple-Mail=_484484E3-1B53-4A83-A485-8A192C1E3AD7
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)

iEYEARECAAYFAlI09RkACgkQsF6jCi4glqMPawCgs9TClZulaAmHYYl+ArGN2z+v
SiIAoPDRP4Z0zcKrWxJ9T0KUqdnESxSD
=jlCe
-----END PGP SIGNATURE-----

--Apple-Mail=_484484E3-1B53-4A83-A485-8A192C1E3AD7--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?108F3771-64B3-40E9-91FA-04C160442608>