[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: PGI patches
From: |
Ralf Wildenhues |
Subject: |
FYI: PGI patches |
Date: |
Thu, 7 Apr 2005 19:57:57 +0200 |
User-agent: |
Mutt/1.4.1i |
I have checked in enhanced support for PGI compilers as below, to
Libtool CVS HEAD. Because it adds a `prelink_cmds' interface for
template object compilation to libtool, I regard it as "HEAD only"
for now. Given that it proves stable (useful also for other compilers
would be a goodie), a backport might be ok.
You can employ templates now, but at a cost: you must configure with
CXX='pgCC --one_instantiation_per_object'
(or put it in CXXFLAGS) and you must not use parallel make. This is
mentioned in doc/notes.texi.
Rationale:
1) For projects using templates, but not using them in libraries, I
don't want to force the instantiation mode with Libtool, as that might
break existing setups which use other modes.
2) Parallel make won't work because I cannot choose the name of the
template object directory at link time: The compilations leave
information including the directory name in files named foo.ti, where
foo.o is the object name. The Libtool link step will erase the template
directory in order to avoid objects that don't belong into the output,
but the pgCC link will use the information from foo.ti.
For parallel make (necessitating lib-private template directories) we
would have to modify foo.ti, but that in turn won't work if foo.o would
be linked into two different libraries at the same time (which libtool
cannot know about without outside help).
Notes and open issues:
- This patch is a merger of my "PGI whole-archive patch" and the
original template patch. Non-trivial interaction is that the prelink
step does not interpret the --whole-archive arguments, thus I
added $convenience so no symbols are missing for the prelinker.
- `make clean' ought to remove both template directory and .ti files.
This issue is open, but somewhat orthogonal as creating additional files
is not limited to this compiler.
- Libtool now works with a prerelease of version 6 of the PGI compiler
which uses weak symbols for templates just like g++.
- Open problem with this prerelease on x86_64: tagdemo builds fail with
| /bin/sh ./libtool --tag=CXX --mode=link pgCC -g -no-undefined -o
libfoo.la -rpath /tmp/build-pgi/tests/_inst/lib foo.lo libconv.la -lm
| libtool: link: pgCC -shared .libs/foo.o
-Wl,--whole-archive,,./.libs/libconv.a -Wl,--no-whole-archive -lm
-Wl,-soname -Wl,libfoo.so.0 -o .libs/libfoo.so.0.0.0
| /usr/bin/ld: /tmp/pgi/linux86-64/6.0/lib/libstd.a(ios.o): relocation
R_X86_64_32S against `a local symbol' can not be used when making a shared
object; recompile with -fPIC
| /tmp/pgi/linux86-64/6.0/lib/libstd.a: could not read symbols: Bad value
I believe this is a bug in the PGI 6 prerelease, but I might be wrong here.
Adding
-L/tmp/pgi/linux86-64/6.0/libso
will change the error from above to
| pgCC -shared .libs/foo.o .libs/libfoo.lax/libconv.a/conv.o -lm
-Wl,-soname -Wl,libfoo.so.0 -o .libs/libfoo.so.0.0.0 -L$PGI/linux86-64/6.0/libso
| /usr/bin/ld: .libs/foo.o: relocation R_X86_64_PC32 against
`__vtbl__Q2_3std48basic_ios__tm__31_cQ2_3std20char_traits__tm__2_c' can not be
used when making a shared object; recompile with -fPIC
| /usr/bin/ld: final link failed: Bad value
Setting pic_flag from -fpic to -fPIC does not resolve the matter either
(but might be necessary for other reasons anyway). Suggestions are
welcome here.
By the way, many thanks to Jeff Squyres and to PGI support for access
and help! I will report back for any further improvements.
Regards,
Ralf
Improved Portland support: prelinking of C++ templates and
whole_archive.
* m4/libtool.m4 (_LT_COMPILER_PIC, _LT_LINKER_SHLIBS) [ linux ]:
Reinstate formatted whole_archive_flag_spec for PGI compilers.
* config/ltmain.m4sh (func_mode_link), m4/libtool.m4
(_LT_LINKER_SHLIBS):
New tag prelink_cmds, to be executed before linking a program.
(_LT_LANG_CXX_CONFIG) [ linux ]: Use for pgCC.
(_LT_COMPILER_C_O): conftest might be nonempty, clean up more
thoroughly.
Index: config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.59
diff -u -r1.59 ltmain.m4sh
--- config/ltmain.m4sh 18 Mar 2005 15:57:17 -0000 1.59
+++ config/ltmain.m4sh 7 Apr 2005 17:31:01 -0000
@@ -5563,6 +5563,17 @@
func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+ # template prelinking step
+ if test -n "$prelink_cmds"; then
+ cmds=$prelink_cmds
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ eval cmd=\"$cmd\"
+ IFS="$save_ifs"
+ func_show_eval "$cmd" 'exit $?'
+ done
+ IFS="$save_ifs"
+ fi
wrappers_required=yes
case $host in
Index: m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/libtool.m4,v
retrieving revision 1.179
diff -u -r1.179 libtool.m4
--- m4/libtool.m4 7 Apr 2005 06:29:55 -0000 1.179
+++ m4/libtool.m4 7 Apr 2005 17:31:02 -0000
@@ -1504,7 +1504,7 @@
test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
$RM out/* && rmdir out
cd ..
- rmdir conftest
+ $RM -r conftest
$RM conftest*
])
_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
@@ -3139,7 +3139,6 @@
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
- _LT_TAGVAR(whole_archive_flag_spec, $1)=''
;;
cxx*)
# Compaq C++
@@ -3702,10 +3701,10 @@
tmp_addflag=
case $cc_basename,$host_cpu in
pgcc*) # Portland Group C compiler
- _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ _LT_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'
;;
pgf77* | pgf90* ) # Portland Group f77 and f90 compilers
- _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ _LT_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'
tmp_addflag=' -fpic -Mnomain' ;;
ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
tmp_addflag=' -i_dynamic' ;;
@@ -4501,6 +4500,8 @@
[Symbols that should not be listed in the preloaded symbols])
_LT_TAGDECL([], [include_expsyms], [1],
[Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+ [Commands necessary for linking programs (against libraries) with
templates])
dnl FIXME: Not yet implemented
dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
dnl [Compiler flag to generate thread safe objects])
@@ -5227,12 +5228,35 @@
;;
pgCC*)
# Portland Group C++ compiler
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs
$deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects
$libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname
${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ case `$CC -V` in
+ *pgCC\ [[1-5]]*)
+ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs
$libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o |
$NL2SP`"'
+ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir
$oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name
\*.o | $NL2SP`~
+ $RANLIB $oldlib'
+ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir
$predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $predep_objects $libobjs $deplibs `find $tpldir
-name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname
-o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir
$predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $predep_objects $libobjs $deplibs `find $tpldir
-name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname
${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 will use weak symbols
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects
$libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o
$lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects
$libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname
${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath
${wl}$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ _LT_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'
;;
cxx*)
# Compaq C++
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: PGI patches,
Ralf Wildenhues <=