Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUP-2320 DO NOT MERGE Convert nupic.core to shared lib. #1216

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
41c9768
NUP-2320 Work-in-progress: separation of concerns. Still static lib.
Jan 24, 2017
9a9a0b5
NUP-2320 Created nupic_core shared lib, but unit_tests fails to link.
Jan 24, 2017
cfe1a38
NUPC-2320 Converted to shared library, but on OS X Sierra, getting er…
Jan 25, 2017
8221cd1
fixup
Jan 25, 2017
e622040
NUP-2320 Add python support objects to tests builds.
Jan 25, 2017
fb87ba8
NUP-2320 Include necessary py_support files in nupic_core shared lib …
Jan 25, 2017
343e6e1
NUP-2320 Add missing link libraries to nupic_core shared lib build on…
Jan 26, 2017
0ed5642
NUP-2320 - Link nupic_core shared lib against necessary os libs.
Jan 26, 2017
b6d74a5
NUP-2320 Make py_binding_support_archive build depend on nupic_core s…
Jan 26, 2017
221a929
NUP-2320 Force visibility of symbols from internal sources compiled i…
Jan 26, 2017
38b32c2
NUP-2320 Use rpath on Unix (OS X and Linux) systems to find nupic_cor…
Jan 27, 2017
152f5d6
NUP-2320 When generating python extensions, link tests also with a sh…
Jan 27, 2017
9fed2c7
NUP-2320 Use toolchain-specific linker option to force all archive sy…
Jan 28, 2017
0bd12fb
NUP-2320 Make all shared lib target_link_library items PRIVATE.
Jan 28, 2017
94aea65
NUP-2320 Use `-Wl,--whole-archive` instead of raw `--whole-archive` f…
Jan 28, 2017
47b561d
Convert new private cmake vars to upper case prefixed with underscore
Jan 28, 2017
83321ba
NUP-2320 Only wrap specific archives in "WHOLE ARCHIVE".
Jan 28, 2017
0746712
NUP-2320 Link lib capnproto_shared with src_common_os_libs to satisif…
Jan 30, 2017
8ef6762
NUP-2320 Define _SRC_WHOLE_ARCHIVE_START for Clang.
Jan 30, 2017
183acd0
fixed APPLE reference.
Jan 30, 2017
504de1f
NUP-2320 Try a different WHOLEARCHIVE option for windows
Jan 30, 2017
9f83b83
Revert syntax of "whole archive" flags. The builds were unhappy with …
Jan 30, 2017
87b8bf7
NUP-2320 Use same "whole archive" option for mingw as for Linux.
Jan 31, 2017
0245637
NUP-2320 Add `--export-all-symbols` link flag to GNUCXX-based builds.
Jan 31, 2017
6e75c38
NUP-2320 Log value of _SRC_SHARED_NUPICCORE_LINK_FLAGS
Jan 31, 2017
7ea90f6
NUP-2320 remove leading/trailing spaces from whole-archive linker flags.
Jan 31, 2017
2c98a61
NUP-2320 No need for --export-all-symbols, since GCC automatically ex…
Jan 31, 2017
47ecbd6
NUP-2320 Move _SRC_LIB_SHARED_CAPNPROTO after _SRC_LIB_SHARED_NUPICCO…
Jan 31, 2017
598e148
NUP-2320 Enable export of all symbols when building nupic_core DLL on…
Feb 1, 2017
60207ae
NUP-2320 Use WINDOWS_EXPORT_ALL_SYMBOLS instead of MINGW-specific -ex…
Feb 1, 2017
24955c0
Revert "NUP-2320 Use WINDOWS_EXPORT_ALL_SYMBOLS instead of MINGW-spec…
Feb 1, 2017
0e5d18e
NUP-2320 Support "export all symbols" for MSVC as well as MINGW, usin…
Feb 1, 2017
c5c33d7
NUP-2320 On GNU builds - including MINGW - always link with -shared-l…
Feb 1, 2017
d7929fa
NUP-2320 Added missing advapi32 to the link list for MINGW builds. It…
Feb 1, 2017
df1790d
NUP-2320 Forego installation of a plethora of header files when build…
Feb 2, 2017
3783395
NUP-2320 Mark nupic-core's link librar interface as PRIVATE.
Feb 2, 2017
aae5644
NUP-2320 Added printfs to help debug py_region_test failures on some …
Feb 2, 2017
486be62
Added `BEFORE SHOULDFAIL(n.run(1))` to make sure we're able to get so…
Feb 2, 2017
4719591
Try with defualt libstdc++ and libgcc.
Feb 2, 2017
cf244f3
NUP-2320 Limit symbols exported from nupic_core DLL when building ext…
Feb 3, 2017
a30831b
Add exported functions from ImageSensorLite.hpp to version script.
Feb 3, 2017
67c6d42
NUP-2320 Added gaborCompute to nupic_core's version script.
Feb 3, 2017
00c9e51
NUP-2320 Remove the experimental INTERNAL_CXX_FLAGS_NO_HIDE from nupi…
Feb 3, 2017
9ceb440
fix typo in comment
Feb 6, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# http://numenta.org/licenses/
# -----------------------------------------------------------------------------

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.12)
project(nupic_core_main CXX)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
Expand Down
56 changes: 37 additions & 19 deletions CommonCompilerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@
#
# INTERNAL_CXX_FLAGS_OPTIMIZED: string of C++ flags with explicit optimization flags for internal sources
#
# INTERNAL_CXX_FLAGS_NO_HIDE: string of C++ flags that may be appended to
# INTERNAL_CXX_FLAGS_NO_HIDE to force visibility of symbols
# that have default visibility.
#
# INTERNAL_LINKER_FLAGS_OPTIMIZED: string of linker flags for linking internal executables
# and shared libraries (DLLs) with optimizations that are
# compatible with INTERNAL_CXX_FLAGS_OPTIMIZED
#
# PYEXT_CXX_FLAGS_OPTIMIZED: string of C++ flags with explicit optimization
# flags for compiling python extension sources.
#
# PYEXT_LINKER_FLAGS_OPTIMIZED: string of linker flags for linking python extension
# shared libraries (DLLs) with optimizations that are
# compatible with EXTERNAL_CXX_FLAGS_OPTIMIZED.
# compatible with PYEXT_CXX_FLAGS_OPTIMIZED.
#
# CMAKE_AR: Name of archiving tool (ar) for static libraries. See cmake documentation
#
Expand All @@ -94,8 +101,10 @@ set(COMMON_COMPILER_DEFINITIONS)
set(COMMON_COMPILER_DEFINITIONS_STR)

