Nixpkgs: GNAT Invalid command line option, can't compile Ada code

Created on 18 Oct 2017  路  5Comments  路  Source: NixOS/nixpkgs

Issue description

Compiling a trivial Ada application fails due to invalid command line options added by some nix-specific wrapper scripts.

In other Linux distributions 'gnatmake' is a binary file, in nix however it`s a wrapper script.

Steps to reproduce

$ gnatmake hello.adb 
gcc -c -I/nix/store/2dam02rdvc2bp5ghcd7x8ivrd2dwsl3p-gnat-4.5.4/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/adainclude hello.adb
/nix/store/w7n604zqlncab02gxyf5kld19wl5v8k6-gnat-wrapper-4.5.4/bin/gnatbind -aI/nix/store/2dam02rdvc2bp5ghcd7x8ivrd2dwsl3p-gnat-4.5.4/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/adainclude -aO/nix/store/2dam02rdvc2bp5ghcd7x8ivrd2dwsl3p-gnat-4.5.4/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/adalib -x hello.ali
/nix/store/w7n604zqlncab02gxyf5kld19wl5v8k6-gnat-wrapper-4.5.4/bin/gnatlink hello.ali
gnat1: warning: command line option "-Wformat" 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: error: unrecognized command line option "-fstack-protector-strong"
gnatmake: *** link failed.

where 'hello.adb' is a simple "hello world" program with the following contents:

with Ada.Text_IO;

procedure Hello is
begin
  Ada.Text_IO.Put_Line("Hello");
end;

Technical details

  • System:
$ nixos-version 
17.09.1756.c99239bca0 (Hummingbird)
  • Nix version:
$ nix-env --version
nix-env (Nix) 1.11.15
  • Nixpkgs version:
$ nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion
"17.09.1756.c99239bca0"
  • Sandboxing enabled:
$ grep build-use-sandbox /etc/nix/nix.conf
build-use-sandbox = false
bug regression stale

Most helpful comment

TL;DR: work around via export hardeningDisable=all

All 5 comments

Additional information
As can be seen in the trail below it's the hardning script that adds the invalid command line options.

/nix/store/w7n604zqlncab02gxyf5kld19wl5v8k6-gnat-wrapper-4.5.4/bin/gnatlink
extraAfter=("--GCC=/nix/store/w7n604zqlncab02gxyf5kld19wl5v8k6-gnat-wrapper-4.5.4/bin/gcc")

/nix/store/w7n604zqlncab02gxyf5kld19wl5v8k6-gnat-wrapper-4.5.4/bin/gcc
source /nix/store/w7n604zqlncab02gxyf5kld19wl5v8k6-gnat-wrapper-4.5.4/nix-support/add-hardening.sh

/nix/store/w7n604zqlncab02gxyf5kld19wl5v8k6-gnat-wrapper-4.5.4/nix-support/add-hardening.sh
hardeningFlags=(fortify stackprotector pic strictoverflow format relro bindnow)

In nixpkgs these files are:

nixpkgs/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh
nixpkgs/pkgs/build-support/cc-wrapper/cc-wrapper.sh
nixpkgs/pkgs/build-support/cc-wrapper/add-hardening.sh

TL;DR: work around via export hardeningDisable=all

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

Our default gnat is in version 9 now, so these errors shouldn't happen. To be sure, gnatmake hello.adb works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

lverns picture lverns  路  3Comments

yawnt picture yawnt  路  3Comments

langston-barrett picture langston-barrett  路  3Comments

grahamc picture grahamc  路  3Comments