Do not explicitly add "-fPIC" to the compiler command line.
authorOssama Othman <ossama.othman@intel.com>
Mon, 23 Feb 2015 18:45:26 +0000 (10:45 -0800)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Mon, 2 Mar 2015 03:51:45 +0000 (03:51 +0000)
There is no need to explicitly add "-fPIC" to the compiler command
line since the SCons SharedLibary builder will automatically add it.
This change also addresses a problem where position independent code
was unnecessarily and incorrectly generated for static libraries.
IoTivity resource related static libraries are now smaller and code is
more efficient as result of removing "-fPIC" from static library
generation since the indirection that accompanies position independent
code no longer exists (for those static libraries).

Change-Id: I6cf57713d97b62f873ded4f4728fbb5e77e28ca6
Signed-off-by: Ossama Othman <ossama.othman@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/399
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Caiwen Zhang <caiwen.zhang@intel.com>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
resource/csdk/SConscript
resource/csdk/libcoap-4.1.1/SConscript
resource/oc_logger/SConscript
resource/src/SConscript

index cead37e..98af56b 100644 (file)
@@ -40,8 +40,6 @@ liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
 
 if target_os == 'arduino':
        liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
-else:
-       liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
 
 if target_os in ['darwin', 'ios']:
        liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
@@ -73,5 +71,3 @@ else:
        static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
        shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
        liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
-
-
index d10bba0..c7bba15 100644 (file)
@@ -27,7 +27,7 @@ libcoap_env.PrependUnique(CPPPATH = [
 
 if target_os not in ['arduino', 'windows', 'winrt']:
        libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
-       libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99', '-fPIC'])
+       libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99'])
 
 if target_os not in ['windows', 'winrt']:
        libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
index a484ffd..078f725 100644 (file)
@@ -16,8 +16,8 @@ if target_os == 'android':
        liboc_logger_env.AppendUnique(LIBS = ['gnustl_static', 'log'])
 
 if target_os not in ['arduino', 'windows', 'winrt']:
-       liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC'])
-       liboc_logger_env.AppendUnique(CXXFLAGS = ['-Wall', '-fPIC'])
+       liboc_logger_env.AppendUnique(CFLAGS = ['-std=c99'])
+       liboc_logger_env.AppendUnique(CCFLAGS = ['-Wall'])
 
 ######################################################################
 # Source files and Targets
index 9f8a376..8a1803b 100644 (file)
@@ -19,7 +19,7 @@ oclib_env.AppendUnique(CPPPATH = [
 
 target_os = env.get('TARGET_OS')
 if target_os not in ['windows', 'winrt']:
-       oclib_env.AppendUnique(CXXFLAGS = ['-Wall', '-fPIC'])
+       oclib_env.AppendUnique(CXXFLAGS = ['-Wall'])
 
 if target_os == 'android':
        oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])