[GHC] #12755: Build from source fails on Ubuntu 16.10: ld: -r and -pie may not be used together
GHC
ghc-devs at haskell.org
Sun Oct 23 13:56:27 UTC 2016
#12755: Build from source fails on Ubuntu 16.10: ld: -r and -pie may not be used
together
-------------------------------------+-------------------------------------
Reporter: SamuelMarks | Owner:
Type: bug | Status: new
Priority: high | Milestone:
Component: Build System | Version: 8.0.1
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: Building GHC | (amd64)
failed | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by SamuelMarks):
Thanks for those arguments, the build is currently running (no errors yet
=]).
Automated solutions to this problem include `grep` of:
{{{
gcc -dumpspecs
}}}
Or a `readelf` like from [http://www.trapkit.de/tools/checksec.html
checksec.sh]:
{{{
#!bash
if readelf -h $1 2>/dev/null | grep -q 'Type:[[:space:]]*EXEC'; then
echo -n -e '\033[31mNo PIE \033[m '
elif readelf -h $1 2>/dev/null | grep -q 'Type:[[:space:]]*DYN'; then
if readelf -d $1 2>/dev/null | grep -q '(DEBUG)'; then
echo -n -e '\033[32mPIE enabled \033[m '
else
echo -n -e '\033[33mDSO \033[m '
fi
else
echo -n -e '\033[33mNot an ELF file\033[m '
fi
}}}
Alternatively in C++ take a look at this [http://lists.llvm.org/pipermail
/cfe-commits/Week-of-Mon-20130408/077610.html LLVM patch implementation]
of `isPIEDefault`.
[https://wiki.dlang.org/LDC ldc] uses `llvm::Reloc::PIC_` to check, see:
[https://github.com/ximion/ldc/blob/d9496882163e173ea718756a7fb0cbc627c5326f/driver/targetmachine.cpp#L521
ldc/driver/targetmachine.cpp#L521]. In particular see `Reloc::Model
TargetMachine::getRelocationModel() const` in LLVM's
[http://llvm.org/docs/doxygen/html/classllvm_1_1TargetMachine.html#a87f1815c4b56735aaadbbcdfdf32cf4f
TargetMachine.cpp].
Additionally there's this `gcc` patch [http://gcc.gnu.org/ml/gcc-
patches/2016-07/msg01257.html check -nopie in configure].
The compile-and-see approach you mentioned is used in various places also,
e.g.: `gccSupportsFlag` function under [https://github.com/gcc-
mirror/gcc/blob/be239ed2ba619747b64629895116f209b58baee8/libgo/go/cmd/go/build.go#L3082
gcc/libgo/go/cmd/go/build.go#L3082].
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12755#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list