While running pulseaudio out of build dir (especially for cross compiling), we should not expose pulseaudio build path[1], it is helpful for reproducibility build[2]. As commit introduced [3cae4a0 doc: Add info about running pulseaudio from the build dir], run pulseaudio from the build dir, __OPTIMIZE__ should be diabled, so add macro checking to drop PA_SRCDIR/PA_BUILDDIR (in which contains build path) at precompilation. [1] https://reproducible-builds.org/docs/build-path/ [2] https://reproducible-builds.org/ Signed-off-by: Hongxu Jia <hongxu.jia@xxxxxxxxxxxxx> --- src/daemon/daemon-conf.c | 6 ++++-- src/modules/alsa/alsa-mixer.c | 4 ++++ src/pulsecore/core-util.c | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index f956a55..ba3ab6e 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -155,16 +155,18 @@ pa_daemon_conf *pa_daemon_conf_new(void) { c->dl_search_path = pa_sprintf_malloc("%s" PA_PATH_SEP "lib" PA_PATH_SEP "pulse-%d.%d" PA_PATH_SEP "modules", pa_win32_get_toplevel(NULL), PA_MAJOR, PA_MINOR); #else +#if !defined(__OPTIMIZE__) if (pa_run_from_build_tree()) { pa_log_notice("Detected that we are run from the build tree, fixing search path."); #ifdef MESON_BUILD c->dl_search_path = pa_xstrdup(PA_BUILDDIR PA_PATH_SEP "src" PA_PATH_SEP "modules"); #else c->dl_search_path = pa_xstrdup(PA_BUILDDIR); -#endif +#endif // Endof #ifdef MESON_BUILD } else +#endif // Endof #if !defined(__OPTIMIZE__) c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH); -#endif +#endif // Endof #ifdef OS_IS_WIN32 return c; } diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 7d50fc7..e1f9361 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -2573,9 +2573,11 @@ static int path_verify(pa_alsa_path *p) { } static const char *get_default_paths_dir(void) { +#if defined(__linux__) && !defined(__OPTIMIZE__) if (pa_run_from_build_tree()) return PA_SRCDIR "/modules/alsa/mixer/paths/"; else +#endif return PA_ALSA_PATHS_DIR; } @@ -4458,7 +4460,9 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel fname = "default.conf"; fn = pa_maybe_prefix_path(fname, +#if defined(__linux__) && !defined(__OPTIMIZE__) pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" : +#endif PA_ALSA_PROFILE_SETS_DIR); r = pa_config_parse(fn, NULL, items, NULL, false, ps); diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 367e767..b7d352b 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -3269,15 +3269,17 @@ void pa_reset_personality(void) { } bool pa_run_from_build_tree(void) { - char *rp; static bool b = false; +#if defined(__linux__) && !defined(__OPTIMIZE__) + char *rp; PA_ONCE_BEGIN { if ((rp = pa_readlink("/proc/self/exe"))) { b = pa_startswith(rp, PA_BUILDDIR); pa_xfree(rp); } } PA_ONCE_END; +#endif return b; } -- 2.7.4 _______________________________________________ pulseaudio-discuss mailing list pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss