9 Replies Latest reply on Aug 9, 2012 6:19 AM by santosh.zanjurne

    Compile R with Open64 4.5.1 failed with -fPIC related error

    klin938

      Hi guys,

       

      I am trying to compile R 2.15.1 with Open64 4.5.1 and ACMP 5.1.9 (open64_64_fma4_mp).

       

      The configure went without an error but when I compiled it, it failed when linking objects for libR.so:

       

      /usr/bin/ld: eval.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
      eval.o: could not read symbols: Bad value
      collect2: ld returned 1 exit status
      

       

      So I saw the -fPIC indeed wasn't there, so I modified the Makeconf to include -fPIC, but it still failed with the same error. I also tried -fpic install, no help.

       

      I am using CentOS 6.2 x86_64.

       

      Regards,

      Derrick

        • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
          santosh.zanjurne

          Hello Derrick,

          Sorry for coming late on this but I am still in the process of reproducing this issue.  Will get back soon.

           

          Regards,

          Santosh

            • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
              klin938

              Thanks Santosh,

               

              This is how I config the R:

              ./configure --prefix=/share/ClusterShare/software/centos6/R-2.15.1-open64-4.5.1 --enable-R-shlib --enable-BLAS-shlib  --with-blas="-L/share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib -lacml_mp" --with-lapack

              Hope hear from you soon.

               

              Derrick

                • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
                  santosh.zanjurne

                  Hello Derrick,

                  This turned out to be a known issue of 'goto'.  Computed goto's are not supported by Open64 as yet and is an open issue in  our bug database.

                   

                  This gcc extension is guarded in NO_THREADED_CODE macro.  Defining -DNO_THREADED_CODE in CFLAGS/CXXFLAGS is a work around to this problem.  Let me know if you face any other issues in the build.

                   

                  Regards,

                  Santosh

                    • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
                      klin938

                      Hi Santosh,

                       

                      Your work around did the trick. The error no longer happen.

                       

                      After the compilation, I checked the compiled share R lib such as libR.so, libRlapack.so with ldd, I found:

                       

                      libacml_mv.so => /share/ClusterShare/software/centos6/x86_open64-4.5.1//lib/gcc-lib/x86_64-open64-linux/4.5.1/libacml_mv.so (0x00007f63279b8000)
                      libmv.so.1 => /share/ClusterShare/software/centos6/x86_open64-4.5.1//lib/gcc-lib/x86_64-open64-linux/4.5.1/libmv.so.1 (0x00007f63277a8000)
                      

                       

                      So it seems that the ACML lib bundled inside Open64 was used, despite the fact that I have specified the PATH_TO_ACML in the configure command:

                       

                      --with-blas="-L/share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib -lacml_mp"
                      

                       

                      My LD_LIBRARY_PATH looks like (acml one comes first):

                       

                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib:/share/ClusterShare/software/centos6/x86_open64-4.5.1/lib/gcc-lib/x86_64-open64-linux/4.5.1:/opt/gridengine/lib/lx26-amd64:/opt/openmpi/lib
                      

                       

                      So is it the expected behaviour?

                       

                      Cheers,

                      Derrick

                        • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
                          santosh.zanjurne

                          You will need to specifiy the ACML settings in LDFLAGS.  You will also need to give other dependant library names to avoid  error when LDFLAGS are used by non-fortran compiler.  Folloing settings worked for me.

                           

                          export LDFLAGS="-L/home/santosh/apps/R/acml-bin/open64_64_fma4_mp/lib -lacml_mp -lfortran -lffio -lopenmp -mp  -lacml_mv"

                           

                          Linking to libacml_mv.so is normal for compiler. Yours in libacml.so or libacml_mp.so. In case of libacml_mp.so specify -mp flag also.

                            • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
                              santosh.zanjurne

                              Hi Derrick,

                              Did this help you? 

                               

                              Regards,

                              Santosh

                                • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
                                  klin938

                                  Hi Santosh,

                                   

                                  I gave it another try, used the LDFLAGS you provided, the compilation failed:

                                   

                                  opencc -std=gnu99 -shared -L/share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib -lacml_mp -lfortran -lffio -lopenmp -mp -lacml_mv -o cairo.so cairoBM.o ../../../../../src/modules/X11/rbitmap.o -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lpng12 -lz -lcairo   -ltiff -ljpeg -lpng -lz -L../../../../../lib -lR -lm
                                  make[9]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices/src/cairo'
                                  make[8]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices/src/cairo'
                                  make[7]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices/src/cairo'
                                  make[6]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices/src'
                                  make[5]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices/src'
                                  make[4]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices'
                                  make[4]: Entering directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices'
                                  byte-compiling package 'grDevices'
                                  Warning in solve.default(rgb) :
                                    unable to load shared object '/home/pwbcad/workspace/R-2.15.1/modules//lapack.so':
                                    /home/pwbcad/workspace/R-2.15.1/lib/libRlapack.so: undefined symbol: _gfortran_concat_string
                                  Error in solve.default(rgb) : lapack routines cannot be loaded
                                  Error: unable to load R code in package 'grDevices'
                                  Execution halted
                                  make[4]: *** [../../../library/grDevices/R/grDevices.rdb] Error 1
                                  make[4]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices'
                                  make[3]: *** [all] Error 2
                                  make[3]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library/grDevices'
                                  make[2]: *** [R] Error 1
                                  make[2]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src/library'
                                  make[1]: *** [R] Error 1
                                  make[1]: Leaving directory `/home/pwbcad/workspace/R-2.15.1/src'
                                  make: *** [R] Error 1
                                  
                                  

                                   

                                  Thanks for helping me alone the way!

                                  Derrick

                                    • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
                                      klin938

                                      Actually, I think the R failed to pick up the ACML 5.1.0 I specified at all. In the Makeconf, I found:

                                       

                                      BLAS_LIBS = -L$(R_HOME)/lib$(R_ARCH) -lRblas
                                      

                                       

                                      I expected something like:

                                       

                                      BLAS_LIBS = -L/usr/local/lib64 conftest.c -L/share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib -lacml_mp
                                      

                                       

                                      In the config.log I found it failed the test built and guess that's why R decided to use the default BLAS instead of ACML.

                                       

                                      configure:28957: checking for dgemm_ in -L/share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib -lacml_mp
                                      configure:28978: opencc -std=gnu99 -o conftest -g -march=bdver1 -O3 -DNO_THREADED_CODE -fpic  -I/usr/local/include  -L/usr/local/lib64 conftest.c -L/share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib -lacml_mp  -L/usr/lib$
                                      conftest.c: In function 'main':
                                      conftest.c:205: warning: implicit declaration of function 'dgemm_'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_end_critical'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_static_init_4'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_critical'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_serialized_parallel'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_get_local_thread_num'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `_TRANSFER'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_end_serialized_parallel'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `_index90'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_fork'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `_F90_STOP'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `_FRF'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `s_cmp'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `s_copy'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_can_fork'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `s_cat'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__powri'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `_FWF'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `_DEALLOC'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__ompc_barrier'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__powii'
                                      /share/ClusterShare/software/noarch/acml5.1.0/open64_64_fma4_mp/lib/libacml_mp.so: undefined reference to `__powdi'
                                      collect2: ld returned 1 exit status
                                      configure:28978: $? = 1
                                      configure: failed program was:
                                      
                                      

                                       

                                      Sorry for the troublesome, but can you provide more about how you were able to build with ACML?

                                       

                                      Regards,

                                      Derrick

                                        • Re: Compile R with Open64 4.5.1 failed with -fPIC related error
                                          santosh.zanjurne

                                          Hi Derrick,

                                          I used following setup to build this suite:

                                           

                                           export PATH=/home/santosh/Compiler/open64/binaries/bin/:$PATH
                                           export LD_LIBRARY_PATH=/home/santosh/apps/acml/ACML/BUILD_open64_mp_fma4_64/lib
                                           export CC=opencc CXX=openCC FC=openf90  F77=openf90 CFLAGS="-O3 -DHELLO -mp -fPIC  -DNO_THREADED_CODE" CXXFLAGS="$CFLAGS" FFLAGS="$CFLAGS"  export FCFLAGS="$CFLAGS -fno-second-underscore" export F77FLAGS="$CFLAGS -fno-second-underscore"
                                           export SHLIB_LDFLAGS="-shared -L/home/santosh/apps/acml/ACML/BUILD_open64_mp_fma4_64/lib -lacml_mp -mp"
                                           export SHLIB_LD="openf90"
                                           ./configure --enable-R-shlib --with-blas="-L/home/santosh/apps/acml/ACML/BUILD_open64_mp_fma4_64/lib  -lacml_mp" --with-lapack="-L/home/santosh/apps/acml/ACML/BUILD_open64_mp_fma4_64/lib -lacml_mp" --with-libpth-prefix=/home/santosh/apps/acml/ACML/BUILD_open64_mp_fma4_64/  --prefix=/home/santosh/apps/R/R-2.8.1-bin >&clog; make all >& blog
                                          
                                            After configuring delete" -lopen64rt" from Makeconf, etc/Makeconf, before executing make cmd.
                                          
                                          

                                           

                                           

                                          Let me know if this helps you.

                                           

                                          regards.

                                          Santosh