Skip to content

Commit 07c4056

Browse files
committed
gnats: format hardened flag isn't supported
When invoking a simple Ada program with `gcc` from `gnats10`, the following warnings are shown: ``` $ gcc -c conftest.adb gnat1: warning: command-line option ‘-Wformat=1’ is valid for C/C++/ObjC/ObjC++ but not for Ada gnat1: warning: command-line option ‘-Wformat-security’ is valid for C/C++/ObjC/ObjC++ but not for Ada gnat1: warning: ‘-Werror=’ argument ‘-Werror=format-security’ is not valid for Ada $ echo $? 0 ``` This is only spammy when compiling Ada programs inside a Nix derivation, but certain configure scripts (such as the ./configure script from the gcc that's built by coreboot's `make crossgcc` command) fail entirely when getting that warning output. https://nixos.wiki/wiki/Coreboot currently suggests manually running > NIX_HARDENING_ENABLE="${NIX_HARDENING_ENABLE/ format/}" make crossgcc … but actually teaching the nixpkgs-provided cc wrapper that `format` isn't supported as a hardening flag seems to be the more canonical way to do this in nixpgks. After this, Ada programs still compile: ``` $ gcc -c conftest.adb $ echo $? 0 ``` And the compiler output is empty.
1 parent 9232d41 commit 07c4056

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pkgs/build-support/cc-wrapper/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ stdenv.mkDerivation {
437437
'' + optionalString targetPlatform.isNetBSD ''
438438
hardening_unsupported_flags+=" stackprotector fortify"
439439
'' + optionalString cc.langAda or false ''
440-
hardening_unsupported_flags+=" stackprotector strictoverflow"
440+
hardening_unsupported_flags+=" format stackprotector strictoverflow"
441441
'' + optionalString cc.langD or false ''
442442
hardening_unsupported_flags+=" format"
443443
'' + optionalString targetPlatform.isWasm ''

0 commit comments

Comments
 (0)