Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions nix-meson-build-support/common/asan-options/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ endif
if 'address' in get_option('b_sanitize')
deps_other += declare_dependency(sources : 'asan-options.cc')
endif

if 'undefined' in get_option('b_sanitize')
add_project_arguments('-DNIX_UBSAN_ENABLED=1', language : 'cpp')
else
add_project_arguments('-DNIX_UBSAN_ENABLED=0', language : 'cpp')
endif
3 changes: 2 additions & 1 deletion src/libutil/include/nix/util/error.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "nix/util/suggestions.hh"
#include "nix/util/fmt.hh"
#include "nix/util/config.hh"

#include <cstring>
#include <list>
Expand Down Expand Up @@ -350,7 +351,7 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
*/
[[gnu::noinline, gnu::cold, noreturn]] void unreachable(std::source_location loc = std::source_location::current());

#if NIX_UBSAN_ENABLED == 1
#if NIX_UBSAN_ENABLED
/* When building with sanitizers, also enable expensive unreachable checks. In
optimised builds this explicitly invokes UB with std::unreachable for better
optimisations. */
Expand Down
7 changes: 6 additions & 1 deletion src/libutil/include/nix/util/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

include_dirs = [ include_directories('../..') ]

headers = files(
config_pub_h = configure_file(
configuration : configdata_pub,
output : 'config.hh',
)

headers = [ config_pub_h ] + files(
'abstract-setting-to-json.hh',
'alignment.hh',
'ansicolor.hh',
Expand Down
15 changes: 11 additions & 4 deletions src/libutil/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ cxx = meson.get_compiler('cpp')

subdir('nix-meson-build-support/deps-lists')

configdata = configuration_data()
configdata_pub = configuration_data()
configdata_priv = configuration_data()

deps_private_maybe_subproject = []
deps_public_maybe_subproject = []
Expand All @@ -34,9 +35,15 @@ check_funcs = [
foreach funcspec : check_funcs
define_name = 'HAVE_' + funcspec[0].underscorify().to_upper()
define_value = cxx.has_function(funcspec[0]).to_int()
configdata.set(define_name, define_value, description : funcspec[1])
configdata_priv.set(define_name, define_value, description : funcspec[1])
endforeach

configdata_pub.set(
'NIX_UBSAN_ENABLED',
('undefined' in get_option('b_sanitize')).to_int(),
description : 'Whether nix has been built with UBSan enabled',
)

subdir('nix-meson-build-support/libatomic')

if host_machine.system() == 'windows'
Expand Down Expand Up @@ -104,7 +111,7 @@ cpuid = dependency(
version : '>= 0.7.0',
required : cpuid_required,
)
configdata.set('HAVE_LIBCPUID', cpuid.found().to_int())
configdata_priv.set('HAVE_LIBCPUID', cpuid.found().to_int())
deps_private += cpuid

nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
Expand All @@ -113,7 +120,7 @@ deps_public += nlohmann_json
cxx = meson.get_compiler('cpp')

config_priv_h = configure_file(
configuration : configdata,
configuration : configdata_priv,
output : 'util-config-private.hh',
)

Expand Down