mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1908630 - Override LLVM Profiling for manual handling r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D218428
This commit is contained in:
parent
c925cf6a17
commit
bf4989dfb6
@ -15,11 +15,24 @@ def Binary():
|
||||
OS_LIBS += ["log"]
|
||||
|
||||
|
||||
@template
|
||||
def MaybeAddProfiling(name):
|
||||
if (
|
||||
CONFIG["MOZ_ENABLE_FORKSERVER"]
|
||||
and CONFIG["NIGHTLY_BUILD"]
|
||||
and CONFIG["OS_TARGET"] == "Linux"
|
||||
and CONFIG["MOZ_PROFILE_GENERATE"] == "1"
|
||||
):
|
||||
USE_LIBS += ["profiling"]
|
||||
|
||||
|
||||
@template
|
||||
def Program(name):
|
||||
"""Template for program executables."""
|
||||
PROGRAM = name
|
||||
|
||||
MaybeAddProfiling(name)
|
||||
|
||||
Binary()
|
||||
|
||||
|
||||
@ -126,6 +139,8 @@ def SharedLibrary(name, output_category=None):
|
||||
if output_category:
|
||||
SHARED_LIBRARY_OUTPUT_CATEGORY = output_category
|
||||
|
||||
MaybeAddProfiling(name)
|
||||
|
||||
Binary()
|
||||
|
||||
|
||||
|
@ -6,3 +6,11 @@
|
||||
|
||||
if CONFIG["USE_ELF_HACK"] or CONFIG["RELRHACK"]:
|
||||
DIRS += ["elfhack"]
|
||||
|
||||
if (
|
||||
CONFIG["MOZ_ENABLE_FORKSERVER"]
|
||||
and CONFIG["NIGHTLY_BUILD"]
|
||||
and CONFIG["OS_TARGET"] == "Linux"
|
||||
and CONFIG["MOZ_PROFILE_GENERATE"] == "1"
|
||||
):
|
||||
DIRS += ["profiling"]
|
||||
|
9
build/unix/profiling/moz.build
Normal file
9
build/unix/profiling/moz.build
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Library("profiling")
|
||||
|
||||
SOURCES += ["profiling.cpp"]
|
45
build/unix/profiling/profiling.cpp
Normal file
45
build/unix/profiling/profiling.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#if defined(MOZ_PROFILE_GENERATE) && defined(XP_LINUX) && !defined(ANDROID)
|
||||
|
||||
# include <pthread.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
|
||||
# if defined(__cplusplus)
|
||||
extern "C" {
|
||||
# endif
|
||||
void __llvm_profile_initialize(void);
|
||||
void __llvm_profile_initialize_file(void);
|
||||
void __llvm_profile_set_filename(const char*);
|
||||
|
||||
// Use the API to force a different filename, then set back the original one.
|
||||
// This will make sure the pattern is re-parsed and thus the PID properly
|
||||
// updated within the lprofCurFilename struct.
|
||||
static void updateFilenameAfterFork(void) {
|
||||
__llvm_profile_set_filename("default.profraw");
|
||||
__llvm_profile_initialize_file();
|
||||
__llvm_profile_set_filename(getenv("LLVM_PROFILE_FILE"));
|
||||
__llvm_profile_initialize_file();
|
||||
}
|
||||
|
||||
static int CustomRegisterRuntime(void) {
|
||||
__llvm_profile_initialize();
|
||||
|
||||
if (pthread_atfork(NULL, NULL, updateFilenameAfterFork) < 0) {
|
||||
fprintf(stderr, "[%d] [%s] pthread_atfork()=%d\n", getpid(),
|
||||
__PRETTY_FUNCTION__, errno);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_RUNINIT int __llvm_profile_runtime = CustomRegisterRuntime();
|
||||
# if defined(__cplusplus)
|
||||
}
|
||||
# endif
|
||||
#endif // defined(MOZ_PROFILE_GENERATE) && defined(XP_LINUX) &&
|
||||
// !defined(ANDROID)
|
@ -3013,7 +3013,7 @@
|
||||
#ifdef MOZ_ENABLE_FORKSERVER
|
||||
- name: dom.ipc.forkserver.enable
|
||||
type: bool
|
||||
#if defined(MOZ_CODE_COVERAGE) || defined(MOZ_ASAN) || defined(MOZ_TSAN) || defined(MOZ_MSAN) || defined(MOZ_UBSAN) || defined(MOZ_PROFILE_GENERATE)
|
||||
#if defined(MOZ_CODE_COVERAGE) || defined(MOZ_ASAN) || defined(MOZ_TSAN) || defined(MOZ_MSAN) || defined(MOZ_UBSAN)
|
||||
value: false
|
||||
#else
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
|
@ -17,7 +17,7 @@ using mozilla::DebugOnly;
|
||||
#if defined(MOZ_ENABLE_FORKSERVER) && !defined(MOZ_TSAN)
|
||||
# include "mozilla/pthread_atfork.h"
|
||||
|
||||
static constexpr const int maxHandlers = 16;
|
||||
static constexpr const int maxHandlers = 32;
|
||||
static constexpr const int idxPreFork = 0;
|
||||
static constexpr const int idxPostForkParent = 1;
|
||||
static constexpr const int idxPostForkChild = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user