read-edid: fix build on -fno-common toolchains

Without the change build fails on toolchains like clang-13 which
switch to -fno-common by default:

    $ nix build -L --impure --expr 'with import ./. {}; read-edid.override { stdenv = clang13Stdenv; }'
    ...
    read-edid> ld: CMakeFiles/get-edid.dir/classic.c.o:(.bss+0x0):
      multiple definition of `quiet'; CMakeFiles/get-edid.dir/get-edid.c.o:(.bss+0x0): first defined here
    read-edid> ld: CMakeFiles/get-edid.dir/i2c.c.o:(.bss+0x0):
      multiple definition of `quiet'; CMakeFiles/get-edid.dir/get-edid.c.o:(.bss+0x0): first defined here
main
Sergei Trofimovich 2 years ago
parent bb074513be
commit 6b75fe0638
  1. 9
      pkgs/os-specific/linux/read-edid/default.nix
  2. 22
      pkgs/os-specific/linux/read-edid/fno-common.patch

@ -9,14 +9,17 @@ stdenv.mkDerivation rec {
sha256 = "0vqqmwsgh2gchw7qmpqk6idgzcm5rqf2fab84y7gk42v1x2diin7";
};
patches = [ ./fno-common.patch ];
postPatch = ''
substituteInPlace CMakeLists.txt --replace 'COPYING' 'LICENSE'
'';
nativeBuildInputs = [ cmake ];
buildInputs = lib.optional stdenv.hostPlatform.isx86 libx86;
cmakeFlags = [ "-DCLASSICBUILD=${if stdenv.hostPlatform.isx86 then "ON" else "OFF"}" ];
patchPhase = ''
substituteInPlace CMakeLists.txt --replace 'COPYING' 'LICENSE'
'';
meta = with lib; {
description = "Tool for reading and parsing EDID data from monitors";

@ -0,0 +1,22 @@
--- a/get-edid/classic.c
+++ b/get-edid/classic.c
@@ -26,7 +26,7 @@ typedef byte* real_ptr;
#define dosmemput(buffer,length,offset) memcpy(offset,buffer,length)
#define display(...) if (quiet == 0) { fprintf(stderr, __VA_ARGS__); }
-int quiet;
+extern int quiet;
real_ptr far_ptr_to_real_ptr( uint32 farptr )
{
--- a/get-edid/i2c.c
+++ b/get-edid/i2c.c
@@ -15,7 +15,7 @@
//Ideas (but not too much actual code) taken from i2c-tools. Thanks guys.
-int quiet;
+extern int quiet;
#define display(...) if (quiet == 0) { fprintf(stderr, __VA_ARGS__); }
Loading…
Cancel
Save