Commit 18520152 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2356] try -Wl,-R first to make it safer for build-time failure

parent 1f2f8e9d
...@@ -12,22 +12,35 @@ dnl fi ...@@ -12,22 +12,35 @@ dnl fi
AC_DEFUN([AX_ISC_RPATH], [ AC_DEFUN([AX_ISC_RPATH], [
# check -R and -Wl,-R rather than gcc specific -rpath to be as portable # We'll tweak both CXXFLAGS and CCFLAGS so this function will work whichever
# as possible. # language is used in the main script. Note also that it's not LDFLAGS;
AC_MSG_CHECKING([whether -R flag is available in linker]) # technically this is a linker flag, but we've noticed $LDFLAGS can be placed
LDFLAGS_SAVED="$LDFLAGS" # where the compiler could interpret it as a compiler option, leading to
LDFLAGS="$LDFLAGS -R/usr/lib" # subtle failure mode. So, in the check below using the compiler flag is
# safer (in the actual Makefiles the flag should be set in LDFLAGS).
CXXFLAGS_SAVED="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wl,-R/usr/lib"
CCFLAGS_SAVED="$CCFLAGS"
CCFLAGS="$CCFLAGS -Wl,-R/usr/lib"
# check -Wl,-R and -R rather than gcc specific -rpath to be as portable
# as possible. -Wl,-R seems to be safer, so we try it first. In some cases
# -R is not actually recognized but AC_TRY_LINK doesn't fail due to that.
AC_MSG_CHECKING([whether -Wl,-R flag is available in linker])
AC_TRY_LINK([],[], AC_TRY_LINK([],[],
[ AC_MSG_RESULT(yes) [ AC_MSG_RESULT(yes)
ISC_RPATH_FLAG=-R ISC_RPATH_FLAG=-Wl,-R
],[ AC_MSG_RESULT(no) ],[ AC_MSG_RESULT(no)
AC_MSG_CHECKING([whether -Wl,-R flag is available in linker]) AC_MSG_CHECKING([whether -R flag is available in linker])
LDFLAGS="$LDFLAGS_SAVED -Wl,-R" CXXFLAGS="$CXXFLAGS_SAVED -R"
CCFLAGS="$CCFLAGS_SAVED -R"
AC_TRY_LINK([], [], AC_TRY_LINK([], [],
[ AC_MSG_RESULT(yes) [ AC_MSG_RESULT([yes; note that -R is more sensitive about the position in option arguments])
ISC_RPATH_FLAG=-Wl,-R ISC_RPATH_FLAG=-R
],[ AC_MSG_RESULT(no) ]) ],[ AC_MSG_RESULT(no) ])
]) ])
LDFLAGS=$LDFLAGS_SAVED
CXXFLAGS=$CXXFLAGS_SAVED
CCFLAGS=$CCFLAGS_SAVED
])dnl AX_ISC_RPATH ])dnl AX_ISC_RPATH
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment