meson: Configure with -Db_lundef=false on FreeBSD

Meson sets a default for all platforms which is -Db_lundef=true, meaning
always add the --no-undefined flag to linker invocations. This is a
consistently bad idea on FreeBSD, since the `environ` variable is
provided not by libc but by the csu, leading to the linker complaining
whenever it is used.
This commit is contained in:
Audrey Dutcher 2025-03-05 22:48:59 -07:00
parent daad8c8069
commit e27c288c0b
3 changed files with 6 additions and 1 deletions

View File

@ -249,7 +249,6 @@ stdenv.mkDerivation (finalAttrs: {
"-Dlibelf=disabled"
]
++ lib.optionals stdenv.hostPlatform.isFreeBSD [
"-Db_lundef=false"
"-Dxattr=false"
"-Dsysprof=disabled" # sysprof-capture does not build on FreeBSD
];

View File

@ -144,6 +144,7 @@ python3.pkgs.buildPythonApplication rec {
'';
setupHook = ./setup-hook.sh;
env.hostPlatform = stdenv.targetPlatform.system;
meta = {
homepage = "https://mesonbuild.com";

View File

@ -26,6 +26,11 @@ mesonConfigurePhase() {
"--buildtype=${mesonBuildType:-plain}"
)
# --no-undefined is universally a bad idea on freebsd because environ is in the csu
if [[ "@hostPlatform@" == *-freebsd ]]; then
flagsArray+=("-Db_lundef=false")
fi
concatTo flagsArray mesonFlags mesonFlagsArray
echoCmd 'mesonConfigurePhase flags' "${flagsArray[@]}"