From f9d08cc44c615606186d65fe2e500d10488bf8e4 Mon Sep 17 00:00:00 2001 From: Qyriad Date: Wed, 17 Apr 2024 23:37:07 -0600 Subject: [PATCH] meson: embed source paths as relative to the source root and avoid ../src Change-Id: Ifab83cb7a3bfde717a4d6032ede8be75dc61f2b1 --- meson.build | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/meson.build b/meson.build index f62e93d0c..0c0bfb8f0 100644 --- a/meson.build +++ b/meson.build @@ -413,6 +413,21 @@ if get_option('profile-build').require(meson.get_compiler('cpp').get_id() == 'cl add_project_arguments('-ftime-trace', language: 'cpp') endif +if cxx.get_id() in ['clang', 'gcc'] + add_project_arguments([ + # Meson uses out of source builds, conventionally usually in a subdirectory + # of the source tree (e.g. meson setup ./build). This means that unlike in + # the previous Make buildsystem, all compilation sources are passed as a relative + # parent, e.g. `cc -o src/libexpr/nixexpr.cc.o ../src/libexpr/nixexpr.cc`. + # These paths show up when debugging, and in asserts, which look both look strange + # and confuse debuggers. + # So let's just tell GCC and Clang that ../src really means src. + '-ffile-prefix-map=../src=src', + ], + language : 'cpp', + ) +endif + subdir('src') subdir('scripts') subdir('misc')