From 2533c88e18de689dbb26cfd4d585b1a991533c76 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 21 Jul 2015 22:00:18 +0200 Subject: [PATCH] build: make build fail if unresolved symbols found 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/1802 Tested-by: jenkins-iotivity Reviewed-by: Erich Keane Reviewed-by: Hun-je Yeon Reviewed-by: Uze Choi --- extlibs/expat/SConscript | 3 +++ .../csdk/connectivity/samples/android/SConscript | 1 + resource/csdk/connectivity/src/SConscript | 3 +++ resource/oc_logger/SConscript | 3 +++ resource/src/SConscript | 3 +++ service/notification-manager/SConscript | 3 +++ service/protocol-plugin/plugin-manager/SConscript | 4 ++++ .../plugin-manager/src/Android/jni/SConscript | 1 + service/protocol-plugin/plugins/SConscript | 3 +++ .../plugins/mqtt-fan/lib/cpp/SConscript | 3 +++ .../resource-manipulation/src/common/SConscript | 5 ++++- .../src/resourceContainer/SConscript | 3 +++ .../src/resourceContainer/unittests/SConscript | 3 +++ .../src/serverBuilder/SConscript | 3 +++ service/soft-sensor-manager/SConscript | 3 +++ service/things-manager/SConscript | 3 +++ service/things-manager/sdk/java/jni/SConscript | 3 +++ 17 files changed, 49 insertions(+), 1 deletion(-) --- a/extlibs/expat/SConscript +++ b/extlibs/expat/SConscript @@ -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 ###################################################################### --- a/resource/csdk/connectivity/src/SConscript +++ b/resource/csdk/connectivity/src/SConscript @@ -27,6 +27,9 @@ env.AppendUnique(CPPPATH = [ os.path.joi 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']) --- a/resource/oc_logger/SConscript +++ b/resource/oc_logger/SConscript @@ -42,6 +42,9 @@ if target_os not in ['arduino', 'windows 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 ###################################################################### --- a/resource/src/SConscript +++ b/resource/src/SConscript @@ -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']) --- a/service/notification-manager/SConscript +++ b/service/notification-manager/SConscript @@ -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']) --- a/service/protocol-plugin/plugin-manager/SConscript +++ b/service/protocol-plugin/plugin-manager/SConscript @@ -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') --- a/service/protocol-plugin/plugin-manager/src/Android/jni/SConscript +++ b/service/protocol-plugin/plugin-manager/src/Android/jni/SConscript @@ -23,6 +23,7 @@ ppm_jni_env.PrependUnique(LIBS = ['pmimp 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 --- a/service/protocol-plugin/plugins/SConscript +++ b/service/protocol-plugin/plugins/SConscript @@ -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']) + if target_os not in ['arduino', 'android']: plugins_env.AppendUnique(LIBS = ['pthread']) --- a/service/protocol-plugin/plugins/mqtt-fan/lib/cpp/SConscript +++ b/service/protocol-plugin/plugins/mqtt-fan/lib/cpp/SConscript @@ -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']) --- a/service/resource-encapsulation/src/resourceContainer/SConscript +++ b/service/resource-encapsulation/src/resourceContainer/SConscript @@ -88,6 +88,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']) --- a/service/resource-encapsulation/src/resourceContainer/unittests/SConscript +++ b/service/resource-encapsulation/src/resourceContainer/unittests/SConscript @@ -144,6 +144,9 @@ if int(containerJavaSupport): 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', --- a/service/resource-encapsulation/src/serverBuilder/SConscript +++ b/service/resource-encapsulation/src/serverBuilder/SConscript @@ -54,6 +54,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']) --- a/service/soft-sensor-manager/SConscript +++ b/service/soft-sensor-manager/SConscript @@ -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']) --- a/service/things-manager/SConscript +++ b/service/things-manager/SConscript @@ -43,6 +43,9 @@ if target_os not in ['windows', 'winrt'] things_manager_env.AppendUnique(CXXFLAGS = ['-pthread']) things_manager_env.AppendUnique(LIBS = ['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 = ['gnustl_shared']) --- a/service/things-manager/sdk/java/jni/SConscript +++ b/service/things-manager/sdk/java/jni/SConscript @@ -27,6 +27,9 @@ tm_jni_env.AppendUnique(CPPPATH = [tm_sd 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 ######################################################################