Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 8133742

Browse files
committed
[[ Prebuilt ]] Enable -fPIC option when compiling Linux prebuilt libraries
By building the prebuilt libraries with position-independent code, we enable them to be linked into position-independent executables, which is now the default for executables built with recent versions of GCC (v6 onwards)
1 parent 1b6f636 commit 8133742

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

config/linux-settings.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
'target_conditions':
3131
[
3232
[
33-
'_type == "loadable_module" or _type == "shared_library" or (_type == "static_library" and library_for_module != 0)',
33+
'_type' == "executable" or '_type == "loadable_module" or _type == "shared_library" or (_type == "static_library" and library_for_module != 0)',
3434
{
3535
'cflags':
3636
[

prebuilt/scripts/platform.inc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,17 @@ function setCCForTarget {
114114
else
115115
CC_FLAGS_X86_NORELAX=
116116
fi
117-
echo "*DEBUG* CC_FLAGS: ${CC_FLAGS_X86_NORELAX}"
117+
118+
CC_FLAGS="-fPIC ${CC_FLAGS_X86_NORELAX}"
119+
120+
echo "*DEBUG* CC_FLAGS: ${CC_FLAGS}"
118121

119122
if [ "${ARCH}" == "x86_64" ] ; then
120-
CC="${CC_BASE} -m64 ${CC_FLAGS_X86_NORELAX}"
121-
CXX="${CXX_BASE} -m64 ${CC_FLAGS_X86_NORELAX}"
123+
CC="${CC_BASE} -m64 ${CC_FLAGS}"
124+
CXX="${CXX_BASE} -m64 ${CC_FLAGS}"
122125
elif [ "$1" == "x86" ] ; then
123-
CC="${CC_BASE} -m32 ${CC_FLAGS_X86_NORELAX}"
124-
CXX="${CXX_BASE} -m32 ${CC_FLAGS_X86_NORELAX}"
126+
CC="${CC_BASE} -m32 ${CC_FLAGS}"
127+
CXX="${CXX_BASE} -m32 ${CC_FLAGS}"
125128
fi
126129
;;
127130
android)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PIC
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1
1+
1-PIC
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PIC

0 commit comments

Comments
 (0)