Fix build on FreeBSD

FreeBSD defines environ in crt1.o, so allow undefined symbols when
linking libraries to fix libutil build.
Also set defines in libutil to fix boost headers.

Change-Id: I094b8ac97469b26fd5d096617a58d7fd279103ae
This commit is contained in:
Artemis Tosini 2024-05-13 01:01:45 +00:00
parent dd53bce476
commit 6a945e1d2b
Signed by: artemist
SSH key fingerprint: SHA256:w028LIB8Jqsri7H2uJ7RimKalF++o2LsV9iqq2QMpSE
3 changed files with 9 additions and 2 deletions

View file

@ -138,6 +138,7 @@ message('canonical Nix system name:', host_system)
is_linux = host_machine.system() == 'linux'
is_darwin = host_machine.system() == 'darwin'
is_freebsd = host_machine.system() == 'freebsd'
is_x64 = host_machine.cpu_family() == 'x86_64'
# Per-platform arguments that you should probably pass to shared_module() invocations.
@ -454,6 +455,12 @@ if cxx.get_linker_id() in ['ld.bfd', 'ld.gold']
add_project_link_arguments('-Wl,--no-copy-dt-needed-entries', language : 'cpp')
endif
if is_freebsd
# FreeBSD's `environ` is defined in `crt1.o`, not `libc.so`.
#
add_project_link_arguments('-Wl,-z,undefs', language: 'cpp')
endif
# Generate Chromium tracing files for each compiled file, which enables
# maintainers/buildtime_report.sh BUILD-DIR to simply work in clang builds.
#

View file

@ -27,7 +27,7 @@ stdenv.mkDerivation (finalAttrs: {
platforms = lib.platforms.unix;
# `long long int` != `size_t`
# There's no convenient lib.platforms.32bit or anything, but it's easy enough to do ourselves.
badPlatforms = lib.filter (plat: (lib.systems.elaborate plat).is32bit) lib.platforms.all;
badPlatforms = (lib.filter (plat: (lib.systems.elaborate plat).is32bit) lib.platforms.all) ++ lib.platforms.freebsd;
mainProgram = "ClangBuildAnalyzer";
};
})

View file

@ -6,7 +6,7 @@
#include <optional>
#include <boost/format.hpp>
// Darwin stdenv does not define _GNU_SOURCE but does have _Unwind_Backtrace.
#ifdef __APPLE__
#if __APPLE__ || __FreeBSD__
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
#endif
#include <boost/stacktrace.hpp>