set(INTERNAL_CXX_FLAGS_OPTIMIZED)
set(INTERNAL_CXX_FLAGS_NO_HIDE)
set(INTERNAL_LINKER_FLAGS_OPTIMIZED)

set(PYEXT_CXX_FLAGS_OPTIMIZED)
set(PYEXT_LINKER_FLAGS_OPTIMIZED)

set(EXTERNAL_C_FLAGS_UNOPTIMIZED)
Expand Down Expand Up @@ -182,22 +191,21 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()

if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# NOTE We need to use shared libgcc to be able to throw and catch exceptions
# across different shared libraries, as may be the case when our python
# extensions runtime-link to capnproto symbols in pycapnp's extension.
#set(stdlib_common "${stdlib_common} -shared-libgcc")

if (${NUPIC_BUILD_PYEXT_MODULES} AND "${PLATFORM}" STREQUAL "linux")
# NOTE When building manylinux python extensions, we want the static
# libstdc++ due to differences in c++ ABI between the older toolchain in the
# manylinux Docker image and libstdc++ in newer linux distros that is
# compiled with the c++11 ABI. for example, with shared libstdc++, the
# manylinux-built extension is unable to catch std::ios::failure exception
# raised by the shared libstdc++.so while running on Ubuntu 16.04.
set(stdlib_cxx "${stdlib_cxx} -static-libstdc++")

