Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Sep 2013 17:26:24 -0400
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        Dimitry Andric <dim@FreeBSD.org>,  Baptiste Daroussin <bapt@FreeBSD.org>
Cc:        java@FreeBSD.org, Greg Lewis <glewis@FreeBSD.org>
Subject:   Re: Building java/openjdk7 with clang
Message-ID:  <523B6C00.7070501@FreeBSD.org>
In-Reply-To: <108F3771-64B3-40E9-91FA-04C160442608@FreeBSD.org>
References:  <108F3771-64B3-40E9-91FA-04C160442608@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------090604040406090907070200
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-09-14 19:45:19 -0400, Dimitry Andric wrote:
> Hi,
> 
> I took some time to figure out how to build java/openjdk7 with
> clang. There are a few items I changed:

BTW, patch-set and patch-set-jdk are directly coming from the OpenJDK
Mercurial repositories:

http://hg.openjdk.java.net/bsd-port/bsd-port/
http://hg.openjdk.java.net/bsd-port/bsd-port/corba/
http://hg.openjdk.java.net/bsd-port/bsd-port/hotspot/
http://hg.openjdk.java.net/bsd-port/bsd-port/jaxp/
http://hg.openjdk.java.net/bsd-port/bsd-port/jaxws/
http://hg.openjdk.java.net/bsd-port/bsd-port/jdk/
http://hg.openjdk.java.net/bsd-port/bsd-port/langtools/

Note the bsd-port is shared with other BSDs and we don't want to upset
other BSD users. ;-)

> - 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
> :).

AFAIK, it was *intentionally* turned on by default for HotSpot.  We
can override it via MAKE_ENV for ports tree for now, however.

> - 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.

A proper fix may be committed to upstream to minimize diff.  Please
see my patch for example.

> - 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.

Agreed.  It was based on Defs-linux.gmk but it is actually
BSD-specific file.  I don't think any BSDs ever used
'--hash-style=gnu'.  Therefore, this check should be removed
altogether, IMO.

BTW, your test doesn't work because the output is going to stderr, not
stdout.  Please see my patch for "-fcheck-new" for a proper test. ;-)

> - 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.

Looks good.  Actually, this problem was fixed in JDK8 long ago:

http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/eb441933f6fe

> 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.

Thanks for working on this!

Jung-uk Kim

* PS: The attached patch is also available from here:

http://people.freebsd.org/~jkim/openjdk7.diff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (FreeBSD)

iQEcBAEBAgAGBQJSO2v/AAoJECXpabHZMqHOtVIIAIHsmyECYTRq/aZ8XDpqaWF7
fgzLk9Cr3+nigSTHBf/vqDqaMUEQz9uQlgv+YrKYoNlbiUw/DjDg9tmpRxKtsDRh
6qg4hzVlVdgJqMvIaRi+SFsLZY3/eym1NzWs2MKqJj0BqmSt4uubkQP43xJCGMgO
2A5e4q3RO97MwV/z0ocQ5LgB092a3OkyF+9lMG0enw1FJgfQSwcnZuqQa7howF4l
+nazX5ey3aVfzwVUaldjsl5XsdTlX0ed5hd+bc60pEc5P+fcBmW1Mzpl8BJg0mgh
qaKYyWrtHWcWEBq/Y2C6jv/F8JljH9UWuBlvOOJzXo9aOSW5MPguNXQbA8MoPo8=
=QTdD
-----END PGP SIGNATURE-----

--------------090604040406090907070200
Content-Type: text/x-patch;
 name="openjdk7.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="openjdk7.diff"

Index: java/openjdk7/Makefile
===================================================================
--- java/openjdk7/Makefile	(revision 327646)
+++ java/openjdk7/Makefile	(working copy)
@@ -29,7 +29,6 @@ USES=		iconv gmake
 USE_XORG+=	x11 xext xi xrender xt xtst
 MAKE_ARGS=	CC=${CC} CXX=${CXX} HOST_CC=${CC}
 MAKE_JOBS_UNSAFE=	yes
-USE_GCC=	any
 
 OPTIONS_DEFINE=		DEBUG POLICY TZUPDATE
 OPTIONS_DEFAULT=	POLICY TZUPDATE
@@ -86,6 +85,7 @@ MAKE_ENV+=	LANG="C" \
 		JAVACMD=${BOOTSTRAPJDKDIR}/bin/java \
 		X11DIR="${LOCALBASE}" \
 		LOCALDIR="${LOCALBASE}" \
+		COMPILER_WARNINGS_FATAL="false" \
 		NO_DOCS="true" \
 		SKIP_COMPARE_IMAGES="true" \
 		SKIP_FASTDEBUG_BUILD="true" \
Index: java/openjdk7/files/patch-set-clang
===================================================================
--- java/openjdk7/files/patch-set-clang	(revision 0)
+++ java/openjdk7/files/patch-set-clang	(working copy)
@@ -0,0 +1,13 @@
+--- hotspot/make/bsd/makefiles/gcc.make.orig
++++ hotspot/make/bsd/makefiles/gcc.make
+@@ -111,7 +111,10 @@
+ CFLAGS += -fno-rtti
+ CFLAGS += -fno-exceptions
+ CFLAGS += -pthread
++# Clang does not support -fcheck-new.
++ifeq (,$(findstring clang,$(shell $(CC) -v 2>&1)))
+ CFLAGS += -fcheck-new
++endif
+ # 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"

Property changes on: java/openjdk7/files/patch-set-clang
___________________________________________________________________
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: java/openjdk7/files/patch-set-jdk-clang
===================================================================
--- java/openjdk7/files/patch-set-jdk-clang	(revision 0)
+++ java/openjdk7/files/patch-set-jdk-clang	(working copy)
@@ -0,0 +1,17 @@
+--- jdk/make/common/Defs-bsd.gmk.orig
++++ jdk/make/common/Defs-bsd.gmk
+@@ -217,14 +217,6 @@
+   LDFLAGS_COMMON        += $(LDFLAGS_COMMON_$(ARCH))
+ endif
+ 
+-# 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')
+-ifneq ($(_HAS_HASH_STYLE_GNU),)
+-  LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
+-endif
+-LDFLAGS_COMMON          += $(LDFLAGS_HASH_STYLE)
+-
+ #
+ # Selection of warning messages
+ #

Property changes on: java/openjdk7/files/patch-set-jdk-clang
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: java/openjdk7/files/patch-src-solaris-native-java-net-net_util_md.c
===================================================================
--- java/openjdk7/files/patch-src-solaris-native-java-net-net_util_md.c	(revision 0)
+++ java/openjdk7/files/patch-src-solaris-native-java-net-net_util_md.c	(working copy)
@@ -0,0 +1,14 @@
+--- jdk/src/solaris/native/java/net/net_util_md.c.orig
++++ jdk/src/solaris/native/java/net/net_util_md.c
+@@ -118,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;

Property changes on: java/openjdk7/files/patch-src-solaris-native-java-net-net_util_md.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: fbsd:nokeywords
## -0,0 +1 ##
+yes
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property

--------------090604040406090907070200--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?523B6C00.7070501>