clang doesn't support -pie option (as of clang 3.3):
clang: error: argument unused during compilation:
'-pie' [-Werror,-Wunused-command-line-argument]
We have to use -Wl,-pie instead.
(ref.
https://bugs.ruby-lang.org/issues/5697)
The new code checks -pie first, and if it fails, checks -Wl,-pie
next. By doing so, we can handle both cases.
The patch is tested on Mac OS X 10.8.5 and Fedora 19.
Signed-off-by: Ryota Ozaki <ozaki.ryota(a)gmail.com>
---
m4/virt-compile-pie.m4 | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/m4/virt-compile-pie.m4 b/m4/virt-compile-pie.m4
index cceb495..11cf0af 100644
--- a/m4/virt-compile-pie.m4
+++ b/m4/virt-compile-pie.m4
@@ -27,7 +27,14 @@ AC_DEFUN([LIBVIRT_COMPILE_PIE],[
*)
gl_COMPILER_OPTION_IF([-fPIE -DPIE], [
PIE_CFLAGS="-fPIE -DPIE"
- PIE_LDFLAGS="-pie"
+ gl_COMPILER_OPTION_IF(["-pie"], [
+ PIE_LDFLAGS="-pie"
+ ], [
+ dnl clang requires -Wl,-pie instead of -pie
+ gl_COMPILER_OPTION_IF(["-Wl,-pie"], [
+ PIE_LDFLAGS="-Wl,-pie"
+ ])
+ ])
])
esac
AC_SUBST([PIE_CFLAGS])
--
1.8.4