فهرست منبع

fixup static binary

That is _very_ specific build feature. To invoke, run:

  cd /path/to/build
  cmake -DSTATIC_BINARY=1 /path/to/sources
  make

That should build daemon as static binary (i.e. no depending from any so
 libraries. As side effect - no replication, no ssl, no udf
 functions, and no dns resolving. ldd should say that searchd 'not a
 dynamic executable'.

 That fixes #1862
Alexey N. Vinogradov 5 سال پیش
والد
کامیت
de36c29636
3فایلهای تغییر یافته به همراه53 افزوده شده و 29 حذف شده
  1. 14 4
      CMakeLists.txt
  2. 15 5
      cmake/update_bundle.cmake
  3. 24 20
      src/CMakeLists.txt

+ 14 - 4
CMakeLists.txt

@@ -310,9 +310,13 @@ else ( WIN32 )
 		if ( STATIC_BINARY )
 			set ( CFLAGS "${CFLAGS} -static")
 			set ( HAVE_DLOPEN 0 )
-			set ( WITH_ODBC 0 )
-			set ( WITH_MYSQL 0 )
-			set ( WITH_PGSQL 0 )
+			set ( HAVE_GETADDRINFO_A 0 )
+			set ( WITH_ODBC 0 CACHE BOOL "" FORCE)
+			set ( WITH_MYSQL 0 CACHE BOOL "" FORCE)
+			set ( WITH_PGSQL 0 CACHE BOOL "" FORCE)
+			set ( USE_GALERA 0 CACHE BOOL "" FORCE )
+			set ( USE_SSL 0 CACHE BOOL "" FORCE )
+			SET ( DISABLE_TESTING 1 CACHE BOOL "" FORCE)
 		endif()
 
 		set ( MY_C_FLAGS "${CFLAGS}" )
@@ -582,8 +586,14 @@ ENDIF ( WITH_STEMMER )
 message ( STATUS "Option WITH_ICU ${WITH_ICU}" )
 option ( WITH_ICU "compile with ICU library support" ON )
 if ( WITH_ICU )
-	OPTION ( WITH_ICU_FORCE_STATIC "force to compile ICU from sources" ON )
+	OPTION ( WITH_ICU_FORCE_STATIC "force to link ICU statically" ON )
+	if (STATIC_BINARY)
+		OPTION(WITH_ICU_FORCE_BUILD "force to compile ICU from sources" ON)
+	endif()
 	include ( GetICU )
+	if (STATIC_BINARY)
+		target_compile_options(icu PRIVATE "-DHAVE_DLOPEN=0")
+	endif()
 endif ( WITH_ICU )
 
 

+ 15 - 5
cmake/update_bundle.cmake

@@ -263,13 +263,23 @@ function(PROVIDE LIB LIB_GITHUB LIB_TARBALL)
 
 	# get source tarball, if WRITEB is in action
 	populate (LIB_PLACE ${LIB} "${LIBS_BUNDLE}/${LIB_TARBALL}" "${LIB_GITHUB}")
-	get_buildd(LIB_BUILD ${SLIB})
 	get_srcpath(LIB_SRC ${SLIB})
 
-	# check for cached lib
-	if (HAVE_BBUILD)
-		find_lib_build (${LIB} ${LIB_SRC} ${LIB_BUILD})
-		return_if_found(${LIB} "found in cache")
+	# check if user wants to try cached sources, but build them in-tree (to use custom config keys, etc)
+	if (WITH_${LIB}_FORCE_BUILD)
+		# force get_buildd to find no cache for building
+		unset (__OLD_BBUILD)
+		set(__OLD_BBUILD ${HAVE_BBUILD})
+		set(HAVE_BBUILD FALSE)
+		get_buildd(LIB_BUILD ${SLIB})
+		set(HAVE_BBUILD ${__OLD_BBUILD})
+	else()
+		# check for cached lib
+		get_buildd(LIB_BUILD ${SLIB})
+		if (HAVE_BBUILD )
+			find_lib_build (${LIB} ${LIB_SRC} ${LIB_BUILD})
+			return_if_found(${LIB} "found in cache")
+		endif()
 	endif()
 
 	# check in-tree sources

+ 24 - 20
src/CMakeLists.txt

@@ -210,21 +210,24 @@ endif ( USE_SSL )
 add_dependencies ( lsearchd vergen )
 
 # our executables
-add_executable ( indexer ${INDEXER_SRCS} )
-add_executable ( indextool ${INDEXTOOL_SRCS} )
-add_executable ( searchd searchd.cpp )
-add_executable ( spelldump ${SPELLDUMP_SRCS} )
-add_executable ( wordbreaker ${WORDBREAKER_SRCS} )
-add_executable ( index_converter ${INDEX_CONV_SRCS} )
-add_dependencies ( wordbreaker vergen )
-target_link_libraries ( indexer libsphinx )
-target_link_libraries ( indextool libsphinx )
-target_link_libraries ( searchd lsearchd libsphinx ${EXTRA_SEARCHD_LIBRARIES} ${WSREP})
-target_link_libraries ( spelldump libsphinx )
-target_link_libraries ( wordbreaker libsphinx )
-target_link_libraries ( index_converter libsphinx )
-
-add_library ( udfexample SHARED ${UDFEXAMPLE_SRC} )
+add_executable(searchd searchd.cpp)
+target_link_libraries(searchd lsearchd libsphinx ${EXTRA_SEARCHD_LIBRARIES} ${WSREP})
+
+if (NOT STATIC_BINARY)
+	add_executable(indexer ${INDEXER_SRCS})
+	add_executable(indextool ${INDEXTOOL_SRCS})
+	add_executable(spelldump ${SPELLDUMP_SRCS})
+	add_executable(wordbreaker ${WORDBREAKER_SRCS})
+	add_executable(index_converter ${INDEX_CONV_SRCS})
+	add_dependencies(wordbreaker vergen)
+	target_link_libraries(indexer libsphinx)
+	target_link_libraries(indextool libsphinx)
+	target_link_libraries(spelldump libsphinx)
+	target_link_libraries(wordbreaker libsphinx)
+	target_link_libraries(index_converter libsphinx)
+
+	add_library(udfexample SHARED ${UDFEXAMPLE_SRC})
+endif ()
 
 diag(BINPREFIX)
 IF ( USE_GALERA )
@@ -244,11 +247,12 @@ if ( SPLIT_SYMBOLS )
        split_dbg ( index_converter )
 endif()
 
-INSTALL ( TARGETS indexer indextool spelldump wordbreaker RUNTIME DESTINATION ${BINPREFIX}bin COMPONENT tools )
-INSTALL ( TARGETS searchd RUNTIME DESTINATION ${BINPREFIX}bin COMPONENT applications )
-
-INSTALL ( TARGETS index_converter RUNTIME DESTINATION ${BINPREFIX}bin COMPONENT converter )
-INSTALL(FILES sphinxudf.h  DESTINATION usr/include/manticore COMPONENT devel)
+INSTALL(TARGETS searchd RUNTIME DESTINATION ${BINPREFIX}bin COMPONENT applications)
+if (NOT STATIC_BINARY)
+	INSTALL ( TARGETS indexer indextool spelldump wordbreaker RUNTIME DESTINATION ${BINPREFIX}bin COMPONENT tools )
+	INSTALL ( TARGETS index_converter RUNTIME DESTINATION ${BINPREFIX}bin COMPONENT converter )
+	INSTALL(FILES sphinxudf.h  DESTINATION usr/include/manticore COMPONENT devel)
+endif ()
 
 if ( NOT DISABLE_TESTING )