Avoid using deprecated stat64 on Mac OS X

Krystal Mok rednaxelafx at gmail.com
Sun Jul 28 23:02:04 PDT 2013


Thank you very much, David.

By the way, my build environment that had this problem was:
Mac OS X 10.7.5,
XCode 4.1
i686-apple-darwin11-llvm-g++-4.2

- Kris


On Mon, Jul 29, 2013 at 1:57 PM, David Holmes <david.holmes at oracle.com>wrote:

> On 29/07/2013 3:34 PM, Krystal Mok wrote:
>
>> Hi David,
>>
>> Thanks for taking a look. I'm not that familiar with other BSD variants,
>> and I'm only encountering this on Mac OS X. Looking for help here.
>>
>
> I can only assume that the warning is new in 10.8 as we don't see it
> building on 10.7. And given we are about to enable building on 10.8 this is
> good to find now! I've filed 8021771.
>
>
>  I think FreeBSD also uses the bsd-port in their downstream OpenJDK
>> package. FreeBSD uses stat instead of stat64, too.
>>
>
> We (ie whomever fixes this :) ) need to determine whether this can simply
> be changed or whether it needs to be ifdef'd on OSX.
>
> Thanks,
> David
>
>  Thanks,
>> Kris
>>
>>
>> On Mon, Jul 29, 2013 at 1:24 PM, David Holmes <david.holmes at oracle.com
>> <mailto:david.holmes at oracle.**com <david.holmes at oracle.com>>> wrote:
>>
>>     Hi Kris,
>>
>>
>>     On 28/07/2013 5:59 PM, Krystal Mok wrote:
>>
>>         Hi all,
>>
>>         I'm building a freshly cloned repo from the tip of hotspot-comp
>>         on Mac OS X
>>         10.7.5, and got and error:
>>
>>         llvm-g++ -D_ALLBSD_SOURCE -D_GNU_SOURCE -DAMD64 -DASSERT -I.
>>         -I/Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/__**
>> share/vm/prims
>>         -I/Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/__**
>> share/vm
>>         -I/Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/__**
>> share/vm/precompiled
>>         -I/Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/cpu/_**
>> _x86/vm
>>         -I/Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/os___**
>> cpu/bsd_x86/vm
>>         -I/Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/os/__**
>> bsd/vm
>>         -I/Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/os/__**
>> posix/vm
>>         -I../generated -DHOTSPOT_RELEASE_VERSION="\"_**
>> _25.0-b44-internal\""
>>         -DHOTSPOT_BUILD_TARGET="\"__**fastdebug\""
>>         -DHOTSPOT_BUILD_USER="\"__**rednaxelafx\""
>>         -DHOTSPOT_LIB_ARCH=\"amd64\"
>>         -DHOTSPOT_VM_DISTRO="\"__**OpenJDK\""  -DTARGET_OS_FAMILY_bsd
>>         -DTARGET_ARCH_x86
>>         -DTARGET_ARCH_MODEL_x86_64 -DTARGET_OS_ARCH_bsd_x86
>>         -DTARGET_OS_ARCH_MODEL_bsd___**x86_64 -DTARGET_COMPILER_gcc
>>
>>         -DCOMPILER2
>>         -DCOMPILER1 -fPIC -fno-rtti -fno-exceptions -pthread -fcheck-new
>>         -m64
>>            -pipe -fno-strict-aliasing -DMAC_OS_X_VERSION_MAX___**
>> ALLOWED=1070
>>
>>         -mmacosx-version-min=10.7.0 -Os  -DVM_LITTLE_ENDIAN -D_LP64=1
>>         -fno-omit-frame-pointer -Werror -Wunused-function
>>           -DDTRACE_ENABLED
>>            -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -DALLOW_OPERATOR_NEW_USAGE
>>         -c -MMD -MP
>>         -MF ../generated/dependencies/__**attachListener_bsd.o.d
>> -fpch-deps -o
>>         attachListener_bsd.o
>>         /Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/os/__**
>> bsd/vm/attachListener_bsd.cpp
>>
>>         cc1plus: warnings being treated as errors
>>         /Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/os/__**
>> bsd/vm/attachListener_bsd.cpp:
>>
>>         In static member function ‘static void
>> AttachListener::vm_start()’:
>>         /Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/os/__**
>> bsd/vm/attachListener_bsd.cpp:**__455:
>>
>>         warning: ‘stat64’ is deprecated (declared at
>>         /usr/include/sys/stat.h:466)
>>         /Users/rednaxelafx/build/__**hotspot-comp/hotspot/src/os/__**
>> bsd/vm/attachListener_bsd.cpp:**__455:
>>
>>         warning: ‘stat64’ is deprecated (declared at
>>         /usr/include/sys/stat.h:466)
>>         make[6]: *** [attachListener_bsd.o] Error 1
>>
>>         The problem came from a recent commit [1]:
>>         7162400: Intermittent java.io.IOException: Bad file number during
>>         HotSpotVirtualMachine.__**executeCommand
>>
>>
>>         According to [2], the *-64 variants of the stat*() functions
>>         have been
>>         deprecated on Mac OS X and should be avoided.
>>
>>
>>     So is this purely an OSX issue or also a BSD one? I'm assuming OSX.
>>
>>     Does anybody out there actually use the BSD port seperately from OSX?
>>
>>     David
>>     -----
>>
>>
>>
>>         The fix is simple:
>>         diff -r d90d1b96b65b src/os/bsd/vm/attachListener__**_bsd.cpp
>>         --- a/src/os/bsd/vm/__**attachListener_bsd.cpp Fri Jul 26
>> 12:37:39
>>         2013 -0700
>>         +++ b/src/os/bsd/vm/__**attachListener_bsd.cpp Sun Jul 28
>> 15:55:54
>>
>>         2013 +0800
>>         @@ -445,14 +445,14 @@
>>
>>            void AttachListener::vm_start() {
>>              char fn[UNIX_PATH_MAX];
>>         -  struct stat64 st;
>>         +  struct stat st;
>>              int ret;
>>
>>              int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
>>                       os::get_temp_directory(), os::current_process_id());
>>              assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer
>>         overflow");
>>
>>         -  RESTARTABLE(::stat64(fn, &st), ret);
>>         +  RESTARTABLE(::stat(fn, &st), ret);
>>              if (ret == 0) {
>>                ret = ::unlink(fn);
>>                if (ret == -1) {
>>
>>         I'm not sure if this should be done for all BSD platforms. Could
>>         anybody
>>         help confirm this?
>>
>>         Thanks,
>>         Kris
>>
>>         (P.S. recovering from bad health...)
>>
>>         [1]:
>>         http://hg.openjdk.java.net/__**hsx/hotspot-comp/hotspot/rev/_**
>> _2e8f19c2feef<http://hg.openjdk.java.net/__hsx/hotspot-comp/hotspot/rev/__2e8f19c2feef>
>>         <http://hg.openjdk.java.net/**hsx/hotspot-comp/hotspot/rev/**
>> 2e8f19c2feef<http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/2e8f19c2feef>
>> >
>>         [2]:
>>         https://developer.apple.com/__**library/mac/documentation/__**
>> Darwin/Reference/ManPages/__**man2/stat64.2.html<https://developer.apple.com/__library/mac/documentation/__Darwin/Reference/ManPages/__man2/stat64.2.html>
>>         <https://developer.apple.com/**library/mac/documentation/**
>> Darwin/Reference/ManPages/**man2/stat64.2.html<https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat64.2.html>
>> >
>>
>>
>>


More information about the hotspot-dev mailing list