Software Archive
Read-only legacy content
17061 Discussions

Installing cilkplus on Mac Os X Mountain Lion

fca
Beginner
868 Views

Hello,

   I am trying to install cilkplus on Mac Os X Mountain Lion without too much success. First of all I have dowloaded the cilkplus branch from the gcc git repo and then I have configured as follows:

../configure --prefix=/opt/gcc-cilk --enable-languages=c,c++ --disable-multilib

The first hurdle was the presence of an old compatibility flag that I fixed

diff --git a/libcilkrts/runtime/cilk-abi.c b/libcilkrts/runtime/cilk-abi.c
index fb52515..3fde1d8 100644
--- a/libcilkrts/runtime/cilk-abi.c
+++ b/libcilkrts/runtime/cilk-abi.c
@@ -420,7 +420,7 @@ CILK_ABI_WORKER_PTR BIND_THREAD_RTN(void)
*
* For Windows, the aliased symbol is exported in cilk-exports.def.
*/
-#ifdef _DARWIN_C_SOURCE
+#ifdef __APPLE_CC__
/*
* Mac OS X: Unfortunately, Darwin doesn't allow aliasing, so we just make a
* call and hope the optimizer does the right thing.

but this was not enough and the make boostrap dies with

make[2]: Entering directory `/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libcilkrts'
/bin/sh ./libtool --tag=CXX --mode=link /usr/local/cilkplus-gcc/build/./gcc/xg++ -B/usr/local/cilkplus-gcc/build/./gcc/ -nostdinc++ -nostdinc++ -I/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/include/x86_64-apple-darwin12.4.0 -I/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/include -I/usr/local/cilkplus-gcc/libstdc++-v3/libsupc++ -I/usr/local/cilkplus-gcc/libstdc++-v3/include/backward -I/usr/local/cilkplus-gcc/libstdc++-v3/testsuite/util -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src/.libs -B/opt/gcc-cilk/x86_64-apple-darwin12.4.0/bin/ -B/opt/gcc-cilk/x86_64-apple-darwin12.4.0/lib/ -isystem /opt/gcc-cilk/x86_64-apple-darwin12.4.0/include -isystem /opt/gcc-cilk/x86_64-apple-darwin12.4.0/sys-include -g -O2 -rpath '/opt/gcc-cilk/lib' -version-info 5:2546:0 -lpthread -ldl -o libcilkrts.la -rpath /opt/gcc-cilk/lib cilk-abi.lo cilk_api.lo cilk_malloc.lo c_reducers.lo frame_malloc.lo full_frame.lo jmpbuf.lo local_state.lo metacall_impl.lo os_mutex-unix.lo os-unix.lo scheduler.lo signal_node.lo stacks.lo stats.lo sysdep-unix.lo worker_mutex.lo bug.lo cilk-abi-cilk-for.lo except-gcc.lo global_state.lo reducer_impl.lo pedigrees.lo
libtool: link: /usr/local/cilkplus-gcc/build/./gcc/xg++ -B/usr/local/cilkplus-gcc/build/./gcc/ -nostdinc++ -nostdinc++ -I/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/include/x86_64-apple-darwin12.4.0 -I/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/include -I/usr/local/cilkplus-gcc/libstdc++-v3/libsupc++ -I/usr/local/cilkplus-gcc/libstdc++-v3/include/backward -I/usr/local/cilkplus-gcc/libstdc++-v3/testsuite/util -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src/.libs -B/opt/gcc-cilk/x86_64-apple-darwin12.4.0/bin/ -B/opt/gcc-cilk/x86_64-apple-darwin12.4.0/lib/ -isystem /opt/gcc-cilk/x86_64-apple-darwin12.4.0/include -isystem /opt/gcc-cilk/x86_64-apple-darwin12.4.0/sys-include -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libcilkrts.5.dylib .libs/cilk-abi.o .libs/cilk_api.o .libs/cilk_malloc.o .libs/c_reducers.o .libs/frame_malloc.o .libs/full_frame.o .libs/jmpbuf.o .libs/local_state.o .libs/metacall_impl.o .libs/os_mutex-unix.o .libs/os-unix.o .libs/scheduler.o .libs/signal_node.o .libs/stacks.o .libs/stats.o .libs/sysdep-unix.o .libs/worker_mutex.o .libs/bug.o .libs/cilk-abi-cilk-for.o .libs/except-gcc.o .libs/global_state.o .libs/reducer_impl.o .libs/pedigrees.o -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src/.libs -lpthread -ldl -install_name /opt/gcc-cilk/lib/libcilkrts.5.dylib -compatibility_version 6 -current_version 6.2546 -Wl,-single_module
ld: malformed 64-bit a.b.c.d.e version number: 6.2546
collect2: error: ld returned 1 exit status
make[2]: *** [libcilkrts.la] Error 1
make[2]: Leaving directory `/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libcilkrts'
make[1]: *** [all-target-libcilkrts] Error 2
make[1]: Leaving directory `/usr/local/cilkplus-gcc/build'
make: *** [bootstrap] Error 2

That also is not impossible to fix, e.g. running manually the load with appropriate versioning, however the command fails with

ld: in section .itt_notify_tab,"a" reloc 1: X86_64_RELOC_SUBTRACTOR must have r_extern=1 for architecture x86_64

any help would be appreciated.

0 Kudos
14 Replies
Wei_Pan
Beginner
868 Views

This is a FAQ. A workround can be found here

http://sourceforge.net/p/assimp/bugs/112/

0 Kudos
fca
Beginner
868 Views

Thanks a lot. This works, however, as explained in my original post, the make bootstrap dies soon after with 

libtool: link: /usr/local/cilkplus-gcc/build/./gcc/xg++ -B/usr/local/cilkplus-gcc/build/./gcc/ -nostdinc++ -nostdinc++ -I/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/include/x86_64-apple-darwin12.4.0 -I/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/include -I/usr/local/cilkplus-gcc/libstdc++-v3/libsupc++ -I/usr/local/cilkplus-gcc/libstdc++-v3/include/backward -I/usr/local/cilkplus-gcc/libstdc++-v3/testsuite/util -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src/.libs -B/opt/gcc-cilk/x86_64-apple-darwin12.4.0/bin/ -B/opt/gcc-cilk/x86_64-apple-darwin12.4.0/lib/ -isystem /opt/gcc-cilk/x86_64-apple-darwin12.4.0/include -isystem /opt/gcc-cilk/x86_64-apple-darwin12.4.0/sys-include -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libcilkrts.5.dylib .libs/cilk-abi.o .libs/cilk_api.o .libs/cilk_malloc.o .libs/c_reducers.o .libs/frame_malloc.o .libs/full_frame.o .libs/jmpbuf.o .libs/local_state.o .libs/metacall_impl.o .libs/os_mutex-unix.o .libs/os-unix.o .libs/scheduler.o .libs/signal_node.o .libs/stacks.o .libs/stats.o .libs/sysdep-unix.o .libs/worker_mutex.o .libs/bug.o .libs/cilk-abi-cilk-for.o .libs/except-gcc.o .libs/global_state.o .libs/reducer_impl.o .libs/pedigrees.o -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src -L/usr/local/cilkplus-gcc/build/x86_64-apple-darwin12.4.0/libstdc++-v3/src/.libs -lpthread -ldl -install_name /opt/gcc-cilk/lib/libcilkrts.5.dylib -compatibility_version 6 -current_version 6.255 -Wl,-single_module
ld: in section .itt_notify_tab,"a" reloc 1: X86_64_RELOC_SUBTRACTOR must have r_extern=1 for architecture x86_64
collect2: error: ld returned 1 exit status

Best regards, 

0 Kudos
Wei_Pan
Beginner
868 Views

This happened to me too when I tried to build on Mac OSX. The only workround I can think of is to comment out all related functions in "gcc/gcc/cilk.c". 

You may also want to try Cilk Plus implementation in Clang, cilkplus.github.io.

0 Kudos
fca
Beginner
868 Views

Hello,

Thanks for your answer. I am not sure what to comment out in cilk.c, as the error message is obscure to me. It seems to indicate that symbol "a" is not relocatable, but where is symbol "a" defined? I would like someone on this forum to tell me whether cilk in gcc is supposed to work with Mac OS X at all or not. Thanks and best regards, 

Federico

0 Kudos
Balaji_I_Intel
Employee
868 Views

A quick temporary fix for now would be to go edit cilkplus-gcc/gcc/config/i386/i386.c and make the function "ix86_have_cilkscreen_support" return false instead of true.

Here is the change below:

/* Returns true if the backend has cilkscreen support.  */

