Enable position independent code by default
Add a build option (--disable-pic, wxBUILD_PIC=OFF) to disable it. Note that it is always enabled for shared libraries and static third party libraries.
This commit is contained in:
parent
3328480f78
commit
4ee04daa7c
@ -83,6 +83,10 @@ function(wx_set_common_target_properties target_name)
|
||||
RUNTIME_OUTPUT_DIRECTORY "${wxOUTPUT_DIR}${wxPLATFORM_LIB_DIR}"
|
||||
)
|
||||
|
||||
if(wxBUILD_PIC)
|
||||
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(wxCOMMON_TARGET_PROPS_DEFAULT_WARNINGS)
|
||||
set(MSVC_WARNING_LEVEL "/W3")
|
||||
@ -498,6 +502,10 @@ function(wx_set_builtin_target_properties target_name)
|
||||
|
||||
set_target_properties(${target_name} PROPERTIES FOLDER "Third Party Libraries")
|
||||
|
||||
if(wxBUILD_SHARED OR wxBUILD_PIC)
|
||||
set_target_properties(${target_name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
endif()
|
||||
|
||||
wx_set_common_target_properties(${target_name} DEFAULT_WARNINGS)
|
||||
if(NOT wxBUILD_SHARED)
|
||||
wx_install(TARGETS ${name} ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}")
|
||||
@ -518,9 +526,6 @@ function(wx_add_builtin_library name)
|
||||
add_library(wx::${name_short} ALIAS ${name})
|
||||
wx_set_builtin_target_properties(${name})
|
||||
set_target_properties(${name} PROPERTIES PROJECT_LABEL ${name_short})
|
||||
if(wxBUILD_SHARED)
|
||||
set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# List of third party libraries added via wx_add_thirdparty_library()
|
||||
|
@ -64,6 +64,8 @@ else()
|
||||
endif()
|
||||
wx_option(wxBUILD_STRIPPED_RELEASE "remove debug symbols in release build" ${wxBUILD_STRIPPED_RELEASE_DEFAULT})
|
||||
mark_as_advanced(wxBUILD_STRIPPED_RELEASE)
|
||||
wx_option(wxBUILD_PIC "Enable position independent code (PIC)." ON)
|
||||
mark_as_advanced(wxBUILD_PIC)
|
||||
wx_option(wxUSE_NO_RTTI "disable RTTI support" OFF)
|
||||
|
||||
# STL options
|
||||
|
51
configure
vendored
51
configure
vendored
@ -634,6 +634,7 @@ WX_VERSION_TAG
|
||||
DMALLOC_LIBS
|
||||
OPENGL_LIBS
|
||||
LDFLAGS_GL
|
||||
SAMPLES_CXXFLAGS
|
||||
SAMPLES_SUBDIRS
|
||||
DISTDIR
|
||||
GUIDIST
|
||||
@ -889,7 +890,6 @@ RANLIB
|
||||
USE_DPI_AWARE_MANIFEST
|
||||
HOST_SUFFIX
|
||||
HEADER_PAD_OPTION
|
||||
SAMPLES_CXXFLAGS
|
||||
SAMPLES_RPATH_FLAG
|
||||
DYLIB_RPATH_POSTLINK
|
||||
DYLIB_RPATH_INSTALL
|
||||
@ -1123,6 +1123,7 @@ enable_utf8only
|
||||
enable_extended_rtti
|
||||
enable_optimise
|
||||
enable_profile
|
||||
enable_pic
|
||||
enable_no_rtti
|
||||
enable_no_exceptions
|
||||
enable_permissive
|
||||
@ -2079,6 +2080,7 @@ Optional Features:
|
||||
--enable-extended_rtti use extended RTTI (XTI)
|
||||
--disable-optimise compile without optimisations
|
||||
--enable-profile create code with profiling information
|
||||
--disable-pic don't use position independent code when building static libraries (shared libraries always use PIC)
|
||||
--enable-no_rtti create code without RTTI information
|
||||
--enable-no_exceptions create code without C++ exceptions handling
|
||||
--enable-permissive compile code disregarding strict ANSI
|
||||
@ -5939,6 +5941,35 @@ fi
|
||||
eval "$wx_cv_use_profile"
|
||||
|
||||
|
||||
enablestring=disable
|
||||
defaultval=
|
||||
if test -z "$defaultval"; then
|
||||
if test x"$enablestring" = xdisable; then
|
||||
defaultval=yes
|
||||
else
|
||||
defaultval=no
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check whether --enable-pic was given.
|
||||
if test "${enable_pic+set}" = set; then :
|
||||
enableval=$enable_pic;
|
||||
if test "$enableval" = yes; then
|
||||
wx_cv_use_pic='wxUSE_PIC=yes'
|
||||
else
|
||||
wx_cv_use_pic='wxUSE_PIC=no'
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
wx_cv_use_pic='wxUSE_PIC=${'DEFAULT_wxUSE_PIC":-$defaultval}"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
eval "$wx_cv_use_pic"
|
||||
|
||||
|
||||
enablestring=
|
||||
defaultval=
|
||||
if test -z "$defaultval"; then
|
||||
@ -26276,8 +26307,7 @@ $as_echo "yes" >&6; }
|
||||
TOOLKIT_INCLUDE="${TOOLKIT_INCLUDE} ${QT5_CFLAGS}"
|
||||
GUI_TK_LIBRARY="${GUI_TK_LIBRARY} ${QT5_LIBS}"
|
||||
if `pkg-config --variable qt_config Qt5Core | grep "reduce_relocations" >/dev/null`; then
|
||||
SAMPLES_CXXFLAGS="-fPIC $SAMPLES_CXXFLAGS"
|
||||
WXCONFIG_CXXFLAGS="-fPIC $WXCONFIG_CXXFLAGS"
|
||||
wxUSE_PIC=yes
|
||||
fi
|
||||
|
||||
fi
|
||||
@ -33152,6 +33182,11 @@ $as_echo "$as_me: WARNING: plugins require wxDynamicLibrary, disabling" >&2;}
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$wxUSE_PIC" = "no" -a "$wxUSE_SHARED" = "yes"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: position independent code (PIC) can not be disabled for shared libraries" >&5
|
||||
$as_echo "$as_me: WARNING: position independent code (PIC) can not be disabled for shared libraries" >&2;}
|
||||
fi
|
||||
|
||||
|
||||
if test "$wxUSE_FSWATCHER" = "yes"; then
|
||||
if test "$USE_WIN32" != 1; then
|
||||
@ -38157,7 +38192,6 @@ TOOLKIT_LOWERCASE=`echo $TOOLKIT | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
|
||||
|
||||
|
||||
case "$TOOLKIT" in
|
||||
GTK)
|
||||
TOOLKIT_DESC="GTK+"
|
||||
@ -40592,6 +40626,14 @@ then
|
||||
#OBJCXXFLAGS="-DWX_PRECOMP $CXXFLAGS"
|
||||
fi
|
||||
|
||||
if test "$wxUSE_PIC" = "yes" ; then
|
||||
if test "$wxUSE_SHARED" = "no" ; then
|
||||
CFLAGS="$CFLAGS $PIC_FLAG"
|
||||
CXXFLAGS="$CXXFLAGS $PIC_FLAG"
|
||||
fi
|
||||
SAMPLES_CXXFLAGS="$SAMPLES_CXXFLAGS $PIC_FLAG"
|
||||
fi
|
||||
|
||||
|
||||
if test "$DEPS_TRACKING" = 1 -a "$wxUSE_MAC" = 1 ; then
|
||||
if test "x$wxUSE_UNIVERSAL_BINARY" != "xno" ; then
|
||||
@ -40690,6 +40732,7 @@ SAMPLES_SUBDIRS="`echo $SAMPLES_SUBDIRS | tr -s ' ' | tr ' ' '\n' | sort | uniq
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
|
||||
|
19
configure.in
19
configure.in
@ -678,6 +678,7 @@ WX_ARG_ENABLE(extended_rtti, [ --enable-extended_rtti use extended RTTI (XTI)]
|
||||
WX_ARG_DISABLE(optimise, [ --disable-optimise compile without optimisations], wxUSE_OPTIMISE)
|
||||
|
||||
WX_ARG_ENABLE(profile, [ --enable-profile create code with profiling information], wxUSE_PROFILE)
|
||||
WX_ARG_DISABLE(pic, [ --disable-pic don't use position independent code when building static libraries (shared libraries always use PIC)], wxUSE_PIC)
|
||||
WX_ARG_ENABLE(no_rtti, [ --enable-no_rtti create code without RTTI information], wxUSE_NO_RTTI)
|
||||
WX_ARG_ENABLE(no_exceptions, [ --enable-no_exceptions create code without C++ exceptions handling], wxUSE_NO_EXCEPTIONS)
|
||||
WX_ARG_ENABLE(permissive, [ --enable-permissive compile code disregarding strict ANSI], wxUSE_PERMISSIVE)
|
||||
@ -3610,8 +3611,7 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
|
||||
GUI_TK_LIBRARY="${GUI_TK_LIBRARY} ${QT5_LIBS}"
|
||||
if `pkg-config --variable qt_config Qt5Core | grep "reduce_relocations" >/dev/null`; then
|
||||
dnl build with position independent code if Qt needs it
|
||||
SAMPLES_CXXFLAGS="-fPIC $SAMPLES_CXXFLAGS"
|
||||
WXCONFIG_CXXFLAGS="-fPIC $WXCONFIG_CXXFLAGS"
|
||||
wxUSE_PIC=yes
|
||||
fi
|
||||
],
|
||||
[
|
||||
@ -5586,6 +5586,10 @@ if test "$wxUSE_PLUGINS" = "yes" ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$wxUSE_PIC" = "no" -a "$wxUSE_SHARED" = "yes"; then
|
||||
AC_MSG_WARN([position independent code (PIC) can not be disabled for shared libraries])
|
||||
fi
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl File system watcher checks
|
||||
dnl ---------------------------------------------------------------------------
|
||||
@ -8269,7 +8273,6 @@ AC_SUBST(TOOLKIT_VERSION)
|
||||
AC_SUBST(DYLIB_RPATH_INSTALL)
|
||||
AC_SUBST(DYLIB_RPATH_POSTLINK)
|
||||
AC_SUBST(SAMPLES_RPATH_FLAG)
|
||||
AC_SUBST(SAMPLES_CXXFLAGS)
|
||||
AC_SUBST(HEADER_PAD_OPTION)
|
||||
AC_SUBST(HOST_SUFFIX)
|
||||
AC_SUBST(USE_DPI_AWARE_MANIFEST)
|
||||
@ -8359,6 +8362,15 @@ then
|
||||
#OBJCXXFLAGS="-DWX_PRECOMP $CXXFLAGS"
|
||||
fi
|
||||
|
||||
dnl cc/cxx option for position independent code
|
||||
if test "$wxUSE_PIC" = "yes" ; then
|
||||
if test "$wxUSE_SHARED" = "no" ; then
|
||||
CFLAGS="$CFLAGS $PIC_FLAG"
|
||||
CXXFLAGS="$CXXFLAGS $PIC_FLAG"
|
||||
fi
|
||||
SAMPLES_CXXFLAGS="$SAMPLES_CXXFLAGS $PIC_FLAG"
|
||||
fi
|
||||
|
||||
dnl HACK ALERT!!
|
||||
dnl For now, we need to alter bk-deps not to generate deps
|
||||
dnl when we've configured a Universal binary build.
|
||||
@ -8501,6 +8513,7 @@ AC_SUBST(DISTDIR)
|
||||
|
||||
dnl additional subdirectories where we will build
|
||||
AC_SUBST(SAMPLES_SUBDIRS)
|
||||
AC_SUBST(SAMPLES_CXXFLAGS)
|
||||
|
||||
dnl additional libraries and linker settings
|
||||
AC_SUBST(LDFLAGS_GL)
|
||||
|
Loading…
Reference in New Issue
Block a user