Dear group,

I'm not sure if anyone is interested, however, I'd like to announce that I 
was able to build and use
X10 compiler on my old PowerMac (dual) G5 (PPC64) with MacOSX 10.5.x. For 
those who are actually interested, here's the whole story.

Since MacOSX 10.5.x lacks some command-line tools and system-provided 
libraries, installation of macports is obligatory (not to mention Xcode 
we can't move any further whithout gcc installed! I'm using 
xcode314_2809_developerdvd.dmg).

Things to install from macports are:

wget
subversion
ant
...and for OpenGL usability (will be described later):
mesa
freeglut
glew

Preferably, all with +universal variant selected (where available) for 
creating both ppc and ppc64 binaries.
Note that gcc version at least 4.2 is required, use 'port select gcc' 
commad to make sure your gcc is new enough. For my survey I was using 
apple-gcc42:

$ gcc --version
powerpc-apple-darwin9-gcc-apple-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) 
(dot 3) (MacPorts apple-gcc42 5666.3_9)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE.

Now, what can we expect when we try to build x10 with it?:

1. First obstacle - Java 1.5 shipped with MacOSX 10.5.x is too old, x10 
web site states clearly, 1.6
or later is required.
At first I was trying to find out if it was always the case. I've found
that version 2.2.1 can actually be built with system-wide installed Java 
1.5.
Later, after though googling I've found this:

http://www.intricatesoftware.com/OpenJDK/macppc/openjdk7u2-macppc-fcs-2012-03-14.tar.bz2

I've unpacked this to /opt and created a symlink in there:

openjdk  openjdk7u2-macppc-fcs-2012-03-14

This JDK turned out to be sufficient for building newer versions of x10 
I've tested latest SVN snapshot and version 2.2.3 (due to OpenGL issue, 
see below).

Before starting to build, some things need to be fixed. At first, let's 
built 32-bit compiler.

2. Second obstacle, no -msse2 neither -mfpmath=sse option available in 
PPC's gcc.
Now it turns out that all x10's MacOSX builds are expected to be 
Intel-CPU. Simple hack helps here:

Index: x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java
===================================================================
--- x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 
(wersja 24827)
+++ x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 
(kopia robocza)
@@ -22,8 +22,8 @@

      public void addPreArgs(ArrayList<String> cxxCmd) {
          super.addPreArgs(cxxCmd);
-        cxxCmd.add("-msse2");
-        cxxCmd.add("-mfpmath=sse");
+        cxxCmd.add("-faltivec");
+        cxxCmd.add("-maltivec");
      }

      public void addPostArgs(ArrayList<String> cxxCmd) {
Index: x10.runtime/Make.rules
===================================================================
--- x10.runtime/Make.rules      (wersja 24827)
+++ x10.runtime/Make.rules      (kopia robocza)
@@ -237,7 +237,7 @@
          override CXXFLAGS += -arch x86_64
          override XRX_PROPS_CXXFLAGS += -arch x86_64
        endif
-      override XRX_PROPS_CXXFLAGS += -msse2 -mfpmath=sse
+      override XRX_PROPS_CXXFLAGS += -maltivec -faltivec
        AR = libtool
        # Warning: Order matters!  The "-o" has to be at the end.
        ARFLAGS = -static -o

3. Third obstacle: 32-bit compiler did not satisfy me!
I wanted to have something that can exploit capabilities of G5 CPU 
completely. So I prepared one more patch (used instead the one listed 
above):

Index: x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java
===================================================================
--- x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 
(wersja 24832)
+++ x10.compiler/src/x10cpp/postcompiler/MacOSX_CXXCommandBuilder.java 
(kopia robocza)
@@ -22,8 +22,10 @@

      public void addPreArgs(ArrayList<String> cxxCmd) {
          super.addPreArgs(cxxCmd);
-        cxxCmd.add("-msse2");
-        cxxCmd.add("-mfpmath=sse");
+        cxxCmd.add("-faltivec");
+        cxxCmd.add("-maltivec");
+        cxxCmd.add("-arch");
+        cxxCmd.add("ppc64");
      }

      public void addPostArgs(ArrayList<String> cxxCmd) {
Index: x10.dist/releng/buildRelease.sh
===================================================================
--- x10.dist/releng/buildRelease.sh     (wersja 24832)
+++ x10.dist/releng/buildRelease.sh     (kopia robocza)
@@ -71,12 +71,11 @@
        SKIP_DEBUG_BUILD=1
        ;;
    Darwin,*,i*86)
-      X10_PLATFORM='macosx_x86'
-      export USE_32BIT=true
+      X10_PLATFORM='macosx_ppc64'
        export USE_64BIT=true
        SKIP_DEBUG_BUILD=1
        ;;
-
+
    *) echo "Unrecognized platform: '$UNAME'"; exit 1;;
  esac