bool
ix86_have_cilkscreen_support (void)
{
-  return true;

+ return false;
}

 

Thanks,


Balaji V. Iyer.

0 Kudos
Barry_T_Intel
Employee
868 Views

".itt_notify_tab" is the name of the section generated by the compiler to hold the metadata.  However, ".itt_notify_tab" is the name for the section on Linux.

According to the Mach-O spec "sections should be named using all lowercase letters preceded by two underscores (for example, __text). This naming convention is standard, although not required for the tools to operate correctly."  The emphasis is mine.  In our experience, *not* following the convention caused problems like you're seeing.  So we changed the section name for MacOS to "__itt_notify_ta". Note that section names are limited to 16 characters, including the trailing NUL, so it's "__itt_notify_ta" (no "b").

Please try the following:  In gcc/cilk.cpp, modify the call to get_unnamed_section to specify the string "\t.section __itt_notify_ta,\"a\"".  Do not change the string above that's initializing the value of the itt_string variable.  That's the "magic number" that's written as the first value in a table of metadata.

    - Barry

0 Kudos
fca
Beginner
868 Views

Hello Barry,

   thanks a lot. This brought me further. Now the compiler builds, but when I try to link a simple example I get

[/Users/fca/cilk] /opt/gcc-cilk/bin/g++ -fcilkplus -lcilkrts -o fib_test fib_test.cxx
ld: in section .itt_notify_ta,"a" reloc 8: X86_64_RELOC_SUBTRACTOR must have r_extern=1 for architecture x86_64
collect2: error: ld returned 1 exit status

