-fPIC isn't a preprocessor flag, but rather a compiler flag. Regardless of this, I consider it redunant since it affects only libtool calls and m4/libtool.m4 will properly determine the required PIC flag for the platform and compiler and supply it to $pic_flag:
./libtool:pic_flag=" -fPIC -DPIC"
./libtool:archive_cmds="\$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \$wl-soname \$wl\$soname -o \$lib"
./libtool:archive_expsym_cmds="\$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \$wl-soname \$wl\$soname \$wl-retain-symbols-file \$wl\$export_symbols -o \$lib"
./libtool: command="$base_compile $qsrcfile $pic_flag"
./libtool: command="$base_compile $qsrcfile $pic_flag"
./libtool: pic_flag_for_symtable=
./libtool: # compiling the symbol table file with pic_flag works around
./libtool: # pic_flag when linking with -static. The problem exists in
./libtool: pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
./libtool: pic_flag_for_symtable=" $pic_flag" ;;
./libtool: $my_pic_p && pic_flag_for_symtable=" $pic_flag"
./libtool: func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
./libtool: if test -z "$pic_flag" && test -n "$link_static_flag"; then
./libtool: if test -z "$pic_flag" && test -n "$link_static_flag"; then
./libtool: test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
./libtool: if test -n "$pic_flag" || test default != "$pic_mode"; then
I have removed th flag in question on FreeBSD and here is a diff of the make invocation output:
When compiling version 2.1.28 on HP-UX I see the following warnings:
-fPIC
is not valid for HP aCC, one needs to pass another flag (+z
). The source of it is in-fPIC
isn't a preprocessor flag, but rather a compiler flag. Regardless of this, I consider it redunant since it affects only libtool calls andm4/libtool.m4
will properly determine the required PIC flag for the platform and compiler and supply it to$pic_flag
:I have removed th flag in question on FreeBSD and here is a diff of the make invocation output:
As you can see,
-fPIC -DPIC
are still present because generated libtool does contain it.I believe it can be safely removed and improve portability. A PR has been provided.