From 42d9bdd5e2c5bcc48b13f6dfc5f398a084f0d1f1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mouret Date: Thu, 31 Mar 2022 15:20:30 +0200 Subject: [PATCH 1/4] minor improvements to wscript (-fPIC) and dart.py --- src/robot_dart/utils.hpp | 2 +- waf_tools/dart.py | 2 +- wscript | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/robot_dart/utils.hpp b/src/robot_dart/utils.hpp index 7e92643c..2cc106e9 100644 --- a/src/robot_dart/utils.hpp +++ b/src/robot_dart/utils.hpp @@ -51,7 +51,7 @@ namespace robot_dart { #define ROBOT_DART_ASSERT(condition, message, returnValue) \ do { \ if (!(condition)) { \ - std::cerr << "robot_dart assertion failed: " << message << std::endl; \ + std::cerr << __LINE__ << " " << __FILE__<< " -> robot_dart assertion failed: " << message << std::endl; \ return returnValue; \ } \ } while (false) diff --git a/waf_tools/dart.py b/waf_tools/dart.py index ab03a6c4..3e87d2cf 100644 --- a/waf_tools/dart.py +++ b/waf_tools/dart.py @@ -34,7 +34,7 @@ def get_directory(filename, dirs): libs_check = [conf.options.dart + '/lib'] else: includes_check = ['/usr/local/include', '/usr/include', '/opt/homebrew/include'] - libs_check = ['/usr/local/lib', '/usr/local/lib64', '/usr/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/opt/homebrew/lib'] + libs_check = ['/usr/local/lib', '/usr/local/lib64', '/usr/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/opt/homebrew/lib'] if 'RESIBOTS_DIR' in os.environ: includes_check = [os.environ['RESIBOTS_DIR'] + '/include'] + includes_check diff --git a/wscript b/wscript index 42e6835d..bd72ded7 100644 --- a/wscript +++ b/wscript @@ -139,15 +139,15 @@ def configure_robot_dart(conf): common_flags = "-Wall -std=c++11" opt_flags = " -O3 -xHost -unroll -g " + native_icc elif conf.env.CXX_NAME in ["clang"]: - common_flags = "-Wall -std=c++11" + common_flags = "-Wall -std=c++11 -fPIC" # no-stack-check required for Catalina opt_flags = " -O3 -g -faligned-new -fno-stack-check -Wno-narrowing" + native else: gcc_version = int(conf.env['CC_VERSION'][0]+conf.env['CC_VERSION'][1]) if gcc_version < 47: - common_flags = "-Wall -std=c++0x" + common_flags = "-Wall -std=c++0x -fPIC" else: - common_flags = "-Wall -std=c++11" + common_flags = "-Wall -std=c++11 -fPIC" opt_flags = " -O3 -g" + native if gcc_version >= 71: opt_flags = opt_flags + " -faligned-new" From fa82677f619cf495302a4fe560c3cf937ce02762 Mon Sep 17 00:00:00 2001 From: Konstantinos Chatzilygeroudis Date: Sun, 10 Apr 2022 14:46:26 +0300 Subject: [PATCH 2/4] When building shared lib, we do not need -fPIC and add it as an option even for static [by default we build with -fPIC] --- wscript | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wscript b/wscript index bd72ded7..30a7cb3c 100644 --- a/wscript +++ b/wscript @@ -43,6 +43,7 @@ def options(opt): opt.add_option('--tests', action='store_true', help='compile tests or not', dest='tests') opt.add_option('--python', action='store_true', help='compile python bindings', dest='pybind') opt.add_option('--no-robot_dart', action='store_true', help='only install the URDF library (utheque) / deactivate RobotDART', dest='utheque_only') + opt.add_option('--no-pic', action='store_true', help='do not compile with position independent code', dest='no_pic') def configure(conf): @@ -113,7 +114,8 @@ def configure_robot_dart(conf): conf.check_python_module('dartpy') conf.check_pybind11(required=True) conf.env['BUILD_PYTHON'] = True - conf.env['py_flags'] = ' -fPIC' # we need -fPIC + if not conf.options.build_shared: + conf.env['py_flags'] = ' -fPIC' # we need -fPIC for python if building static # We require Magnum DartIntegration, EigenIntegration, AssimpImporter, and StbTrueTypeFont if len(conf.env.INCLUDES_MagnumIntegration_Dart) > 0 and len(conf.env.INCLUDES_MagnumIntegration_Eigen) > 0 and len(conf.env.INCLUDES_MagnumPlugins_AssimpImporter) > 0 and len(conf.env.INCLUDES_MagnumPlugins_StbTrueTypeFont) > 0: @@ -139,19 +141,22 @@ def configure_robot_dart(conf): common_flags = "-Wall -std=c++11" opt_flags = " -O3 -xHost -unroll -g " + native_icc elif conf.env.CXX_NAME in ["clang"]: - common_flags = "-Wall -std=c++11 -fPIC" + common_flags = "-Wall -std=c++11" # no-stack-check required for Catalina opt_flags = " -O3 -g -faligned-new -fno-stack-check -Wno-narrowing" + native else: gcc_version = int(conf.env['CC_VERSION'][0]+conf.env['CC_VERSION'][1]) if gcc_version < 47: - common_flags = "-Wall -std=c++0x -fPIC" + common_flags = "-Wall -std=c++0x" else: - common_flags = "-Wall -std=c++11 -fPIC" + common_flags = "-Wall -std=c++11" opt_flags = " -O3 -g" + native if gcc_version >= 71: opt_flags = opt_flags + " -faligned-new" + if (not conf.options.build_shared) and (not conf.options.no_pic): + common_flags += ' -fPIC' + all_flags = common_flags + conf.env['py_flags'] + opt_flags conf.env['CXXFLAGS'] = conf.env['CXXFLAGS'] + all_flags.split(' ') @@ -171,6 +176,9 @@ def configure_robot_dart(conf): # add strict flags for warnings corrade.corrade_enable_pedantic_flags(conf) + + # keep only one time each flag + conf.env['CXXFLAGS'] = list(set(conf.env['CXXFLAGS'])) print(conf.env['CXXFLAGS']) def summary(bld): From 6f8cca71364d08442981d5571d3e5d325ae0d6e5 Mon Sep 17 00:00:00 2001 From: Konstantinos Chatzilygeroudis Date: Sun, 10 Apr 2022 15:06:22 +0300 Subject: [PATCH 3/4] Improve all wscripts for all libs (for consistency) --- waf_tools/boost.py | 4 ++-- waf_tools/corrade.py | 2 +- waf_tools/dart.py | 16 ++++++++-------- waf_tools/eigen.py | 2 +- waf_tools/magnum.py | 2 +- waf_tools/magnum_integration.py | 2 +- waf_tools/magnum_plugins.py | 2 +- waf_tools/pybind.py | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/waf_tools/boost.py b/waf_tools/boost.py index d5ada8ee..0a8f1dd1 100644 --- a/waf_tools/boost.py +++ b/waf_tools/boost.py @@ -32,8 +32,8 @@ def build(bld): from waflib import Utils, Logs from waflib.Configure import conf -BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu/', '/opt/homebrew/lib'] -BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] +BOOST_LIBS = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] +BOOST_INCLUDES = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] BOOST_VERSION_FILE = 'boost/version.hpp' BOOST_VERSION_CODE = ''' #include diff --git a/waf_tools/corrade.py b/waf_tools/corrade.py index 1947073f..88372226 100644 --- a/waf_tools/corrade.py +++ b/waf_tools/corrade.py @@ -38,7 +38,7 @@ def find_in_string(data, text): return includes_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] - libs_check = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu/', '/usr/lib64', '/opt/homebrew/lib'] + libs_check = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] bins_check = ['/usr/bin', '/usr/local/bin', '/opt/local/bin', '/sw/bin', '/bin', '/opt/homebrew/bin'] # OSX/Mac uses .dylib and GNU/Linux .so diff --git a/waf_tools/dart.py b/waf_tools/dart.py index 3e87d2cf..dce00651 100644 --- a/waf_tools/dart.py +++ b/waf_tools/dart.py @@ -33,16 +33,16 @@ def get_directory(filename, dirs): includes_check = [conf.options.dart + '/include'] libs_check = [conf.options.dart + '/lib'] else: - includes_check = ['/usr/local/include', '/usr/include', '/opt/homebrew/include'] - libs_check = ['/usr/local/lib', '/usr/local/lib64', '/usr/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/opt/homebrew/lib'] + includes_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] + libs_check = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] if 'RESIBOTS_DIR' in os.environ: includes_check = [os.environ['RESIBOTS_DIR'] + '/include'] + includes_check libs_check = [os.environ['RESIBOTS_DIR'] + '/lib'] + libs_check # DART has some optional Bullet features - bullet_check = ['/usr/local/include/bullet', '/usr/include/bullet', '/opt/homebrew/include/bullet'] - bullet_libs = ['/usr/local/lib', '/usr/local/lib64', '/usr/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/opt/homebrew/lib'] + bullet_check = ['/usr/local/include/bullet', '/usr/include/bullet', '/opt/local/include/bullet', '/sw/include/bullet', '/opt/homebrew/include/bullet', '/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] + bullet_libs = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] bullet_include = [] bullet_lib = [] bullet_found = False @@ -57,8 +57,8 @@ def get_directory(filename, dirs): bullet_found = False # DART has some optional ODE features - ode_check = ['/usr/local/include', '/usr/include', '/opt/homebrew/include'] - ode_libs = ['/usr/local/lib', '/usr/local/lib64', '/usr/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/opt/homebrew/lib'] + ode_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] + ode_libs = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] ode_include = [] ode_lib = [] ode_found = False @@ -73,8 +73,8 @@ def get_directory(filename, dirs): ode_found = False # DART has some optional Octomap dependency - octomap_check = ['/usr/local/include', '/usr/include', '/opt/homebrew/include'] - octomap_libs = ['/usr/local/lib', '/usr/local/lib64', '/usr/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/opt/homebrew/lib'] + octomap_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] + octomap_libs = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] if 'ROS_DISTRO' in os.environ: octomap_check.append('/opt/ros/' + os.environ['ROS_DISTRO'] + '/include') octomap_libs.append('/opt/ros/' + os.environ['ROS_DISTRO'] + '/lib') diff --git a/waf_tools/eigen.py b/waf_tools/eigen.py index a071784c..c833069d 100644 --- a/waf_tools/eigen.py +++ b/waf_tools/eigen.py @@ -45,7 +45,7 @@ def check_eigen(conf, *k, **kw): def get_directory(filename, dirs): res = conf.find_file(filename, dirs) return res[:-len(filename)-1] - includes_check = ['/usr/include/eigen3', '/usr/local/include/eigen3', '/usr/include', '/usr/local/include', '/opt/homebrew/include', '/opt/homebrew/include/eigen3'] + includes_check = ['/usr/include/eigen3', '/usr/local/include/eigen3', '/opt/local/include/eigen3', '/sw/include/eigen3', '/opt/homebrew/include/eigen3', '/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] required = kw.get('required', False) min_version = kw.get('min_version', (3,3,3)) diff --git a/waf_tools/magnum.py b/waf_tools/magnum.py index 7adb2269..16b4d8f3 100644 --- a/waf_tools/magnum.py +++ b/waf_tools/magnum.py @@ -117,7 +117,7 @@ def fatal(required, msg): return includes_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] - libs_check = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu/', '/usr/lib64', '/opt/homebrew/lib'] + libs_check = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] bins_check = ['/usr/bin', '/usr/local/bin', '/opt/local/bin', '/sw/bin', '/bin', '/opt/homebrew/bin'] if conf.env['DEST_OS'] == 'darwin': includes_check = includes_check + ['/System/Library/Frameworks/OpenGL.framework/Headers', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/'] diff --git a/waf_tools/magnum_integration.py b/waf_tools/magnum_integration.py index db72dfe5..4425f5a2 100644 --- a/waf_tools/magnum_integration.py +++ b/waf_tools/magnum_integration.py @@ -97,7 +97,7 @@ def find_in_string(data, text): return includes_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] - libs_check = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu/', '/usr/lib64', '/opt/homebrew/lib'] + libs_check = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] bins_check = ['/usr/bin', '/usr/local/bin', '/opt/local/bin', '/sw/bin', '/bin', '/opt/homebrew/bin'] # Magnum depends on several libraries and we cannot make the assumption that diff --git a/waf_tools/magnum_plugins.py b/waf_tools/magnum_plugins.py index d96e4109..09c79ea2 100644 --- a/waf_tools/magnum_plugins.py +++ b/waf_tools/magnum_plugins.py @@ -103,7 +103,7 @@ def find_in_string(data, text): return includes_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] - libs_check = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu/', '/usr/lib64', '/opt/homebrew/lib'] + libs_check = ['/usr/lib', '/usr/local/lib64', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib64', '/usr/lib/x86_64-linux-gnu/', '/usr/local/lib/x86_64-linux-gnu/', '/usr/lib/aarch64-linux-gnu/', '/usr/local/lib/aarch64-linux-gnu/', '/opt/homebrew/lib'] bins_check = ['/usr/bin', '/usr/local/bin', '/opt/local/bin', '/sw/bin', '/bin', '/opt/homebrew/bin'] # Magnum depends on several libraries and we cannot make the assumption that diff --git a/waf_tools/pybind.py b/waf_tools/pybind.py index 5adf680c..90a606d4 100644 --- a/waf_tools/pybind.py +++ b/waf_tools/pybind.py @@ -18,7 +18,7 @@ def check_pybind11(conf, *k, **kw): required = kw.get('required', False) conf.start_msg('Checking for pybind11') - includes_check = ['/usr/include/', '/usr/local/include/', '/opt/homebrew/include'] + includes_check = ['/usr/local/include', '/usr/include', '/opt/local/include', '/sw/include', '/opt/homebrew/include'] if conf.options.pybind11: includes_check = [conf.options.pybind11] From a994241528dbe8ae3b0af05e4d0c497c90274868 Mon Sep 17 00:00:00 2001 From: Konstantinos Chatzilygeroudis Date: Sun, 10 Apr 2022 15:13:44 +0300 Subject: [PATCH 4/4] Minor formatting [ci skip] --- src/robot_dart/utils.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/robot_dart/utils.hpp b/src/robot_dart/utils.hpp index 2cc106e9..bb0ec489 100644 --- a/src/robot_dart/utils.hpp +++ b/src/robot_dart/utils.hpp @@ -48,12 +48,12 @@ namespace robot_dart { std::cerr << "[robot_dart WARNING]: \"" << message << "\"" << std::endl; \ } -#define ROBOT_DART_ASSERT(condition, message, returnValue) \ - do { \ - if (!(condition)) { \ - std::cerr << __LINE__ << " " << __FILE__<< " -> robot_dart assertion failed: " << message << std::endl; \ - return returnValue; \ - } \ +#define ROBOT_DART_ASSERT(condition, message, returnValue) \ + do { \ + if (!(condition)) { \ + std::cerr << __LINE__ << " " << __FILE__ << " -> robot_dart assertion failed: " << message << std::endl; \ + return returnValue; \ + } \ } while (false) #define ROBOT_DART_EXCEPTION_ASSERT(condition, message) \