From df1cdb132975230d110132d2d6c81c3b3b63e904 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Fri, 9 Mar 2018 12:52:06 +0100 Subject: [PATCH] attempting to build sanitized binaries against statically linked libc++ (WIP) --- SConstruct | 5 +++-- demo/c++/build.py | 6 +++++- include/mapnik/json/unicode_string_grammar_x3.hpp | 2 +- plugins/input/csv/build.py | 4 ++-- plugins/input/ogr/ogr_datasource.cpp | 3 ++- plugins/input/sqlite/build.py | 3 ++- src/expression_grammar_x3.cpp | 10 +++++----- src/json/unicode_string_grammar_x3.cpp | 6 ++++++ test/build.py | 7 ++++++- utils/mapnik-index/build.py | 5 ++--- utils/mapnik-render/build.py | 3 ++- utils/shapeindex/build.py | 1 + 12 files changed, 37 insertions(+), 18 deletions(-) diff --git a/SConstruct b/SConstruct index a27cb2340..545434986 100644 --- a/SConstruct +++ b/SConstruct @@ -1297,7 +1297,8 @@ if not preconfigured: env['QUERIED_PROJ_LIB'] = None env['QUERIED_ICU_DATA'] = None env['QUERIED_GDAL_DATA'] = None - + #'LINKCOM': '$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' + env['LINKCOM'] = '$LINK -o $TARGET $SOURCES $LINKFLAGS $__RPATH $_LIBDIRFLAGS $_LIBFLAGS' # previously a leading / was expected for LIB_DIR_NAME # now strip it to ensure expected behavior if env['LIB_DIR_NAME'].startswith(os.path.sep): @@ -1360,7 +1361,7 @@ if not preconfigured: env.Append(CFLAGS = env['CUSTOM_CFLAGS']) env.Append(LINKFLAGS = DEFAULT_CXX14_LINKFLAGS) env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS']) - + print(env.Dump()) ### platform specific bits thread_suffix = 'mt' diff --git a/demo/c++/build.py b/demo/c++/build.py index c059b05da..64b6d962e 100644 --- a/demo/c++/build.py +++ b/demo/c++/build.py @@ -36,12 +36,16 @@ demo_env = env.Clone() demo_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS']) demo_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES']) +demo_env['LINKFLAGS'] = '-lmapnik -lmapnik-json' + demo_env['LINKFLAGS'] +print demo_env['LINKFLAGS'] + if env['HAS_CAIRO']: demo_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) demo_env.Append(CPPDEFINES = '-DHAVE_CAIRO') -libraries = [env['MAPNIK_NAME']] +libraries = []#env['MAPNIK_NAME']] libraries.extend(copy(env['LIBMAPNIK_LIBS'])) +print libraries rundemo = demo_env.Program('rundemo', source, LIBS=libraries) Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) diff --git a/include/mapnik/json/unicode_string_grammar_x3.hpp b/include/mapnik/json/unicode_string_grammar_x3.hpp index 740b13613..a9985b663 100644 --- a/include/mapnik/json/unicode_string_grammar_x3.hpp +++ b/include/mapnik/json/unicode_string_grammar_x3.hpp @@ -41,7 +41,7 @@ BOOST_SPIRIT_DECLARE(escaped_unicode_type); } grammar::unicode_string_grammar_type const& unicode_string_grammar(); -grammar::escaped_unicode_type const& escaped_unicode_grammar(); +__attribute__((visibility("default"))) grammar::escaped_unicode_type const& escaped_unicode_grammar(); }} diff --git a/plugins/input/csv/build.py b/plugins/input/csv/build.py index f5e030d88..afad43c32 100644 --- a/plugins/input/csv/build.py +++ b/plugins/input/csv/build.py @@ -36,7 +36,7 @@ else: PLUGIN_NAME = 'csv' plugin_env = plugin_base.Clone() - + #plugin_env[LINKFLAGS] = '-lmapnik' + plugin_env[LINKFLAGS] plugin_sources = Split( """ %(PLUGIN_NAME)s_utils.cpp @@ -54,7 +54,7 @@ else: if env['PLUGIN_LINKING'] == 'shared': libraries.append('boost_system%s' % env['BOOST_APPEND']) - libraries.insert(0,env['MAPNIK_NAME']) + #libraries.insert(0,env['MAPNIK_NAME']) libraries.append(env['ICU_LIB_NAME']) TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME, diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index 4c0cb5902..882366260 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -60,7 +60,7 @@ using mapnik::filter_in_box; using mapnik::filter_at_point; static std::once_flag once_flag; - +#if 0 extern "C" MAPNIK_EXP void on_plugin_load() { // initialize ogr formats @@ -69,6 +69,7 @@ extern "C" MAPNIK_EXP void on_plugin_load() OGRRegisterAll(); }); } +#endif ogr_datasource::ogr_datasource(parameters const& params) : datasource(params), diff --git a/plugins/input/sqlite/build.py b/plugins/input/sqlite/build.py index 53dfd8b37..5e6af03cc 100644 --- a/plugins/input/sqlite/build.py +++ b/plugins/input/sqlite/build.py @@ -37,13 +37,14 @@ plugin_sources = Split( libraries = [ 'sqlite3' ] linkflags = [] +plugin_env.Append(LINKFLAGS='-lmapnik') if env['SQLITE_LINKFLAGS']: linkflags.append(env['SQLITE_LINKFLAGS']) plugin_env.Append(LINKFLAGS=linkflags) if env['PLUGIN_LINKING'] == 'shared': libraries.append('boost_system%s' % env['BOOST_APPEND']) - libraries.insert(0,env['MAPNIK_NAME']) + #libraries.insert(0,env['MAPNIK_NAME']) libraries.append(env['ICU_LIB_NAME']) TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME, diff --git a/src/expression_grammar_x3.cpp b/src/expression_grammar_x3.cpp index c072ad75d..fef159f79 100644 --- a/src/expression_grammar_x3.cpp +++ b/src/expression_grammar_x3.cpp @@ -25,13 +25,13 @@ #include namespace mapnik { namespace json { namespace grammar { -BOOST_SPIRIT_INSTANTIATE(unicode_string_grammar_type, mapnik::grammar::iterator_type, mapnik::grammar::context_type); +BOOST_SPIRIT_INSTANTIATE(escaped_unicode_type, mapnik::grammar::iterator_type, mapnik::grammar::context_type); } -grammar::escaped_unicode_type const& escaped_unicode_grammar() -{ - return grammar::escaped_unicode; -} +//grammar::escaped_unicode_type const& escaped_unicode_grammar() +//{ +// return grammar::escaped_unicode; +//} }} diff --git a/src/json/unicode_string_grammar_x3.cpp b/src/json/unicode_string_grammar_x3.cpp index 80c2efc71..72554474d 100644 --- a/src/json/unicode_string_grammar_x3.cpp +++ b/src/json/unicode_string_grammar_x3.cpp @@ -42,6 +42,7 @@ BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extr BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type); BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_context_type_f); BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type_f); + } grammar::unicode_string_grammar_type const& unicode_string_grammar() @@ -49,4 +50,9 @@ grammar::unicode_string_grammar_type const& unicode_string_grammar() return grammar::unicode_string; } +grammar::escaped_unicode_type const& escaped_unicode_grammar() +{ + return grammar::escaped_unicode; +} + }} diff --git a/test/build.py b/test/build.py index 8a9a44523..58b816608 100644 --- a/test/build.py +++ b/test/build.py @@ -5,6 +5,10 @@ from copy import copy Import ('env') test_env = env.Clone() +test_env.Prepend(LINKFLAGS='-lmapnik')# + test_env['LINKFLAGS'] +test_env.Append(LIBS='/home/artem/projects/mason/mason_packages/linux-x86_64/llvm/7.0.0/lib/libc++.a') +#test_env.Append(LIBS='/home/artem/projects/mason/mason_packages/linux-x86_64/llvm/7.0.0/lib/libc++abi.a') +#test_env.Append(LIBS='/home/artem/projects/mason/mason_packages/linux-x86_64/llvm/7.0.0/lib/libunwind.a') if not env['CPP_TESTS']: for cpp_test_bin in glob.glob('./*/*-bin'): @@ -30,10 +34,10 @@ else: test_env.AppendUnique(LIBS='boost_program_options%s' % env['BOOST_APPEND']) test_env_local = test_env.Clone() - # unit tests sources = glob.glob('./unit/*/*.cpp') sources.extend(glob.glob('./unit/*.cpp')) + sources.append('/home/artem/projects/mason/mason_packages/linux-x86_64/llvm/7.0.0/lib/libc++.a') test_program = test_env_local.Program("./unit/run", source=sources) Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(test_program, env.subst('../src/json/libmapnik-json${LIBSUFFIX}')) @@ -57,6 +61,7 @@ else: visual/parse_map_sizes.cpp """ ) + source.append('/home/artem/projects/mason/mason_packages/linux-x86_64/llvm/7.0.0/lib/libc++.a') test_program3 = test_env_local.Program('visual/run', source=source) Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME'])) diff --git a/utils/mapnik-index/build.py b/utils/mapnik-index/build.py index 9bddaf196..92d2edf7e 100644 --- a/utils/mapnik-index/build.py +++ b/utils/mapnik-index/build.py @@ -27,13 +27,12 @@ Import ('env') Import ('plugin_base') program_env = plugin_base.Clone() - +program_env['LINKFLAGS'] = '-lmapnik plugins/input/csv/csv_utils.os' + program_env['LINKFLAGS'] source = Split( """ mapnik-index.cpp process_csv_file.cpp process_geojson_file_x3.cpp - ../../plugins/input/csv/csv_utils.os """ ) @@ -41,7 +40,7 @@ headers = env['CPPPATH'] boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] boost_system = 'boost_system%s' % env['BOOST_APPEND'] -libraries = [env['MAPNIK_NAME'], boost_program_options, boost_system] +libraries = [boost_program_options, boost_system] # need on linux: https://github.com/mapnik/mapnik/issues/3145 libraries.append('mapnik-json') libraries.append('mapnik-wkt') diff --git a/utils/mapnik-render/build.py b/utils/mapnik-render/build.py index 5cdaa164e..6c1c54f17 100644 --- a/utils/mapnik-render/build.py +++ b/utils/mapnik-render/build.py @@ -12,6 +12,7 @@ source = Split( ) program_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS']) +program_env['LINKFLAGS'] = '-lmapnik -lmapnik-json ' + program_env['LINKFLAGS'] program_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES']) if env['HAS_CAIRO']: @@ -19,7 +20,7 @@ if env['HAS_CAIRO']: program_env.Append(CPPDEFINES = '-DHAVE_CAIRO') boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] -libraries = [env['MAPNIK_NAME'],boost_program_options] +libraries = [boost_program_options] libraries.extend(copy(env['LIBMAPNIK_LIBS'])) if env['RUNTIME_LINK'] == 'static' and env['PLATFORM'] == 'Linux': libraries.append('dl') diff --git a/utils/shapeindex/build.py b/utils/shapeindex/build.py index 2a4c2ab07..6984e3499 100644 --- a/utils/shapeindex/build.py +++ b/utils/shapeindex/build.py @@ -28,6 +28,7 @@ Import ('env') Import ('plugin_base') program_env = plugin_base.Clone() +program_env['LINKFLAGS'] = '-lmapnik -lmapnik-json' + program_env['LINKFLAGS'] source = Split( """