vim: enable fortify when using clang

Our vim derivations have been disabling fortify for 10 years, due to a
crash at the time that had yet to be fixed upstream. The vim configure
script tries to strip out any `_FORTIFY_SOURCE` definition provided by
the caller in favor of setting `-D_FORTIFY_SOURCE=1` itself and cites a
crash introduced in gcc 4.0 as the reason, but our MacVim package has
been running with fortify enabled without any known issues. After
testing it seems that compiling vim with clang works just fine with
fortify, but compiling it with gcc detects a buffer overflow and aborts.

We do still need to disable `strictflexarrays1` though, as vim's
`ufunc_S` struct ends with a `uf_name[4]` field that is treated as a
flexible array with a minimum length of 4.
This commit is contained in:
Lily Ballard
2026-04-04 20:22:01 -07:00
parent c85d1f0779
commit 4a1a222f73
3 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -1,4 +1,8 @@
{ lib, fetchFromGitHub }:
{
lib,
fetchFromGitHub,
stdenv,
}:
rec {
version = "9.2.0106";
@@ -17,7 +21,7 @@ rec {
enableParallelBuilding = true;
enableParallelInstalling = false;
hardeningDisable = [ "fortify" ];
hardeningDisable = if stdenv.cc.isClang then [ "strictflexarrays1" ] else [ "fortify" ];
# Use man from $PATH; escape sequences are still problematic.
postPatch = ''
+1 -1
View File
@@ -17,7 +17,7 @@
}:
let
common = callPackage ./common.nix { };
common = callPackage ./common.nix { inherit stdenv; };
in
stdenv.mkDerivation {
pname = "vim";
+1 -1
View File
@@ -81,7 +81,7 @@ let
endif
'';
common = callPackage ./common.nix { };
common = callPackage ./common.nix { inherit stdenv; };
in
stdenv.mkDerivation {