Skip to content

Commit

Permalink
build: add official build flag
Browse files Browse the repository at this point in the history
- libcxx: try using __builtin_trap for official build
  • Loading branch information
Chilledheart committed Jul 29, 2024
1 parent 6d8bf7d commit bd36dce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(YASS_APP_FEATURES)

option(OFFICIAL_BUILD "Build with official build" OFF)

if (OFFICIAL_BUILD)
list(APPEND YASS_APP_FEATURES "official-build")
add_definitions(-DOFFICIAL_BUILD)
endif()

if(MSVC)
# On Windows, prefer cl over gcc if both are available. By default most of
# the CMake generators prefer gcc, even on Windows.
Expand Down
21 changes: 19 additions & 2 deletions third_party/libc++/__assertion_handler
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,24 @@
# pragma GCC system_header
#endif

// TODO(hardening): in production, trap rather than abort.
#define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message)
// Based on CHECK_WILL_STREAM() defined in base/check.h
#if defined(NDEBUG) && defined(OFFICIAL_BUILD)

_LIBCPP_BEGIN_NAMESPACE_STD

_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __libcpp_hardening_failure() {
__builtin_trap();
}

_LIBCPP_END_NAMESPACE_STD

// TODO(hardening): use `__builtin_verbose_trap(message)` once that becomes available.
# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, ::std::__libcpp_hardening_failure())

#else

# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message)

#endif // defined(NDEBUG) && defined(OFFICIAL_BUILD)

#endif // _LIBCPP___ASSERTION_HANDLER
1 change: 1 addition & 0 deletions tools/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ func buildStageGenerateBuildScript() {
glog.Infof("Using compiler %s", _clangPath)
}
}
cmakeArgs = append(cmakeArgs, "-DOFFICIAL_BUILD=on")
cmakeArgs = append(cmakeArgs, "-DENABLE_LLD=on")
cmakeArgs = append(cmakeArgs, "-DGUI=ON", "-DCLI=ON", "-DSERVER=ON")
cmakeArgs = append(cmakeArgs, fmt.Sprintf("-DCMAKE_BUILD_TYPE=%s", cmakeBuildTypeFlag))
Expand Down

0 comments on commit bd36dce

Please sign in to comment.