mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Build System: Improve ccache matching for different menuselect options.
Changing any Menuselect option in the `Compiler Flags` section causes a full rebuild of the Asterisk source tree. Every enabled option causes a #define to be added to buildopts.h, thus breaking ccache caching for every source file that includes "asterisk.h". In most cases each option only applies to one or two files. Now we only define those options for the specific sources which use them, this causes much better cache matching when working with multiple builds. For example testing code with an without MALLOC_DEBUG will now use just over half the ccache size, only main/astmm.o will have two builds cached instead of every file. Reorder main/Makefile so _ASTCFLAGS set on specific object files are all together, sorted by filename. Stop adding -DMALLOC_DEBUG to CFLAGS of bundled pjproject, this define is no longer used by any header so only serves to break cache. The only code change is a slight adjustment to how main/astmm.c is initialized. Initialization functions always exist so main/asterisk.c can call them unconditionally. Additionally rename the astmm initialization functions so they are not exported. Change-Id: Ie2085237a964f6e1e6fff55ed046e2afff83c027
This commit is contained in:
29
main/astmm.c
29
main/astmm.c
@@ -31,6 +31,7 @@
|
||||
#define ASTMM_LIBC ASTMM_IGNORE
|
||||
#include "asterisk.h"
|
||||
|
||||
#include "asterisk/_private.h"
|
||||
#include "asterisk/logger.h"
|
||||
|
||||
/*!
|
||||
@@ -62,6 +63,10 @@
|
||||
#define ast_log_safe ast_log
|
||||
#endif
|
||||
|
||||
#if defined(MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2)
|
||||
#define __AST_DEBUG_MALLOC
|
||||
#endif
|
||||
|
||||
#define MALLOC_FAILURE_MSG \
|
||||
ast_log_safe(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file)
|
||||
|
||||
@@ -1501,14 +1506,7 @@ static void mm_atexit_final(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Initialize malloc debug phase 1.
|
||||
*
|
||||
* \note Must be called first thing in main().
|
||||
*
|
||||
* \return Nothing
|
||||
*/
|
||||
void __ast_mm_init_phase_1(void)
|
||||
void load_astmm_phase_1(void)
|
||||
{
|
||||
atexit(mm_atexit_final);
|
||||
}
|
||||
@@ -1522,12 +1520,7 @@ static void mm_atexit_ast(void)
|
||||
ast_cli_unregister_multiple(cli_memory, ARRAY_LEN(cli_memory));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Initialize malloc debug phase 2.
|
||||
*
|
||||
* \return Nothing
|
||||
*/
|
||||
void __ast_mm_init_phase_2(void)
|
||||
void load_astmm_phase_2(void)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
|
||||
@@ -1550,6 +1543,14 @@ void __ast_mm_init_phase_2(void)
|
||||
|
||||
#else /* !defined(__AST_DEBUG_MALLOC) */
|
||||
|
||||
void load_astmm_phase_1(void)
|
||||
{
|
||||
}
|
||||
|
||||
void load_astmm_phase_2(void)
|
||||
{
|
||||
}
|
||||
|
||||
void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
|
||||
{
|
||||
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
|
||||
|
Reference in New Issue
Block a user