imake: Add uberhack to workaround broken 'gcc -x c'

Our cc-wrapper is broken whenever the '-x' flag is used:
'gcc -x c foo.c -o bar' doesn't work the same way as 'gcc foo.c -o bar'
does. (Try both with NIX_DEBUG=1.)

What happens is that passing '-x' causes linker-related flags (such as
-Wl,-dynamic-linker) not to be added, just like if '-c' is passed.
The bug happens outside the multiple-outputs branch as well, but it
doesn't break imake there. It only breaks in multiple-outputs because
linking without -Wl,-dynamic-linker produces a binary with an invalid
ELF interpreter path. (Which arguably, is a bug in its own.)

Changed files
+14 -1
pkgs
+13
pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch
···
+
diff --git a/imake.c b/imake.c
+
index c20cd4a..ec2589b 100644
+
--- a/imake.c
+
+++ b/imake.c
+
@@ -959,7 +959,7 @@ get_libc_version(FILE *inFile)
+
{
+
char aout[4096], *tmpdir;
+
FILE *fp;
+
- const char *format = "%s -o %s -x c -";
+
+ const char *format = "f=$(mktemp imakeXXXXXX.c); cat > $f; %s $f -o %s";
+
char *cc;
+
int len;
+
char *command;
+1 -1
pkgs/servers/x11/xorg/overrides.nix
···
imake = attrs: attrs // {
inherit (xorg) xorgcffiles;
x11BuildHook = ./imake.sh;
-
patches = [./imake.patch];
+
patches = [./imake.patch ./imake-cc-wrapper-uberhack.patch];
setupHook = if stdenv.isDarwin then ./darwin-imake-setup-hook.sh else null;
CFLAGS = [ "-DIMAKE_COMPILETIME_CPP=\\\"${if stdenv.isDarwin
then "${args.tradcpp}/bin/cpp"