# NOTE We need to use shared libgcc to be able to throw and catch exceptions
# across different shared libraries, as may be the case when our python
# extensions runtime-link to capnproto symbols in pycapnp's extension.
set(stdlib_common "${stdlib_common} -shared-libgcc")
#set(stdlib_cxx "${stdlib_cxx} -static-libstdc++")
else()
set(stdlib_common "${stdlib_common} -static-libgcc")
set(stdlib_cxx "${stdlib_cxx} -static-libstdc++")
#set(stdlib_cxx "${stdlib_cxx} -static-libstdc++")
endif()
endif()

Expand Down Expand Up @@ -237,6 +245,9 @@ set(cxx_flags_unoptimized "")
set(shared_linker_flags_unoptimized "")
set(fail_link_on_undefined_symbols_flags "")
set(allow_link_with_undefined_symbols_flags "")
set(cxx_hidden_vis_compile_flags "")
set(shared_hidden_vis_compile_flags "")
set(shared_default_to_vis_compile_flags "")

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
# MS Visual C
Expand All @@ -252,12 +263,14 @@ else()
# LLVM Clang / Gnu GCC
set(cxx_flags_unoptimized "${cxx_flags_unoptimized} ${stdlib_cxx} -std=c++11")

if (${NUPIC_BUILD_PYEXT_MODULES})
# Hide all symbols in DLLs except the ones with explicit visibility;
# see https://gcc.gnu.org/wiki/Visibility
set(cxx_flags_unoptimized "${cxx_flags_unoptimized} -fvisibility-inlines-hidden")
set(shared_compile_flags "${shared_compile_flags} -fvisibility=hidden")
endif()
# Hide all symbols in DLLs except the ones with explicit visibility;
# see https://gcc.gnu.org/wiki/Visibility
set(cxx_hidden_vis_compile_flags "${cxx_hidden_vis_compile_flags} -fvisibility-inlines-hidden")
set(shared_hidden_vis_compile_flags "${shared_hidden_vis_compile_flags} -fvisibility=hidden")

# Per https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Code-Gen-Options.html:
# "Despite the nomenclature, default always means public"
set(shared_default_to_vis_compile_flags "${shared_default_to_vis_compile_flags} -fvisibility=default")

set(shared_compile_flags "${shared_compile_flags} ${stdlib_common} -fdiagnostics-show-option")
set (internal_compiler_warning_flags "${internal_compiler_warning_flags} -Werror -Wextra -Wreturn-type -Wunused -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers")
Expand Down Expand Up @@ -359,6 +372,7 @@ endif()

# Settings for internal nupic.core code
set(INTERNAL_CXX_FLAGS_OPTIMIZED "${build_type_specific_compile_flags} ${shared_compile_flags} ${cxx_flags_unoptimized} ${internal_compiler_warning_flags} ${optimization_flags_cc}")
set(INTERNAL_CXX_FLAGS_NO_HIDE "${shared_default_to_vis_compile_flags}")

