-
Notifications
You must be signed in to change notification settings - Fork 75
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
CI: build in Docker with MUSL libc for static library #736
base: master
Are you sure you want to change the base?
Changes from all commits
4b43c49
07438fc
65675f2
62d9331
3ece7db
661c470
d84f40b
8796a30
160e515
452d2f9
cf538b3
c0fcc64
76be0eb
fd6ae19
c9f2ff0
fee3e64
29dbb04
e709f24
530cfce
fc0f920
2761587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,8 @@ | |
############################################################## | ||
|
||
include(CheckCXXCompilerFlag) | ||
|
||
#set(CMAKE_CXX_VISIBILITY_PRESET hidden) | ||
set(CMAKE_CXX_VISIBILITY_INLINES_HIDDEN ON) | ||
|
||
# Identify platform name. | ||
if(NOT PLATFORM) | ||
|
@@ -227,6 +228,7 @@ else() | |
-DHAVE_CONFIG_H | ||
-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | ||
-DBOOST_NO_WREGEX | ||
-DNTA_LIBC_MUSL=${NTA_LIBC_MUSL} | ||
) | ||
|
||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release") | ||
|
@@ -253,40 +255,16 @@ else() | |
# endif() | ||
|
||
|
||
# | ||
# Determine stdlib settings | ||
# | ||
set(stdlib_cxx) | ||
set(stdlib_common) | ||
|
||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
set(stdlib_cxx ${stdlib_cxx} -stdlib=libc++) | ||
endif() | ||
|
||
# TODO: investigate if we should use static or shared stdlib and gcc lib. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") | ||
set(stdlib_common ${stdlib_common} -static-libgcc) | ||
set(stdlib_cxx ${stdlib_cxx} -static-libstdc++) | ||
endif() | ||
|
||
|
||
|
||
# | ||
# compiler specific settings and warnings here | ||
# | ||
set(internal_compiler_warning_flags) | ||
set(cxx_flags_unoptimized) | ||
set(linker_flags_unoptimized) | ||
|
||
# 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 ) | ||
|
||
|
||
# LLVM Clang / Gnu GCC | ||
set(cxx_flags_unoptimized ${cxx_flags_unoptimized} ${stdlib_cxx}) | ||
|
||
set(cxx_flags_unoptimized ${cxx_flags_unoptimized} ${stdlib_common} -fdiagnostics-show-option) | ||
set(cxx_flags_unoptimized ${cxx_flags_unoptimized} -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) | ||
|
||
CHECK_CXX_COMPILER_FLAG(-m${BITNESS} compiler_supports_machine_option) | ||
|
@@ -308,8 +286,6 @@ else() | |
endif() | ||
endif() | ||
|
||
set(shared_linker_flags_unoptimized ${shared_linker_flags_unoptimized} ${stdlib_common} ${stdlib_cxx}) | ||
|
||
# Don't allow undefined symbols when linking executables | ||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") | ||
set(linker_flags_unoptimized ${linker_flags_unoptimized} -Wl,--no-undefined) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
if(EXISTS "${REPOSITORY_DIR}/build/ThirdParty/share/googletest.tar.gz") | ||
set(URL "${REPOSITORY_DIR}/build/ThirdParty/share/googletest.tar.gz") | ||
else() | ||
set(URL https://github.com/abseil/googletest/archive/release-1.8.1.tar.gz) | ||
set(URL https://github.com/abseil/googletest/archive/release-1.10.0.tar.gz) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bump gtest |
||
endif() | ||
|
||
# | ||
|
@@ -54,12 +54,12 @@ set(BUILD_GMOCK OFF CACHE BOOL "prevents building gmock" FORCE) | |
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) | ||
|
||
if(MSVC) | ||
set(gtest_LIBRARIES ${googletest_BINARY_DIR}/googletest/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/${CMAKE_STATIC_LIBRARY_PREFIX}gtest$<$<CONFIG:Debug>:d>${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
set(gtest_LIBRARIES ${EP_BASE}/lib/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/${CMAKE_STATIC_LIBRARY_PREFIX}gtest$<$<CONFIG:Debug>:d>${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
else() | ||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") | ||
set(DEBUG_POSTFIX d) | ||
endif() | ||
set(gtest_LIBRARIES ${googletest_BINARY_DIR}/googletest/${CMAKE_STATIC_LIBRARY_PREFIX}gtest$<$<CONFIG:Debug>:d>${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
set(gtest_LIBRARIES ${EP_BASE}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest$<$<CONFIG:Debug>:d>${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
breznak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
endif() | ||
FILE(APPEND "${EXPORT_FILE_NAME}" "gtest_INCLUDE_DIRS@@@${googletest_SOURCE_DIR}/googletest/include\n") | ||
FILE(APPEND "${EXPORT_FILE_NAME}" "gtest_LIBRARIES@@@${gtest_LIBRARIES}\n") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ cmake_minimum_required(VERSION 3.7) | |
project(htm_core CXX) | ||
|
||
message(STATUS "Configuring htm_core src") | ||
message(STATUS "Using MUSL LIBC= ${NTA_LIBC_MUSL}") | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
set(CMAKE_VERBOSE_MAKEFILE ON) # toggle for cmake debug | ||
include(src/NupicLibraryUtils) # for combining static libs | ||
|
@@ -243,6 +244,9 @@ set(src_lib_static htm_core_solo) | |
add_library(${src_lib_static} STATIC $<TARGET_OBJECTS:${src_objlib}>) | ||
if(MSVC) | ||
set_property(TARGET ${src_lib_static} PROPERTY LINK_LIBRARIES ${INTERNAL_LINKER_FLAGS}) | ||
elseif(${NTA_LIBC_MUSL}) | ||
message("Doing static build with MUSL libc") | ||
target_link_libraries(${src_lib_static} -static) | ||
endif() | ||
# | ||
# Create the libhtm_core.a as a "combined" static library by merging htm_core_static | ||
|
@@ -319,12 +323,17 @@ target_link_libraries(${src_executable_hotgym} | |
${core_library} | ||
${COMMON_OS_LIBS} | ||
) | ||
|
||
|
||
# for future reference; to link to shared library, (Not on MSVC) | ||
# link with ${src_lib_shared} rather than ${core_library} | ||
|
||
target_compile_options( ${src_executable_hotgym} PUBLIC ${INTERNAL_CXX_FLAGS}) | ||
target_compile_definitions(${src_executable_hotgym} PRIVATE ${COMMON_COMPILER_DEFINITIONS}) | ||
if(${NTA_LIBC_MUSL}) | ||
target_compile_definitions(${src_executable_hotgym} PRIVATE ${COMMON_COMPILER_DEFINITIONS} -DNTA_LIBC_MUSL=${NTA_LIBC_MUSL}) | ||
else() | ||
target_compile_definitions(${src_executable_hotgym} PRIVATE ${COMMON_COMPILER_DEFINITIONS}) | ||
endif() | ||
target_include_directories(${src_executable_hotgym} PRIVATE | ||
${CORE_LIB_INCLUDES} | ||
${EXTERNAL_INCLUDES} | ||
|
@@ -348,7 +357,11 @@ else() | |
${COMMON_OS_LIBS} | ||
) | ||
target_compile_options( ${src_dyn_executable_hotgym} PUBLIC ${INTERNAL_CXX_FLAGS}) | ||
target_compile_definitions(${src_dyn_executable_hotgym} PRIVATE ${COMMON_COMPILER_DEFINITIONS}) | ||
if(${NTA_LIBC_MUSL}) | ||
target_compile_definitions(${src_dyn_executable_hotgym} PRIVATE ${COMMON_COMPILER_DEFINITIONS} -DNTA_LIBC_MUSL=${NTA_LIBC_MUSL}) | ||
else() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Should not need to do that if it is already in COMMON_COMPILER_DEFINITIONS. |
||
target_compile_definitions(${src_dyn_executable_hotgym} PRIVATE ${COMMON_COMPILER_DEFINITIONS}) | ||
endif() | ||
target_include_directories(${src_dyn_executable_hotgym} PRIVATE | ||
${CORE_LIB_INCLUDES} | ||
${EXTERNAL_INCLUDES} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,11 +44,6 @@ Real64 BenchmarkHotgym::run(UInt EPOCHS, bool useSPlocal, bool useSPglobal, bool | |
EPOCHS = 2; // make test faster in Debug | ||
#endif | ||
|
||
#if defined __aarch64__ || defined __arm__ | ||
#undef _ARCH_DETERMINISTIC | ||
#else | ||
#define _ARCH_DETERMINISTIC | ||
#endif | ||
|
||
if(useTM ) { | ||
NTA_CHECK(useSPlocal or useSPglobal) << "using TM requires a SP too"; | ||
|
@@ -200,7 +195,11 @@ EPOCHS = 2; // make test faster in Debug | |
|
||
SDR goldSP({COLS}); | ||
const SDR_sparse_t deterministicSP{ | ||
#ifdef NTA_LIBC_MUSL | ||
62, 72, 73, 82, 85, 102, 263, 277, 287, 303, 306, 308, 309, 322, 337, 339, 340, 352, 370, 493, 1094, 1095, 1114, 1115, 1120, 1463, 1512, 1518, 1647, 1651, 1691, 1694, 1729, 1745, 1746, 1760, 1770, 1774, 1775, 1781, 1797, 1798, 1803, 1804, 1805, 1812, 1827, 1828, 1831, 1832, 1858, 1859, 1860, 1861, 1862, 1875, 1878, 1880, 1881, 1898, 1918, 1923, 1929, 1931, 1936, 1950, 1953, 1956, 1958, 1961, 1964, 1965, 1967, 1971, 1973, 1975, 1976, 1979, 1980, 1981, 1982, 1984, 1985, 1986, 1988, 1991, 1994, 1996, 1997, 1998, 1999, 2002, 2006, 2008, 2011, 2012, 2013, 2017, 2019, 2022, 2027, 2030 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added custom deterministic results for MUSL. I don't know if we can achieve same on glibc & musl. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #707 |
||
#else | ||
62, 72, 73, 82, 85, 102, 263, 277, 287, 303, 306, 308, 309, 322, 337, 339, 340, 352, 370, 493, 1094, 1095, 1114, 1115, 1120, 1463, 1512, 1518, 1647, 1651, 1691, 1694, 1729, 1745, 1746, 1760, 1770, 1774, 1775, 1781, 1797, 1798, 1803, 1804, 1805, 1812, 1827, 1828, 1831, 1832, 1858, 1859, 1860, 1861, 1862, 1875, 1878, 1880, 1881, 1898, 1918, 1923, 1929, 1931,1936, 1950, 1953, 1956, 1958, 1961, 1964, 1965, 1967, 1971, 1973, 1975, 1976, 1979, 1980, 1981, 1982, 1984, 1985, 1986, 1988, 1991, 1994, 1996, 1997, 1998, 1999, 2002, 2006, 2008, 2011, 2012, 2013, 2017, 2019, 2022, 2027, 2030 | ||
#endif | ||
}; | ||
goldSP.setSparse(deterministicSP); | ||
|
||
|
@@ -212,14 +211,17 @@ EPOCHS = 2; // make test faster in Debug | |
|
||
SDR goldTM({COLS}); | ||
const SDR_sparse_t deterministicTM{ | ||
#ifdef NTA_LIBC_MUSL | ||
62, 77, 85, 322, 340, 432, 952, 1120, 1488, 1502, 1512, 1518, 1547, 1627, 1633, 1668, 1727, 1729, 1797, 1803, 1805, 1812, 1858, 1859, 1896, 1918, 1923, 1925, 1929, 1931, 1939, 1941, 1942, 1944, 1950, 1953, 1955, 1956, 1965, 1966, 1967, 1968, 1974, 1980, 1987, 1996, 2006, 2008, 2011, 2027, 2030, 2042, 2046 | ||
#else | ||
62, 77, 85, 322, 340, 432, 952, 1120, 1488, 1502, 1512, 1518, 1547, 1627, 1633, 1668, 1727, 1729, 1797, 1803, 1805, 1812, 1858, 1859, 1896, 1918, 1923, 1925, 1929, 1931, 1939, 1941, 1942, 1944, 1950, 1953, 1955, 1956, 1965, 1966, 1967, 1968, 1974, 1980, 1987, 1996, 2006, 2008, 2011, 2027, 2030, 2042, 2046 | ||
#endif | ||
}; | ||
goldTM.setSparse(deterministicTM); | ||
|
||
const float goldAn = 0.627451f; | ||
const float goldAnAvg = 0.407265f; | ||
|
||
#ifdef _ARCH_DETERMINISTIC | ||
if(EPOCHS == 5000) { | ||
//these hand-written values are only valid for EPOCHS = 5000 (default), but not for debug and custom runs. | ||
NTA_CHECK(input == goldEnc) << "Deterministic output of Encoder failed!\n" << input << "should be:\n" << goldEnc; | ||
|
@@ -231,7 +233,6 @@ EPOCHS = 2; // make test faster in Debug | |
NTA_CHECK(static_cast<UInt>(avgAnom10.getCurrentAvg() * 10000.0f) == static_cast<UInt>(goldAnAvg * 10000.0f)) | ||
<< "Deterministic average anom score failed:" << avgAnom10.getCurrentAvg() << " should be: " << goldAnAvg; | ||
} | ||
#endif | ||
|
||
// check runtime speed | ||
const size_t timeTotal = (size_t)floor(tAll.getElapsed()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switching to ubuntu for we can use gcc-8 (c++17) there