Compiling /space/src/jdk7/hotspot/src/os/linux/vm/jvm_linux.cpp
rm -f jvm_linux.o
g++ -DLINUX -D_GNU_SOURCE -DIA32 -DPRODUCT -I. -I../generated/adfiles -I<<redacted>> -DHOTSPOT_RELEASE_VERSION="\"12.0-b03\"" -DHOTSPOT_BUILD_TARGET="\"product\"" -DHOTSPOT_BUILD_USER="\"jglick\"" -DJRE_RELEASE_VERSION="\"1.7.0-internal-jglick_2008_04_29_11_32-b00\"" -DHOTSPOT_VM_DISTRO="\"OpenJDK\"" -DCOMPILER2 -DCOMPILER1 -fno-rtti -fno-exceptions -D_REENTRANT -fcheck-new -m32 -march=i586 -pipe -O3 -fno-strict-aliasing -DVM_LITTLE_ENDIAN -Werror -Wpointer-arith -Wconversion -Wsign-compare -c -o jvm_linux.o /space/src/jdk7/hotspot/src/os/linux/vm/jvm_linux.cpp
cc1plus: warnings being treated as errors
/space/src/jdk7/hotspot/src/os/linux/vm/jvm_linux.cpp:179: warning: deprecated conversion from string constant to 'char*' /space/src/jdk7/hotspot/src/os/linux/vm/jvm_linux.cpp:179: warning: deprecated conversion from string constant to 'char*'
[...repeated many times...]
/space/src/jdk7/hotspot/src/os/linux/vm/jvm_linux.cpp:179: warning: deprecated conversion from string constant to 'char*'
make[5]: *** [jvm_linux.o] Error 1


Google shows the problem but no solution:

http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2008-February/001113.html


There are other similar errors later. I am attaching a sort of crude patch (for the hotspot tree, suitable for MQ) which seems to make things compile. Perhaps a newer version of GCC is just stricter?
Fixes "deprecated conversion from string constant to 'char*'" compiler warning.

diff --git a/src/os/linux/vm/jvm_linux.cpp b/src/os/linux/vm/jvm_linux.cpp
--- a/src/os/linux/vm/jvm_linux.cpp
+++ b/src/os/linux/vm/jvm_linux.cpp
@@ -132,7 +132,7 @@
 */
 
 struct siglabel {
-  char *name;
+  const char *name;
   int   number;
 };
 
diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
--- a/src/os/linux/vm/os_linux.cpp
+++ b/src/os/linux/vm/os_linux.cpp
@@ -213,7 +213,7 @@
 // the system call returns 1.  This causes the VM to act as if it is
 // a single processor and elide locking (see is_MP() call).
 static bool unsafe_chroot_detected = false;
-static char *unstable_chroot_error = "/proc file system not found.\n"
+static const char *unstable_chroot_error = "/proc file system not found.\n"
               "Java may be unstable running multithreaded in a chroot "
               "environment on Linux when /proc filesystem is not mounted.";
 
@@ -557,13 +557,13 @@
         // NPTL:
         if (sysconf(_SC_THREAD_THREADS_MAX) > 0) {
            free(str);
-           str = "linuxthreads";
+           str = (char *) "linuxthreads";
         }
      }
      os::Linux::set_libpthread_version(str);
   } else {
      // glibc before 2.3.2 only has LinuxThreads.
-     os::Linux::set_libpthread_version("linuxthreads");
+     os::Linux::set_libpthread_version((char *) "linuxthreads");
   }
 
   if (strstr(libpthread_version(), "NPTL")) {
@@ -4538,7 +4538,7 @@
 // Unlike system(), this function can be called from signal handler. It
 // doesn't block SIGINT et al.
 int os::fork_and_exec(char* cmd) {
-  char * argv[4];
+  const char * argv[4];
   argv[0] = "sh";
   argv[1] = "-c";
   argv[2] = cmd;

Reply via email to