Index: x10.dist/releng/buildToolIntegration.sh
===================================================================
--- x10.dist/releng/buildToolIntegration.sh     (wersja 24832)
+++ x10.dist/releng/buildToolIntegration.sh     (kopia robocza)
@@ -48,11 +48,10 @@
    AIX,*,powerpc)
         X10_PLATFORM='aix_ppc'
         numCPUs=2;;
-  Darwin,*,i*86)
-       X10_PLATFORM='macosx_x86'
+  Darwin,Power,Macintosh,powerpc)
+       X10_PLATFORM='macosx_ppc64'
         numCPUs=$(sysctl -n hw.ncpu)
         numCPUs=$(($numCPUs + 1))
-       export USE_32BIT=true
         export USE_64BIT=true;;

    *) echo "Unrecognized platform: '$UNAME'"; exit 1;;
Index: x10.runtime/Make.rules
===================================================================
--- x10.runtime/Make.rules      (wersja 24832)
+++ x10.runtime/Make.rules      (kopia robocza)
@@ -307,21 +307,21 @@
        XARGS ?= /usr/bin/xargs
      else
      ifeq ($(shell uname -s),Darwin)
-      export X10RT_PLATFORM=$(shell echo | gcc -E -dM - | grep -q x86_64 
&& echo darwin64 || echo darwin)
+      export X10RT_PLATFORM=$(shell echo | gcc -E -dM - | grep -q x86_64 
&& echo darwin64 || echo darwin64)
        ifndef X10_STATIC_LIB
          override CXXFLAGS_SHARED += -fPIC
          override LDFLAGS_SHARED += -dynamiclib -undefined dynamic_lookup 
-install_name '@rpath/$@'
        endif
        export X10RT_TEST_LDFLAGS = -Wl,-rpath 
-Wl,"$(X10_HOME)"/x10.runtime/x10rt/lib -Wl,-rpath 
-Wl,"$(X10_HOME)"/x10.runtime/x10rt
        ifdef USE_32BIT
-        override CXXFLAGS += -arch i386
-        override XRX_PROPS_CXXFLAGS += -arch i386
+        override CXXFLAGS += -arch ppc
+        override XRX_PROPS_CXXFLAGS += -arch ppc
        endif
        ifdef USE_64BIT
-        override CXXFLAGS += -arch x86_64
-        override XRX_PROPS_CXXFLAGS += -arch x86_64
+        override CXXFLAGS += -arch ppc64
+        override XRX_PROPS_CXXFLAGS += -arch ppc64
        endif
-      override XRX_PROPS_CXXFLAGS += -msse2 -mfpmath=sse
+      override XRX_PROPS_CXXFLAGS += -maltivec -faltivec
        AR = libtool
        # Warning: Order matters!  The "-o" has to be at the end.
        ARFLAGS = -static -o
Index: x10.runtime/build.xml
===================================================================
--- x10.runtime/build.xml       (wersja 24832)
+++ x10.runtime/build.xml       (kopia robocza)
@@ -103,13 +103,13 @@
      </condition>

      <!-- darwin architectures -->
-    <condition property="darwin.32" value="-arch i386 " else="">
+    <condition property="darwin.32" value="-arch ppc " else="">
          <and>
              <os family="mac"/>
              <istrue value="${env.USE_32BIT}" />
          </and>
      </condition>
-    <condition property="darwin.64" value="-arch x86_64 " else="">
+    <condition property="darwin.64" value="-arch ppc64 " else="">
          <and>
              <os family="mac"/>
              <istrue value="${env.USE_64BIT}" />
@@ -506,7 +506,8 @@
                    <arg value="--disable-dependency-tracking" />
                    <!-- there is no good way to make an @rpath shared gc 
lib -->
                    <arg value="--disable-shared" />
-                  <env key="CFLAGS" 
value="${darwin.32}${darwin.64}-D_XOPEN_SOURCE" />
+                  <env key="CFLAGS" 
value="${darwin.32}${darwin.64}-D_XOPEN_SOURCE -arch ppc -arch ppc64 
-I/opt/openjdk/include/darwin" />
+                  <env key="CXXFLAGS" 
value="${darwin.32}${darwin.64}-D_XOPEN_SOURCE -arch ppc -arch ppc64 
-I/opt/openjdk/include/darwin" />
                    <arg value="--prefix=${bdwgc.platform.dir}/install" />
                  </exec>
                </then>

