This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug bootstrap/69757] OpenBSD requires -fPIC to build.


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69757

--- Comment #5 from Edd Barrett <edd at theunixzoo dot co.uk> ---
I notice that the previous test *did* append -fPIC (and -DPIC). The failing
test does not show its input or compiler invocation, which makes this hard to
debug.

If you look in the libstdc++ configure script, you can see what happens:


---8<---
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'

...

cat confdefs.h - <<_ACEOF >conftest.$ac_ext                                     
/* end confdefs.h.  */                                                          

int                                                                             
main ()                                                                         
{                                                                               

  ;                                                                             
  return 0;                                                                     
}                                                                               
_ACEOF                                                                          
# FIXME: Cleanup?                                                               
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5        
  (eval $ac_link) 2>&5                                                          
  ac_status=$?                                                                  
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5                  
  test $ac_status = 0; }; then :                                                
  gcc_no_link=no                                                                
else                                                                            
  gcc_no_link=yes                                                               
fi                                                                              
if test x$gcc_no_link = xyes; then                                              
  # Setting cross_compile will disable run tests; it will                       
  # also disable AC_CHECK_FILE but that's generally                             
  # correct if we can't link.                                                   
  cross_compiling=yes                                                           
  EXEEXT=
---8<---

-fPIC is not in CFLAGS, so the test fails with an error like:

/usr/bin/ld: /tmp//ccdT7fwj.o: relocation R_X86_64_32 against `a local symbol'
can not be used when making a shared object; recompile with -fPIC
/tmp//ccdT7fwj.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status

Thus it tricks itself into thinking it is cross compiling.

I think the "no_executables" macros need to emit better debugging information
into config.log. (I would be happy to raise a separate bug for this if you
like).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]