[PATCH] (issue126) Commit WIP on static linking libc

Wald Commits scm-commit at wald.intevation.org
Thu Sep 18 10:29:52 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1411028978 -7200
# Branch static-libc
# Node ID 148014db2f3ba11775e814e3fd17d00535cdab38
# Parent  e82c440c272786a574c14a9ccc581820a682bad0
(issue126) Commit WIP on static linking libc

diff -r e82c440c2727 -r 148014db2f3b CMakeLists.txt
--- a/CMakeLists.txt	Wed Sep 17 16:23:33 2014 +0200
+++ b/CMakeLists.txt	Thu Sep 18 10:29:38 2014 +0200
@@ -86,7 +86,7 @@
 set(WARN_HARDENING_FLAGS " -Wextra -Wconversion -Wformat-security")
 
 # Hardening flags
-set(HARDENING_FLAGS " -Wall -fstack-protector-all -fno-exceptions")
+set(HARDENING_FLAGS " -fPIC -Wall -fstack-protector-all -fno-exceptions")
 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector")
 set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4")
 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O0")
@@ -103,8 +103,9 @@
 endif(WIN32)
 
 if(UNIX)
-   set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv")
+   set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Bdynamic -ftrapv")
    set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now")
+   set(EXTRA_STATIC_FLAGS " -Wl,--undefined=__pthread_unwind -static -static-libstdc++ -static-libgcc")
 elseif(WIN32)
    set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat")
 endif()
diff -r e82c440c2727 -r 148014db2f3b INSTALL
--- a/INSTALL	Wed Sep 17 16:23:33 2014 +0200
+++ b/INSTALL	Thu Sep 18 10:29:38 2014 +0200
@@ -12,6 +12,8 @@
 ( qtbase/src/plugins/platforms/xcb/README ).
 Polarssl needs cmake and build-essentials.
 
+The following documentation uses the variable YOURPREFIX as placeholder for your environment prefix
+
     export YOURPREFIX=<Prefix of your choice (default /usr)>
     export PATH=$YOURPREFIX/bin:$PATH
 
@@ -90,6 +92,7 @@
     --without-zlib
     make && make install
 
+
 To compile the software you can use plain cmake. An out of source build is
 highly suggested. For build options see CMakeList.txt
 
@@ -99,7 +102,6 @@
     cd build-linux
     cmake .. -DCMAKE_PREFIX_PATH=$YOURPREFIX
 
-
 I386
 ====
 Install dependencies (list might be incomplete)
diff -r e82c440c2727 -r 148014db2f3b cinst/CMakeLists.txt
--- a/cinst/CMakeLists.txt	Wed Sep 17 16:23:33 2014 +0200
+++ b/cinst/CMakeLists.txt	Thu Sep 18 10:29:38 2014 +0200
@@ -11,6 +11,8 @@
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common)
 
+set(CMAKE_CXX_FLAGS "${EXTRA_STATIC_FLAGS}")
+
 set(CINST_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/windowsstore.c
     ${CMAKE_CURRENT_SOURCE_DIR}/nssstore_linux.c
@@ -23,11 +25,20 @@
    set(WIN_EXTRA_LIBS -lcrypt32 -luserenv -lshell32)
 endif(WIN32)
 
+#if(EXISTS "${CMAKE_PREFIX_PATH}/lib/libc.a")
+#   message(status "Linking against static libc: ${CMAKE_PREFIX_PATH}/lib/libc.a")
+#   set (LIBC_STATIC "${CMAKE_PREFIX_PATH}/lib/libc.a" "${CMAKE_PREFIX_PATH}/lib/libpthread.a")
+#endif()
+
+message(fatal "cmake prefix ${CMAKE_PREFIX_PATH}")
 target_link_libraries(cinst
    trustbridge_common
    ${PROFILING_LIBS}
    ${POLARSSL_LIBRARIES}
-   ${WIN_EXTRA_LIBS})
+   ${WIN_EXTRA_LIBS}
+   ${LIBC_STATIC}
+   pthread
+   )
 
 install(TARGETS cinst DESTINATION bin)
 if (WIN32)


More information about the Trustbridge-commits mailing list