ãã®è¨äºã¯ 第2のドワンゴ Advent Calendar 2016 - Qiita ã® 7 æ¥ç® (空ãã¦ããã®ã§é£ã³è¾¼ãã ã®ã¯ 10 æ¥ç®ã§ãã) ã§ãã
ããªããã»ããµããã³ãã¬ã¼ããé§ä½¿ãã C++ ãããã g++ ã§ã³ã³ãã¤ã«ããæã§ãã¾ã«çºçãã string table overflow ãã...ã
-g ããããã°ã·ã³ãã«ãæ®ãã¦ããããªã®ãã-g ãåãé¤ãã°å¤§ä¸å¤«ãããã®ã ããCMake ã®ã³ã³ãã¤ã«ãã©ã°ãã -g ãåãé¤ãã®ã«ã¡ããã¨è¦å´ããã
æåã« CMakeLists.txt å ã§
set(CMAKE_CXX_FLAGS "")
ã¨ã
set(ENV{CXXFLAGS} "")
ã§ä¸æ¸ããã¦ã¿ããã®ã®å ¨ç¶æ¶ãã¦ãããªãã
cygport ããå¼ã³åºãã¦ããã®ã§ cmake.cygclass ãè¦ã¦ã¿ãããããããã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ã«ç´æ¥æ¸¡ãã¦ãã
cmake -Wno-dev \ ${cmdir} \ -DCMAKE_BINARY_DIR=. \ -DCMAKE_BUILD_TYPE=${buildtype} \ -DCMAKE_C_COMPILER=$(which ${CC}${exeext}) \ -DCMAKE_C_FLAGS="${CFLAGS} ${CPPFLAGS}" \ -DCMAKE_CXX_COMPILER=$(which ${CXX}${exeext}) \ -DCMAKE_CXX_FLAGS="${CXXFLAGS} ${CPPFLAGS}" \ -DCMAKE_Fortran_COMPILER=$(which ${FC}${exeext}) \ -DCMAKE_Fortran_FLAGS="${FCFLAGS} ${CPPFLAGS}" \ -DCMAKE_AR=$(which ${AR}${exeext}) \ -DCMAKE_RANLIB=$(which ${RANLIB}${exeext}) \ -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" \ -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ -DCMAKE_INSTALL_PREFIX=$(__host_prefix) \ -DCMAKE_LEGACY_CYGWIN_WIN32=0 \ ${crossargs} \ "${@}" \ ${CYGCMAKE_ARGS} \ || error "cmake failed"cygport/cmake.cygclass at master · cygwinports/cygport · GitHub
ãªã®ã§ cmake å¼ã³åºãåã« cygport ã®è¨å®ãã¡ã¤ã«ã®æ¹ã§
CXXFLAGS=""
ã®ããã«ç¡å¹åãã¦ã¿ããã¾ã æ¶ããªãã
ããã« cmake.cygclass ãããè¦ãã¨
if defined _CYGPORT_RESTRICT_debuginfo_ then buildtype=Release else buildtype=RelWithDebInfo ficygport/cmake.cygclass at master · cygwinports/cygport · GitHub
ã¨ãã£ã¦ãCMake ã®ããã©ã«ãè¨å®ãè¦ãã¨
$ cmake --system-information | grep CMAKE_CXX_FLAGS | grep -e '==' CMAKE_CXX_FLAGS == "" CMAKE_CXX_FLAGS_DEBUG == "-g" CMAKE_CXX_FLAGS_MINSIZEREL == "-Os -DNDEBUG" CMAKE_CXX_FLAGS_RELEASE == "-O3 -DNDEBUG" CMAKE_CXX_FLAGS_RELWITHDEBINFO == "-O2 -g -DNDEBUG"
ã¨ãªã£ã¦ããã®ã§ Release ã«ãªãããã«
_CYGPORT_RESTRICT_debuginfo_=1 # cygport å ã§ã¯ RESTRICT="debuginfo" ã§åçã®å¹æããã
ãããã¨ã§ãããã -g ãæ¶ããã
CMake ã使ãæ㯠(CMake ã«éã£ããã¨ã§ã¯ãªãã§ãã) ãªãã·ã§ã³ã¨ç°å¢å¤æ°ããã¡ãã¨ç¢ºèªãã¾ãããã