Bug #7606


gcc -pie configure check is broken for OpenBSD/amd64

Added by kernigh (George Koehler) over 9 years ago. Updated over 9 years ago.

Target version:
ruby -v:
ruby 2.0.0dev (2012-12-23 trunk 38563) [x86_64-openbsd5.2]


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.


config.log (789 KB) config.log config.log with failed -pie check kernigh (George Koehler), 12/23/2012 10:48 AM
pie-check.diff (815 Bytes) pie-check.diff git diff, patching kernigh (George Koehler), 12/23/2012 10:48 AM

Updated by kosaki (Motohiro KOSAKI) over 9 years ago

  • Category set to build
  • Status changed from Open to Assigned
  • Assignee set to kosaki (Motohiro KOSAKI)
  • Priority changed from 3 to 5
  • Target version set to 2.0.0

I don't think OpenBSD support is low priority.

Actions #2

Updated by kosaki (Motohiro KOSAKI) over 9 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38619.
George, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

  • enable -fPIE when checking -pie for fixing
    OpenBSD build error. Patch by George Koehler. Thank you!
    [Bug #7606] [ruby-core:51082]

Also available in: Atom PDF