build: make build fail if unresolved symbols found
authorHauke Mehrtens <hauke.mehrtens@lantiq.com>
Tue, 21 Jul 2015 20:00:18 +0000 (22:00 +0200)
committerUze Choi <uzchoi@samsung.com>
Fri, 24 Jul 2015 04:18:06 +0000 (04:18 +0000)
gcc links shared libs also when there are still some unresolved
symbols, you have to specify it explicitly to make it fail in such
cases. I think a compiler should fail in such cases otherwise
someone will add some not intended dependencies or some existing
dependencies are not getting declared.

This patch makes gcc fail in such cases. I have only activated this for
libs build in a Linux build and explicitly deactivates it for windows
(does this even work at all?) This should be build tested with Android
also.

This was build tested for Linux and Android.

This patch depends on some other patches I send which are fixing the
problems I found with this change.

Change-Id: I9ab79896ca2e86e9226cd9b39060a0763ef89694
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1802
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
Reviewed-by: Hun-je Yeon <hunje.yeon@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
17 files changed:
extlibs/expat/SConscript
resource/csdk/connectivity/samples/android/SConscript
resource/csdk/connectivity/src/SConscript
resource/oc_logger/SConscript
resource/src/SConscript
service/notification-manager/SConscript
service/protocol-plugin/plugin-manager/SConscript
service/protocol-plugin/plugin-manager/src/Android/jni/SConscript
service/protocol-plugin/plugins/SConscript
service/protocol-plugin/plugins/mqtt-fan/lib/cpp/SConscript
service/resource-manipulation/src/common/SConscript
service/resource-manipulation/src/resourceContainer/SConscript
service/resource-manipulation/src/resourceContainer/unittests/SConscript
service/resource-manipulation/src/serverBuilder/SConscript
service/soft-sensor-manager/SConscript
service/things-manager/SConscript
service/things-manager/sdk/java/jni/SConscript

index e6b929c..ece6c2f 100644 (file)
@@ -35,6 +35,9 @@ if target_os not in ['windows', 'winrt']:
                        '-fexceptions', '-fno-common'])
        expat_env.AppendUnique(CPPDEFINES = ['HAVE_EXPAT_CONFIG_H'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       expat_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
index 94e8420..c3a3449 100644 (file)
@@ -39,6 +39,7 @@ print " sample src %s" % sample_src
 app_env.AppendUnique(LIBPATH = [app_env.get('BUILD_DIR'), '.',])\r
 app_env.AppendUnique(CPPPATH = ['lib/android'])\r
 app_env.PrependUnique(LIBS = ['connectivity_abstraction'])\r
+app_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
 \r
 \r
 if secured == '1':\r
index 0f64df7..72ffaa8 100755 (executable)
@@ -27,6 +27,9 @@ env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
 if ca_os not in ['arduino', 'windows', 'winrt']:
        env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
 
+if ca_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if ca_os in ['darwin','ios']:
        env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
 
index 98318be..1fc1a85 100644 (file)
@@ -42,6 +42,9 @@ if target_os not in ['arduino', 'windows', 'winrt']:
        liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC'])
        liboc_logger_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x', '-fPIC'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       liboc_logger_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
index 3a7dd85..28118f1 100644 (file)
@@ -51,6 +51,9 @@ if target_os == 'linux':
 if target_os not in ['windows', 'winrt']:
        oclib_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-fPIC'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       oclib_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'android':
        oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
        oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
index e6c08ff..0949530 100644 (file)
@@ -65,6 +65,9 @@ notimgr_env.PrependUnique(LIBS = [
 if target_os not in ['windows', 'winrt']:
        notimgr_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       notimgr_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'linux':
        notimgr_env.AppendUnique(LIBS = ['pthread'])
 
index 25edfce..9fc55cc 100644 (file)
@@ -61,6 +61,10 @@ if target_os == 'android':
 pmimpl_env = plugin_manager_env.Clone()
 pmimpl_env.PrependUnique(CCFLAGS = ['-fPIC'])
 pmimpl_env.PrependUnique(LIBS = File(env.get('BUILD_DIR') + '/libcpluff.a'))
+
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       pmimpl_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 pmimpl = pmimpl_env.SharedLibrary('pmimpl', pmimpl_src)
 
 plugin_manager_env.InstallTarget([ppm, pmimpl], 'libppm')
index 9b54f72..bc79726 100644 (file)
@@ -23,6 +23,7 @@ ppm_jni_env.PrependUnique(LIBS = ['pmimpl', 'ppm', 'expat', 'cpluff', 'gnustl_sh
 ppm_jni_env.AppendUnique(CPPPATH = [ppm_sdk+'/src'])
 ppm_jni_env.AppendUnique(CPPPATH = [ppm_sdk+'/../lib/cpluff/libcpluff'])
 ppm_jni_env.AppendUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs/rapidxml'])
+ppm_jni_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
 
 ######################################################################
 # Source files and Targets
index b8dce84..7d262c2 100644 (file)
@@ -40,6 +40,9 @@ if target_os not in ['windows', 'winrt']:
     plugins_env.PrependUnique(CCFLAGS = ['-fPIC'])
     plugins_env.AppendUnique(LINKFLAGS = ['-fPIC'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+    plugins_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 #plugins_env.AppendUnique(LIBS=['libconnectivity-abstraction'])
 
     if target_os not in ['arduino', 'android']:
index 15c7e62..ecf4102 100644 (file)
@@ -16,6 +16,9 @@ mosquittopp_env.AppendUnique(CPPPATH = ['./', '../'])
 if target_os not in ['windows', 'winrt']:
        mosquittopp_env.AppendUnique(CFLAGS = ['-Wall', '-ggdb', '-O2', '-fPIC'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       mosquittopp_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'linux':
        mosquittopp_env.AppendUnique(LIBS = ['pthread'])
 
index 4799686..2b76c5c 100644 (file)
@@ -54,6 +54,9 @@ if target_os not in ['windows', 'winrt']:
     if target_os != 'android':\r
         rcs_common_env.AppendUnique(CXXFLAGS = ['-pthread'])\r
 \r
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+    rcs_common_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'android':\r
     rcs_common_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])\r
     rcs_common_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])\r
@@ -115,4 +118,4 @@ rcs_common_test_src = env.Glob('primitiveResource/unittests/*.cpp')
 \r
 rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src)\r
 Alias("rcs_common_test", rcs_common_test)\r
-env.AppendTarget('rcs_common_test')
\ No newline at end of file
+env.AppendTarget('rcs_common_test')
index 89fb477..a875802 100644 (file)
@@ -85,6 +85,9 @@ if target_os not in ['windows', 'winrt']:
     if target_os != 'android':
         resource_container_env.AppendUnique(CXXFLAGS = ['-pthread'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+    resource_container_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'android':
     resource_container_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
     resource_container_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
index e3e7306..5d000f9 100644 (file)
@@ -138,6 +138,9 @@ except KeyError:
 test_bundle_env = container_gtest_env.Clone()
 test_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+    test_bundle_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 TEST_BUNDLE_DIR = 'TestBundle/'
 test_bundle_env.AppendUnique(CPPPATH = [
                TEST_BUNDLE_DIR + 'include',
index e7acde0..d152287 100644 (file)
@@ -52,6 +52,9 @@ if target_os not in ['windows', 'winrt']:
     if target_os != 'android':
         server_builder_env.AppendUnique(CXXFLAGS = ['-pthread'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+    server_builder_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'android':
     server_builder_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
     server_builder_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
index fe54d61..dd01845 100644 (file)
@@ -45,6 +45,9 @@ if target_os not in ['windows', 'winrt']:
                soft_sensor_manager_env.AppendUnique(LIBS = ['pthread'])
                soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-pthread'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+       soft_sensor_manager_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'android':
        soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
        soft_sensor_manager_env.AppendUnique(LIBS = ['gnustl_shared'])
index 73fd6ee..0ae8a81 100644 (file)
@@ -40,6 +40,9 @@ if target_os not in ['windows', 'winrt']:
     if target_os != 'android':
         things_manager_env.AppendUnique(CXXFLAGS = ['-pthread'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+    things_manager_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 if target_os == 'android':
     things_manager_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
     things_manager_env.PrependUnique(LIBS = ['oc', 'octbstack', 'gnustl_shared'])
index 2c1219b..aca5e37 100644 (file)
@@ -27,6 +27,9 @@ tm_jni_env.AppendUnique(CPPPATH = [tm_sdk+'/inc'])
 tm_jni_env.AppendUnique(CPPPATH = [base_jni])
 tm_jni_env.AppendUnique(CPPPATH = ['tm/inc', 'jniutil/inc', extlibs+'/timer/'])
 
+if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
+    tm_jni_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################