Issue #7606 has been reported by kernigh (George Koehler).

----------------------------------------
Bug #7606: gcc -pie configure check is broken for OpenBSD/amd64
https://bugs.ruby-lang.org/issues/7606

Author: kernigh (George Koehler)
Status: Open
Priority: Low
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0dev (2012-12-23 trunk 38563) [x86_64-openbsd5.2]


=begin
I can use PIE if I compile with gcc -fPIE and link with gcc -pie.  Ruby's configure script tries to enable PIE, but the check for gcc -pie says "no".  I expected "yes".  My system runs OpenBSD 5.2 for amd64.  My compiler is the default gcc 4.2.1.

The problem is it forgot to use -fPIE when checking -pie.  Here is the relevant part of config.log:

 configure:17900: checking whether -pie is accepted as LDFLAGS
 configure:17922: gcc -o conftest  -O3 -fno-fast-math -ggdb3 -ansi -std=iso9899:199409  -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -I/usr/local/include -L/usr/local/lib -fstack-protector -Wl,-E -pie conftest.c -pthread -lm  >&5
 /usr/bin/ld: /tmp//ccYa9wrA.o: relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
 /tmp//ccYa9wrA.o: could not read symbols: Bad value
 collect2: ld returned 1 exit status

I am attaching a patch (pie-check.diff) to solve this problem. I use -fPIE during the check for gcc -pie. I also add -fPIE to XCFLAGS only when adding -pie (or -Wl,-pie) to XLDFLAGS. With this patch, the check says "yes" and I see -pie in XLDFLAGS.
=end



-- 
http://bugs.ruby-lang.org/