Unfortunately, it turned out that some parts are not built with 
compilation options hardcoded in that patch above. I had to set 
CFLAGS/CXXFLAGS before running ant. Also, PATH, CLASSPATH, JAVA_HOME and 
JDK_HOME had to be set properly for JDK installed in /opt. Therefore I 
ended with a simple script called x10env-jdk7.sh that I'm executing before 
ant:

#!/bin/sh

PATH=/opt/openjdk/bin:$PATH CFLAGS="-maltivec -faltivec -arch ppc -arch 
ppc64 -I/opt/openjdk/include/darwin" CXXFLAGS="-maltivec -faltivec -arch 
ppc -arch ppc64 -I/opt/openjdk/include/darwin" 
CLASSPATH=/opt/openjdk/jre/lib/rt.jar JAVA_HOME=/opt/openjdk 
JDK_HOME=/opt/openjdk bash

As you can see, it runs bash with some environment variables set. Make it 
executable:

chmod +x x10env-jdk7.sh

Execute:

./x10env-jdk7.sh

And check where is java and java compiler:

bash-3.2$ which java
/opt/openjdk/bin/java
bash-3.2$ which javac
/opt/openjdk/bin/javac

Now we can go to x10.dist direcory and start ant:

ant dist -DNO_CHECKS=true -DX10RT_MPI=true -DUSE_64BIT=true

yeah, mpicc is available on MacOSX, so we can build MPI support too. 
-DUSE_64BIT=true is given in order to make sure that 64-bit compiler will 
be built, probably it can be omitted.

After some time, BUILD SUCCESSFULL should be seen. Compiler is ready. But 
that's not quite the end of the story. If you wish to build shared 
libraries and compile against them, read further about my adventures with 
x10.gl.

One of the nice features of x10 is the provided support for OpenGL. It 
relies on GLUT and GLEW libraries, in later Intel-CPU MacOSX versions GLUT 
is system-provided while GLEW is shipped (with its headers) within CUDA 
toolkit. On MacOSX 10.5.x it must be installed from macports (mesa, 
freeglut and glew ports).

After x10 compiler is built, one can go to x10.gl directory and run:

./build.sh

Headers not found? Libraries not found? They're all provided by macports 
in /opt/local, so we need to change build.sh a bit:
../x10.dist/bin/x10c++ -O -NO_CHECKS -STATIC_CHECKS -buildx10lib . 
src-x10/x10/gl/GL.x10 -o x10_gl -d include -cxx-postarg 
-I/opt/local/include -cxx-postarg -L/opt/local/lib -cxx-postarg -lGL 
-cxx-postarg -lglut -cxx-postarg -lGLEW

See two new cxx-postargs in the middle of line above?:

-cxx-postarg -I/opt/local/include -cxx-postarg -L/opt/local/lib

Unfortunately, on all MacOSX versions (old and new) find command has 
different syntax than on Linux, so .jar file won't be created:
bash-3.2$ ./build.sh
find: illegal option -- p
find: illegal option -- r
find: illegal option -- i
find: illegal option -- n
find: illegal option -- t
find: illegal option -- 0
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal option -- e
find: *.x10: No such file or directory
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal option -- e
find: *.cc: No such file or directory

Fortunately, everything else will be built. At least with x10 version 
2.2.3. Latest SVN snapshot will fail here (I've found the same problem on 
other architectures too!):

x10c++: In file included from ./x10/gl/GL.h:6,
      from x10/gl/GL.cc:3:
      ./x10/gl/GLaux.h:27: error: variable or field 'array_hack' declared 
void
      ./x10/gl/GLaux.h:27: error: 'ref' is not a member of 'x10aux'
      ./x10/gl/GLaux.h:27: error: expected primary-expression before '>' 
token
      ./x10/gl/GLaux.h:27: error: 'arr' was not declared in this scope
      ./x10/gl/GLaux.h:27: error: expected primary-expression before 'void'
      x10/gl/GL.cc: In static member function 'static 