Best, 

0 Kudos
Barry_T_Intel
Employee
868 Views

Something clearly still has a ".itt_notify_ta" section.

Be sure you've changed the name incorrectly.  The name of the section was supposed to change from ".itt_notify_tab" to "__itt_notify_ta". Then rebuild everything.

    - Barry

0 Kudos
fca
Beginner
868 Views

Hello,

 thanks for your message. I have rebuilt everything. This is thre result of my git diff

diff --git a/gcc/cilk.c b/gcc/cilk.c
index 8b561a3..a802852 100644
--- a/gcc/cilk.c
+++ b/gcc/cilk.c
@@ -993,7 +993,7 @@ cilk_output_metadata (void)

/* Create a new zca section (if necessary) and switch to it. */
s = get_unnamed_section (0, output_section_asm_op,
- "\t.section .itt_notify_tab,\"a\"");
+ "\t.section .itt_notify_ta,\"a\"");
switch_to_section (s);
assemble_align (32);

diff --git a/libcilkrts/Makefile.in b/libcilkrts/Makefile.in
index a395044..87c54c3 100644
--- a/libcilkrts/Makefile.in
+++ b/libcilkrts/Makefile.in
@@ -314,6 +314,7 @@ libcilkrts_la_SOURCES = runtime/cilk-abi.c runtime/cilk_api.c \
runtime/global_state.cpp runtime/reducer_impl.cpp runtime/pedigrees.c

CILK_REVISION = 2546
+CILK_REVISION = 255

# Load the $(REVISION) value.
libcilkrts_la_LDFLAGS = -rpath '$(libdir)' -version-info \
diff --git a/libcilkrts/runtime/cilk-abi.c b/libcilkrts/runtime/cilk-abi.c
index fb52515..3fde1d8 100644
--- a/libcilkrts/runtime/cilk-abi.c
+++ b/libcilkrts/runtime/cilk-abi.c
@@ -420,7 +420,7 @@ CILK_ABI_WORKER_PTR BIND_THREAD_RTN(void)
*
* For Windows, the aliased symbol is exported in cilk-exports.def.
*/
-#ifdef _DARWIN_C_SOURCE
+#ifdef __APPLE_CC__
/*
* Mac OS X: Unfortunately, Darwin doesn't allow aliasing, so we just make a
* call and hope the optimizer does the right thing.

0 Kudos
fca
Beginner
868 Views

Sorry,

   I changed only half of the string. I missed the change from dot to uscore-uscore at the beg. However, even doing that, things do not get better

[/Users/fca/cilk] /opt/gcc-cilk/bin/g++ -fcilkplus -lcilkrts -o fib fib.cxx
ld: in section __itt_notify_ta,"a" reloc 8: X86_64_RELOC_SUBTRACTOR must have r_extern=1 for architecture x86_64
collect2: error: ld returned 1 exit status

0 Kudos
Barry_T_Intel
Employee
868 Views

We'll have to chase that down.  In the meantime, Balaji's suggestion to simpy disable the generation of the metadata will probably get you going.

   - Barry

0 Kudos
fca
Beginner
868 Views

Hello,

   thanks again... how do I do that? Best, 

0 Kudos
Balaji_I_Intel
Employee
868 Views

Hello Frederico,

    Have you tried this change that I mentioned a while back?

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c      (revision 200750)
+++ gcc/config/i386/i386.c      (working copy)
@@ -42546,7 +42546,7 @@
 bool
 ix86_have_cilkscreen_support (void)
 {
-  return true;
+  return false;
 }

Thanks,

Balaji V. Iyer.

0 Kudos
fca
Beginner
868 Views

OK,

  this did it, but only with the other mods. Thanks again for the help. I am reposting my git-diff and I would really appreciate if the branch could be updated to be able to do a "clean" pull soemtime in the future. Best, 

0 Kudos
Reply