svn commit: r280327 - in head/sys: kern vm

Bryan Drewery bdrewery at FreeBSD.org
Mon Mar 30 17:12:23 UTC 2015


On 3/30/2015 4:12 AM, Konstantin Belousov wrote:
> On Sun, Mar 29, 2015 at 11:25:14PM -0700, Don Lewis wrote:
>> On amd64, with an amd64 jail, and kernel rev r280326, I observe the
>> following:
>> 	One gcc process calls mmap() with addr=0 and len=0x657a000, and
>>         the value 0x811400000 is returned.  Subsequent gcc processes
>>         call mmap() with addr=0x811400000 and len=0x657a000, getting
>>         0x811400000 in return.
>>
>> With kernel rev r280327 I see:
>> 	One gcc process calls mmap() with addr=0 and len=0x657a000, and
>> 	the value 0x811400000 is returned.  Subsequent gcc processes
>> 	call mmap() with addr=0x811400000 and len=0x657a000, getting
>> 	0x8115f4000 in return.  What I later noticed is that the subsequent
>> 	calls are passing offset=0x1f4000.  Not so coincidentally,
>> 	0x811400000 + 0x1f4000 = 0x8115F4000.
>>
>> My first attempt at a fix subtracted offset from address, but the mmap()
>> return value changed to 0x8113f4000 instead of the 0x811400000 I was
>> expecting.  It looked to me like the code must be doing superpage
>> alignment on the start of the file and then adding the offset to get the
>> start of the mapped region.
> So the real fix is to make gcc pass MAP_FIXED.
> 
>>
>> This somewhat hacking patch disables this alignment if a non-zero
>> address is passed as a hint, and allows the code to make the start of
>> the mapped region match the hint.  With this patch, I've been able to
>> build openjdk7 in a FreeBSD 9.3 amd64 jail.
>>
> This is for precompiled headers, right ?  Could port disable pch ?
> 

That is my opinion as well but I don't think it is enough.

This gcc issue is quite old. Here is a 2004 reference for a similar
issue on Cygwin. https://gcc.gnu.org/ml/gcc-bugs/2004-05/msg00559.html

I think it is not enough to disable PCH in openjdk7. I am finding the
"had to relocate PCH" error referenced in many other ports. I have ran
into it randomly before as well.

I think what we need to do is:

1. Fix GCC on head to use MAP_FIXED
2. Fix GCC ports to all use MAP_FIXED
3. Force ports that use PCH builds to use the port GCC or clang and not
the base GCC in all releases.

This patch should fix openjdk7 for now. My test build is still running.

~/svn/ports/java/openjdk7 # svn diff
Index: Makefile
===================================================================
--- Makefile    (revision 382519)
+++ Makefile    (working copy)
@@ -26,7 +26,7 @@

 WRKSRC=                ${WRKDIR}/${PORTNAME}

-USES=          dos2unix iconv gmake zip
+USES=          compiler:features dos2unix iconv gmake zip
 USE_XORG+=     x11 xext xi xrender xt xtst
 MAKE_ARGS=     CC=${CC:Q} CXX=${CXX:Q} HOST_CC=${CC:Q}

@@ -125,6 +125,10 @@

 .include <bsd.port.pre.mk>

+.if ${COMPILER_TYPE} != clang
+MAKE_ENV+=     USE_PRECOMPILED_HEADER=0
+.endif
+
 .if empty(ICONV_LIB)
 MAKE_ENV+=     EXTRA_CFLAGS=-DLIBICONV_PLUG
 .endif
Index: files/patch-bsd
===================================================================
--- files/patch-bsd     (revision 382519)
+++ files/patch-bsd     (working copy)
@@ -184,16 +184,12 @@
  # 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"
-@@ -215,7 +218,11 @@
+@@ -215,7 +218,7 @@

  # Flags for generating make dependency flags.
  ifneq ("${CC_VER_MAJOR}", "2")
 -DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
-+DEPFLAGS =
-+ifeq (,$(findstring clang,$(shell $(CC) -v 2>&1)))
-+DEPFLAGS += -fpch-deps
-+endif
-+DEPFLAGS += -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
++DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
  endif

  # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in
precompiled.hpp.


-- 
Regards,
Bryan Drewery

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20150330/d64e699f/attachment.sig>


More information about the svn-src-head mailing list