x10::array::Array<x10::lang::String*>* 
x10::gl::GL::glutInit(x10::array::Array<x10::lang::String*>*)':
      x10/gl/GL.cc:152: error: 'ref' is not a member of 'x10aux'
      x10/gl/GL.cc:152: error: 'ref' is not a member of 'x10aux'
      x10/gl/GL.cc:152: error: template argument 1 is invalid
      x10/gl/GL.cc:152: error: expected unqualified-id before '>' token
      x10/gl/GL.cc:153: error: expected initializer before '<' token
      x10/gl/GL.cc:160: error: 'pAS' was not declared in this scope
      x10/gl/GL.cc:160: error: expected `;' before 'new_args'
      x10/gl/GL.cc:161: error: 'new_args' was not declared in this scope
      x10/gl/GL.cc:161: error: 'AS' has not been declared
x10c++: Non-zero return code: 1
2 errors.

So let's stick with x10 version 2.2.3 for a while.

I've examined x10_gl.jar file created on my Linux PC and it turned out 
that it is full of text files, so I copied it to both my Macs (PPC64 and 
x86_64) and used it there. But that's not all of the problems. I've tried 
to build PBO.x10 demo, it compiled fine, but it didn't start. A library 
named @rpath/sharedlib.properties couldn't be found! So here's one 
important change that need to be applied if you wish to deal with x10 
shared libraries on MacOSX. It's in x10.dist/etc/sharedlib.properties in 
the following line:

X10LIB_LDFLAGS_SHARED=-dynamiclib -undefined dynamic_lookup -install_name 
'@rpath/sharedlib.properties'

Whole -install_name part must be gone, so this line will look like this:

X10LIB_LDFLAGS_SHARED=-dynamiclib -undefined dynamic_lookup

Now, go back to x10.gl and remove what was incorrectly built:

./clean.sh

...and build it again:

./build.sh

Now let's build PBO example:

x10c++ -O -NO_CHECKS -STATIC_CHECKS PBO.x10 -o PBO -x10lib 
x10_gl.properties

And now it will run fine! At least on Linux PC and on MacOSX 10.5.x on my 
PowerMac.

I might not mention that already: building x10 on latest MacOSX for 
Intel-based machines is not that painful, should build properly without 
patches above (except one change in x10.dist/etc/sharedlib.properties  the 
same change is required for latest MacOSX too). Unfortunately, PBO example 
won't run due to some weird garbage collection issue resulting in 
segfault:

Program received signal EXC_BAD_ACCESS, Could not access memory.

Reason: KERN_INVALID_ADDRESS at address: 0x0000000100fc3000

[Switching to process 13106]

0x00000001007354e4 in GC_push_all_eager ()

(gdb) bt

#0  0x00000001007354e4 in GC_push_all_eager ()

#1  0x000000010073553d in GC_push_all_stack ()

#2  0x000000010073c13b in GC_push_all_stacks ()

#3  0x0000000100738a53 in GC_default_push_other_roots ()

#4  0x0000000100736c46 in GC_push_roots ()

#5  0x00000001007339f7 in GC_mark_some ()

#6  0x000000010072b605 in GC_stopped_mark ()

#7  0x000000010072b24b in GC_try_to_collect_inner ()

#8  0x0000000100737674 in GC_init_inner ()

#9  0x0000000100732b9e in GC_generic_malloc_many ()

#10 0x000000010073ac4b in GC_malloc ()

#11 0x00000001007257c3 in x10::gl::GL::glutInit ()

#12 0x000000010000426e in PBO::_constructor ()

#13 0x00000001000044ba in PBO::main ()

#14 0x000000010032090a in x10aux::BootStrapClosure::__apply ()

#15 0x0000000100293b2a in x10::lang::Activity::run ()

#16 0x00000001002d2e4b in x10::lang::Runtime__Worker::loop ()

#17 0x00000001002d33a8 in x10::lang::Runtime__Worker::__apply ()

#18 0x00000001002d65cb in x10::lang::Runtime__Pool::__apply ()

#19 0x00000001002d742a in x10::lang::Runtime::start ()

#20 0x0000000100320737 in real_x10_main_inner ()

#21 0x000000010001a2ab in GC_inner_start_routine ()

#22 0x00000001000166dd in GC_call_with_stack_base ()

#23 0x000000010001a2f3 in GC_start_routine ()

#24 0x00007fff86a38fd6 in _pthread_start ()

#25 0x00007fff86a38e89 in thread_start ()

I've tried GLUT from system, GLEW from CUDA toolkit then GLUT/GLEW from 
macports, result always the same.

As I mentioned CUDA already, how it is supported in x10?
Linux PC  only in version 2.2.3, earlier don't compile, later don't work 
(known regression)
MacOSX PPC  no CUDA toolkit for PPC/PPC64 was ever released
MacOSX x86_64  no luck, 2.2.3 builds wrong images, earlier versions don't 
compile (as in Linux) later versions don't work (as in Linux, already 
known regression).

That's all for now,

Best wishes,
Paul


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to