set(complete_linker_flags_unoptimized "${build_type_specific_linker_flags} ${shared_linker_flags_unoptimized}")
set(complete_linker_flags_unoptimized "${complete_linker_flags_unoptimized} ${fail_link_on_undefined_symbols_flags}")
Expand All @@ -370,16 +384,19 @@ set(INTERNAL_LINKER_FLAGS_OPTIMIZED "${complete_linker_flags_unoptimized} ${opti
set(EXTERNAL_C_FLAGS_UNOPTIMIZED "${build_type_specific_compile_flags} ${shared_compile_flags} ${external_compiler_warning_flags}")
set(EXTERNAL_C_FLAGS_OPTIMIZED "${EXTERNAL_C_FLAGS_UNOPTIMIZED} ${optimization_flags_cc}")

set(PYEXT_LINKER_FLAGS_OPTIMIZED "${build_type_specific_linker_flags} ${shared_linker_flags_unoptimized}")
set(PYEXT_LINKER_FLAGS_OPTIMIZED "${PYEXT_LINKER_FLAGS_OPTIMIZED} ${optimization_flags_lt}")
set(PYEXT_LINKER_FLAGS_OPTIMIZED "${PYEXT_LINKER_FLAGS_OPTIMIZED} ${allow_link_with_undefined_symbols_flags}")

set(EXTERNAL_CXX_FLAGS_UNOPTIMIZED "${build_type_specific_compile_flags} ${shared_compile_flags} ${external_compiler_warning_flags} ${cxx_flags_unoptimized}")
set(EXTERNAL_CXX_FLAGS_OPTIMIZED "${EXTERNAL_CXX_FLAGS_UNOPTIMIZED} ${optimization_flags_cc}")

set(EXTERNAL_LINKER_FLAGS_UNOPTIMIZED "${complete_linker_flags_unoptimized}")
set(EXTERNAL_LINKER_FLAGS_OPTIMIZED "${INTERNAL_LINKER_FLAGS_OPTIMIZED}")

set(PYEXT_CXX_FLAGS_OPTIMIZED "${EXTERNAL_CXX_FLAGS_OPTIMIZED} ${shared_hidden_vis_compile_flags}")
set(PYEXT_CXX_FLAGS_OPTIMIZED "${PYEXT_CXX_FLAGS_OPTIMIZED} ${cxx_hidden_vis_compile_flags}")

set(PYEXT_LINKER_FLAGS_OPTIMIZED "${build_type_specific_linker_flags} ${shared_linker_flags_unoptimized}")
set(PYEXT_LINKER_FLAGS_OPTIMIZED "${PYEXT_LINKER_FLAGS_OPTIMIZED} ${optimization_flags_lt}")
set(PYEXT_LINKER_FLAGS_OPTIMIZED "${PYEXT_LINKER_FLAGS_OPTIMIZED} ${allow_link_with_undefined_symbols_flags}")


#
# Provide a string variant of the COMMON_COMPILER_DEFINITIONS list
Expand All @@ -393,6 +410,7 @@ message(STATUS "INTERNAL_CXX_FLAGS_OPTIMIZED=${INTERNAL_CXX_FLAGS_OPTIMIZED}")
message(STATUS "INTERNAL_LINKER_FLAGS_OPTIMIZED=${INTERNAL_LINKER_FLAGS_OPTIMIZED}")
message(STATUS "EXTERNAL_C_FLAGS_UNOPTIMIZED=${EXTERNAL_C_FLAGS_UNOPTIMIZED}")
message(STATUS "EXTERNAL_C_FLAGS_OPTIMIZED=${EXTERNAL_C_FLAGS_OPTIMIZED}")
message(STATUS "PYEXT_CXX_FLAGS_OPTIMIZED=${PYEXT_CXX_FLAGS_OPTIMIZED}")
message(STATUS "PYEXT_LINKER_FLAGS_OPTIMIZED=${PYEXT_LINKER_FLAGS_OPTIMIZED}")
message(STATUS "EXTERNAL_CXX_FLAGS_UNOPTIMIZED=${EXTERNAL_CXX_FLAGS_UNOPTIMIZED}")
message(STATUS "EXTERNAL_CXX_FLAGS_OPTIMIZED=${EXTERNAL_CXX_FLAGS_OPTIMIZED}")
Expand Down
4 changes: 2 additions & 2 deletions bindings/py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ def generateExtensions():
# This distribution contains platform-specific C++ libraries, but they are not
# built with distutils. So we must create a dummy Extension object so when we
# create a binary file it knows to make it platform-specific.
ext_modules=[Extension('nupic.dummy', sources = ['dummy.c'])],
ext_modules=[Extension('nupic.dummy', sources = ['dummy.c'])],
namespace_packages=["nupic"],
install_requires=findRequirements(platform),
packages=find_packages(),
package_data={
"nupic.proto": ["*.capnp"],
"nupic.bindings": ["*.so", "*.pyd"],
"nupic.bindings": ["*.so", "*.dylib", "*.pyd"],
},
extras_require = {"capnp": ["pycapnp==0.5.8"]},
zip_safe=False,
Expand Down
2 changes: 1 addition & 1 deletion external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# http://numenta.org/licenses/
# -----------------------------------------------------------------------------

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.12)
project(nupic_core_main CXX)

set(CMAKE_VERBOSE_MAKEFILE OFF)
Expand Down
Loading