Created
April 30, 2021 02:34
-
-
Save AshyIsMe/471f01920af2dc4349a7fb72ea3e8762 to your computer and use it in GitHub Desktop.
gcc9 in nix-shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
pkgs.mkShell { | |
buildInputs = [ | |
pkgs.gcc9 | |
pkgs.gmp | |
pkgs.primesieve | |
]; | |
} | |
# Usage: | |
# nix-shell gcc-env.nix | |
# gcc foo.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <primesieve.h> | |
int main() { | |
printf("primesieve version %s\n", PRIMESIEVE_VERSION); | |
printf("compiler version %s\n", __VERSION__); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This seems a bit hacky but it gets around the `nix-shell -p gcc9 --run 'gcc --version' => 'gcc 10.x...'` problem | |
nix-shell gcc-env.nix | |
nix run nixpkgs.gcc9 | |
gcc --version | |
# gcc (GCC) 9.3.0 | |
# Copyright (C) 2019 Free Software Foundation, Inc. | |
# This is free software; see the source for copying conditions. There is NO | |
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
gcc primesieve.c | |
./a.out | |
# primesieve version 7.6 | |
# compiler version 9.3.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment