diff options
| author | Nat Goodspeed <nat@lindenlab.com> | 2017-09-19 15:35:08 -0400 | 
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2017-09-19 15:35:08 -0400 | 
| commit | eae144219c3ab2ca0fc724021eec32225065a006 (patch) | |
| tree | 3f2fa0ffa9a72a9b858630ba701cc0e0220aeba2 | |
| parent | 0e9fb587fa267a296183b0d2093700e5fb53c950 (diff) | |
DRTVWR-418: Another attempt to generate Mac debug symbols.
The viewer's 00-COMPILE-LINK-RUN.txt recommends passing -gdwarf-2 to the Mac
compiler, and so we've been doing ever since before the viewer-build-variables
repo was engaged. Now we discover that when CMake sees -gdwarf-2, it removes
the -g switch entirely. It also removes it when you pass plain -g. Only when
you pass -gdwarf-with-dsym or just -gdwarf does CMake pass plain -g to the
compiler. Change -gdwarf-2, if specified, to -gdwarf so we at least get -g.
| -rw-r--r-- | indra/cmake/00-Common.cmake | 8 | ||||
| -rw-r--r-- | indra/cmake/Variables.cmake | 14 | 
2 files changed, 19 insertions, 3 deletions
| diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index b582b47f15..40fc706a99 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -19,9 +19,7 @@ set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES")  include(Variables)  # We go to some trouble to set LL_BUILD to the set of relevant compiler flags. -set(CMAKE_CXX_FLAGS_RELEASE "$ENV{LL_BUILD_RELEASE}") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "$ENV{LL_BUILD_RELWITHDEBINFO}") -set(CMAKE_CXX_FLAGS_DEBUG "$ENV{LL_BUILD_DEBUG}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{LL_BUILD}")  # Given that, all the flags you see added below are flags NOT present in  # https://bitbucket.org/lindenlab/viewer-build-variables/src/tip/variables.  # Before adding new ones here, it's important to ask: can this flag really be @@ -156,6 +154,10 @@ if (DARWIN)    set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")    set(DARWIN_extra_cstar_flags "-Wno-unused-local-typedef -Wno-deprecated-declarations") +  # Ensure that CMAKE_CXX_FLAGS has the correct -g debug information format -- +  # see Variables.cmake. +  string(REPLACE "-gdwarf-2" "-g${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}" +    CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")    # The viewer code base can now be successfully compiled with -std=c++14. But    # turning that on in the generic viewer-build-variables/variables file would    # potentially require tweaking each of our ~50 third-party library builds. diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index e8698ace68..bd69c49856 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -155,6 +155,20 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")    string(REGEX MATCH " -g([^ ]*)" scratch "$ENV{LL_BUILD}")    set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "${CMAKE_MATCH_1}") +  # -gdwarf-2 is passed in LL_BUILD according to 00-COMPILE-LINK-RUN.txt. +  # However, when CMake 3.9.2 sees -gdwarf-2, it silently deletes the whole -g +  # switch, producing no symbols at all! The same thing happens if we specify +  # plain -g ourselves, i.e. CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT is +  # the empty string. Specifying -gdwarf-with-dsym or just -gdwarf drives a +  # different CMake behavior: it substitutes plain -g. As of 2017-09-19, +  # viewer-build-variables/variables still passes -gdwarf-2, which is the +  # no-symbols case. Set -gdwarf, triggering CMake to substitute plain -g -- +  # at least that way we should get symbols, albeit mangled ones. It Would Be +  # Nice if CMake's behavior could be predicted from a consistent mental +  # model, instead of only observed experimentally. +  string(REPLACE "dwarf-2" "dwarf" +    CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT +    "${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}")    message(STATUS "CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT = '${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}'")    string(REGEX MATCH "-O([^ ]*)" scratch "$ENV{LL_BUILD}") | 
