libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for XL C/C++ and Fortran on Linux


From: Roger Ferrer Ibáñez
Subject: Patch for XL C/C++ and Fortran on Linux
Date: Fri, 07 Jul 2006 08:59:44 +0200
User-agent: Thunderbird 1.5.0.2 (X11/20060516)

Hi,

attached to the mail there is a patch against libtool 1.5.22 to make it able to use XL C/C++ and Fortran on Linux.

As I've seen, currently libtool supports these compilers on AIX and Darwin but not on Linux. This results in incorrect flags passed onto the compiler (for instance, "-Wl," is not passed and "-shared" is always assumed to be the "create shared object" flag for Linux compilers). In Linux xlc and xlf use the GNU ld.

I'm not an expert in libtool and most of the work has involved copy-pasting flags from other compilers in Linux. I assume that the patch is nearer to a dirty hack than to a clean solution to be included in the mainstream.

One interesting thing is the fact that xlf by itself is unable to create a shared object but can create PIC objects, so I use LTCC to link a shared object but I don't know how to get the proper "LTCC creation of shared object command" in the script. Now there is a kludgy check. Is using LTCC the correct way or another mechanism must be used?

On the other hand, when using CC=gcc CXX=g++ and F77=xlf, "-fPIC" flag "sticks" on the invocation of xlf (it should be -qpic), what I'm doing wrong in this case?

Comments are welcome.

Thank you.

--
Roger Ferrer Ibáñez - address@hidden
diff -Nurd aclocal.orig/libtool.m4 aclocal/libtool.m4
--- aclocal.orig/libtool.m4     2006-07-06 23:05:08.035633552 +0200
+++ aclocal/libtool.m4  2006-07-07 08:36:25.927231503 +0200
@@ -3353,6 +3353,27 @@
        # dependencies.
        output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v 
conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED 
"s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in 
conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; 
done; echo $list'
        ;;
+    gxlc++*) # IBM XL C for Linux - g++ compatible 
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs 
$deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects 
$libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o 
$lib $wl$export_symbols'
+
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+       _LT_AC_TAGVAR(whole_archive_flag_spec, 
$1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+     ;;
+    xlC* | xlc++*) # IBM XL C++ for Linux
+       with_gnu_ld=yes
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $predep_objects 
$libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o 
$lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -qmkshrobj $predep_objects 
$libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o 
$lib $wl$export_symbols'
+
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+       _LT_AC_TAGVAR(whole_archive_flag_spec, 
$1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+     ;;
     esac
     ;;
   lynxos*)
@@ -4990,6 +5011,16 @@
            _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
            _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
            ;;
+       gxlc++*) # IBM XL for Linux - g++ compatible
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="-fPIC"
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
+        ;;
+       xlC* | xlc++*) # IBM XL C++ for Linux
+          _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+          _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+          _LT_AC_TAGVAR(lt_prog_compiler_static, $1)=''
+           ;;
          *)
            ;;
        esac
@@ -5237,6 +5268,21 @@
         # All Alpha code is PIC.
         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         ;;
+      gxlc*) # IBM XL C for Linux - gcc compatible
+          _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+          _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+          _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      xlc*) # IBM XL C for Linux
+          _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+          _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+          _LT_AC_TAGVAR(lt_prog_compiler_static, $1)=''
+        ;;
+      xlf*) # IBM XL Fortran for Linux
+          _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+          _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+          _LT_AC_TAGVAR(lt_prog_compiler_static, $1)=''
+        ;;
       esac
       ;;
 
@@ -5532,6 +5578,8 @@
     linux*)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
        tmp_addflag=
+    tmp_shared_flag=" -shared "
+    tmp_cc='$CC'
        case $cc_basename,$host_cpu in
        pgcc*)                          # Portland Group C compiler
          _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for 
conv in $convenience\"\"; do test  -n \"$conv\" && 
new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` 
${wl}--no-whole-archive'
@@ -5546,8 +5594,24 @@
          tmp_addflag=' -i_dynamic -nofor_main' ;;
        ifc* | ifort*)                  # Intel Fortran compiler
          tmp_addflag=' -nofor_main' ;;
+    gxlc*)
+      ;;
+    xlc*) # IBM XL C for Linux
+       tmp_shared_flag=" -qmkshrobj "
+       ;;
+    xlf*) # IBM XL Fortran for Linux
+       # This is a kludge, is there any correct way to get the "shared" flag 
for LTCC ?
+       tmp_cc='$LTCC'
+      case $LTCC in
+        xlc*)
+         tmp_shared_flag=" -qmkshrobj "
+         ;;
+        *)
+         ;;
+      esac
+     ;;
        esac
-       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs 
$deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_cmds, 
$1)="$tmp_cc""$tmp_shared_flag""$tmp_addflag"' $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname -o $lib'
 
        if test $supports_anon_versioning = yes; then
          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > 
$output_objdir/$libname.ver~

reply via email to

[Prev in Thread] Current Thread [Next in Thread]