Skip to content

Commit c7bac81

Browse files
committed
Merge 'mingw-w64' and 'darwin' into cross-win-osx.
Both branches have quite a lot in common, so it's time for a merge and do the cleanups with respect to both implementations and also generalize both implementations as much as possible. This also closes #1876. Conflicts: pkgs/development/interpreters/lua-5/5.2.nix pkgs/development/libraries/SDL/default.nix pkgs/development/libraries/glew/default.nix pkgs/top-level/all-packages.nix
3 parents 28069d6 + a3cf381 + a445199 commit c7bac81

33 files changed

Lines changed: 487 additions & 119 deletions

File tree

pkgs/build-support/gcc-cross-wrapper/builder.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ if test -z "$nativeLibc"; then
2626
fi
2727
fi
2828

29+
if [ -n "$osxMinVersion" ]; then
30+
cflagsCompile="$cflagsCompile -mmacosx-version-min=$osxMinVersion"
31+
fi
32+
2933
echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
3034

3135
echo "-L$libc/lib -rpath $libc/lib -rpath-link $libc/lib" > $out/nix-support/libc-ldflags

pkgs/build-support/gcc-cross-wrapper/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ stdenv.mkDerivation {
4646
addFlags = ./add-flags;
4747
inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
4848
crossConfig = if cross != null then cross.config else null;
49+
osxMinVersion = cross.osxMinVersion or null;
4950
gccLibs = if gcc != null then gccLibs else null;
5051
name = chosenName;
5152
langC = if nativeTools then true else gcc.langC;

pkgs/build-support/gcc-cross-wrapper/setup-hook.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ fi
7070

7171
if test "$dontSetConfigureCross" != "1"; then
7272
configureFlags="$configureFlags --build=$system --host=$crossConfig"
73+
# This is because -print-prog-name tries to search FHS paths.
74+
configureFlags="$configureFlags LD=$crossConfig-ld"
7375
fi
7476
# Disabling the tests when cross compiling, as usually the tests are meant for
7577
# native compilations.
7678
doCheck=""
7779

80+
# Don't strip foreign binaries with native "strip" tool.
81+
dontStrip=1
82+
7883
# Add the output as an rpath.
7984
if test "$NIX_NO_SELF_RPATH" != "1"; then
8085
export NIX_CROSS_LDFLAGS="-rpath $out/lib -rpath-link $out/lib $NIX_CROSS_LDFLAGS"

pkgs/data/misc/tzdata/default.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ stdenv.mkDerivation rec {
1717
];
1818

1919
sourceRoot = ".";
20+
outputs = [ "out" "lib" ];
2021

21-
makeFlags = "TOPDIR=$(out) TZDIR=$(out)/share/zoneinfo ETCDIR=$(TMPDIR)/etc LIBDIR=$(TMPDIR)/lib MANDIR=$(TMPDIR)/man AWK=awk";
22+
makeFlags = "TOPDIR=$(out) TZDIR=$(out)/share/zoneinfo ETCDIR=$(TMPDIR)/etc LIBDIR=$(lib)/lib MANDIR=$(TMPDIR)/man AWK=awk";
2223

2324
postInstall =
2425
''
2526
mv $out/share/zoneinfo-posix $out/share/zoneinfo/posix
2627
mv $out/share/zoneinfo-leaps $out/share/zoneinfo/right
28+
29+
ensureDir "$lib/include"
30+
cp tzfile.h "$lib/include/tzfile.h"
2731
'';
2832

2933
meta = {

pkgs/development/compilers/gcc/4.6/default.nix

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,8 @@ let version = "4.6.3";
159159
# In any case, mingw32 g++ linking is broken by default with shared libs,
160160
# unless adding "-lsupc++" to any linking command. I don't know why.
161161
" --disable-shared" +
162-
(if cross.config == "x86_64-w64-mingw32" then
163-
# To keep ABI compatibility with upstream mingw-w64
164-
" --enable-fully-dynamic-string"
165-
else "")
162+
# To keep ABI compatibility with upstream mingw-w64
163+
" --enable-fully-dynamic-string"
166164
else (if cross.libc == "uclibc" then
167165
# In uclibc cases, libgomp needs an additional '-ldl'
168166
# and as I don't know how to pass it, I disable libgomp.

pkgs/development/compilers/gcc/4.8/default.nix

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ let version = "4.8.2";
117117
withMode;
118118

119119
/* Cross-gcc settings */
120-
crossMingw = (cross != null && cross.libc == "msvcrt");
120+
crossMingw = cross != null && cross.libc == "msvcrt";
121+
crossDarwin = cross != null && cross.libc == "libSystem";
121122
crossConfigureFlags = let
122123
gccArch = stdenv.cross.gcc.arch or null;
123124
gccCpu = stdenv.cross.gcc.cpu or null;
@@ -161,7 +162,12 @@ let version = "4.8.2";
161162
" --disable-shared" +
162163
" --disable-decimal-float" # libdecnumber requires libc
163164
else
164-
" --with-headers=${libcCross}/include" +
165+
(if crossDarwin then
166+
" --with-sysroot=${libcCross}/share/sysroot" +
167+
" --with-as=${binutilsCross}/bin/${cross.config}-as" +
168+
" --with-ld=${binutilsCross}/bin/${cross.config}-ld"
169+
else
170+
" --with-headers=${libcCross}/include") +
165171
" --enable-__cxa_atexit" +
166172
" --enable-long-long" +
167173
(if crossMingw then
@@ -175,10 +181,8 @@ let version = "4.8.2";
175181
# In any case, mingw32 g++ linking is broken by default with shared libs,
176182
# unless adding "-lsupc++" to any linking command. I don't know why.
177183
" --disable-shared" +
178-
(if cross.config == "x86_64-w64-mingw32" then
179-
# To keep ABI compatibility with upstream mingw-w64
180-
" --enable-fully-dynamic-string"
181-
else "")
184+
# To keep ABI compatibility with upstream mingw-w64
185+
" --enable-fully-dynamic-string"
182186
else (if cross.libc == "uclibc" then
183187
# In uclibc cases, libgomp needs an additional '-ldl'
184188
# and as I don't know how to pass it, I disable libgomp.
@@ -346,6 +350,7 @@ stdenv.mkDerivation ({
346350
++ optional langAda "ada"
347351
++ optional langVhdl "vhdl"
348352
++ optional langGo "go"
353+
++ optionals crossDarwin [ "objc" "obj-c++" ]
349354
)
350355
)
351356
}

pkgs/development/interpreters/lua-5/5.2.nix

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
1717
sha256 = "004zyh9p3lpvbwhyhlmrw6wwcia5abx84q4h2brkn4zdypipvmiz";
1818
};
1919

20-
buildInputs = [ readline ];
20+
nativeBuildInputs = [ readline ];
2121

2222
patches = [ dsoPatch ];
2323

@@ -49,6 +49,37 @@ stdenv.mkDerivation rec {
4949
EOF
5050
'';
5151

52+
crossAttrs = let
53+
isMingw = stdenv.cross.libc == "msvcrt";
54+
isDarwin = stdenv.cross.libc == "libSystem";
55+
in {
56+
configurePhase = ''
57+
makeFlagsArray=(
58+
INSTALL_TOP=$out
59+
INSTALL_MAN=$out/share/man/man1
60+
CC=${stdenv.cross.config}-gcc
61+
STRIP=:
62+
RANLIB=${stdenv.cross.config}-ranlib
63+
V=${majorVersion}
64+
R=${version}
65+
${if isMingw then "mingw" else stdenv.lib.optionalString isDarwin ''
66+
AR="${stdenv.cross.config}-ar rcu"
67+
macosx
68+
''}
69+
)
70+
'' + stdenv.lib.optionalString isMingw ''
71+
installFlagsArray=(
72+
TO_BIN="lua.exe luac.exe"
73+
TO_LIB="liblua.a lua52.dll"
74+
INSTALL_DATA="cp -d"
75+
)
76+
'';
77+
} // stdenv.lib.optionalAttrs isDarwin {
78+
postPatch = ''
79+
sed -i -e 's/-Wl,-soname[^ ]* *//' src/Makefile
80+
'';
81+
};
82+
5283
meta = {
5384
homepage = "http://www.lua.org";
5485
description = "Powerful, fast, lightweight, embeddable scripting language";

pkgs/development/libraries/SDL/default.nix

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@
77

88
# OSS is no longer supported, for it's much crappier than ALSA and
99
# PulseAudio.
10-
assert alsaSupport || pulseaudioSupport;
10+
assert !(stdenv ? cross) -> alsaSupport || pulseaudioSupport;
1111

1212
assert openglSupport -> (mesa != null && x11Support);
1313
assert x11Support -> (x11 != null && libXrandr != null);
1414
assert alsaSupport -> alsaLib != null;
1515
assert pulseaudioSupport -> pulseaudio != null;
1616

17-
let
18-
configureFlagsFun = attrs: ''
19-
--disable-oss --disable-video-x11-xme
20-
--disable-x11-shared --disable-alsa-shared --enable-rpath --disable-pulseaudio-shared
21-
--disable-osmesa-shared
22-
${if alsaSupport then "--with-alsa-prefix=${attrs.alsaLib}/lib" else ""}
23-
'';
24-
in
2517
stdenv.mkDerivation rec {
2618
version = "1.2.15";
2719
name = "SDL-${version}";
@@ -32,20 +24,46 @@ stdenv.mkDerivation rec {
3224
};
3325

3426
# Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated.
35-
propagatedBuildInputs = stdenv.lib.optionals x11Support [ x11 libXrandr ] ++
27+
propagatedNativeBuildInputs =
28+
stdenv.lib.optionals x11Support [ x11 libXrandr ] ++
3629
stdenv.lib.optional pulseaudioSupport pulseaudio;
3730

38-
buildInputs = [ pkgconfig audiofile ] ++
31+
buildInputs = let
32+
notMingw = !(stdenv ? cross) || stdenv.cross.libc != "msvcrt";
33+
in stdenv.lib.optional notMingw audiofile;
34+
35+
nativeBuildInputs = [ pkgconfig ] ++
3936
stdenv.lib.optional openglSupport [ mesa ] ++
4037
stdenv.lib.optional alsaSupport alsaLib;
4138

4239
# XXX: By default, SDL wants to dlopen() PulseAudio, in which case
4340
# we must arrange to add it to its RPATH; however, `patchelf' seems
4441
# to fail at doing this, hence `--disable-pulseaudio-shared'.
45-
configureFlags = configureFlagsFun { inherit alsaLib; };
42+
configureFlags = [
43+
"--disable-oss"
44+
"--disable-video-x11-xme"
45+
"--disable-x11-shared"
46+
"--disable-alsa-shared"
47+
"--enable-rpath"
48+
"--disable-pulseaudio-shared"
49+
"--disable-osmesa-shared"
50+
] ++ stdenv.lib.optionals (stdenv ? cross) ([
51+
"--without-x"
52+
] ++ stdenv.lib.optional alsaSupport "--with-alsa-prefix=${alsaLib}/lib");
4653

47-
crossAttrs = {
48-
configureFlags = configureFlagsFun { alsaLib = alsaLib.crossDrv; };
54+
crossAttrs =stdenv.lib.optionalAttrs (stdenv.cross.libc == "libSystem") {
55+
patches = let
56+
f = rev: sha256: fetchurl {
57+
url = "http://hg.libsdl.org/SDL/raw-rev/${rev}";
58+
inherit sha256;
59+
};
60+
in [
61+
(f "e9466ead70e5" "0ygir3k83d0vxp7s3k48jn3j8n2bnv9wm6613wpx3ybnjrxabrip")
62+
(f "bbfb41c13a87" "17v29ybjifvka19m8qf14rjc43nfdwk9v9inaizznarhb17amlnv")
63+
];
64+
postPatch = ''
65+
sed -i -e 's/ *-fpascal-strings//' configure
66+
'';
4967
};
5068

5169
passthru = {inherit openglSupport;};

pkgs/development/libraries/audiofile/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
stdenv.mkDerivation rec {
44
name = "audiofile-0.3.6";
55

6-
buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
6+
nativeBuildInputs = stdenv.lib.optional stdenv.isLinux alsaLib;
77

88
src = fetchurl {
99
url = "http://audiofile.68k.org/${name}.tar.gz";

pkgs/development/libraries/glew/default.nix

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{ stdenv, fetchurl, mesa_glu, x11, libXmu, libXi }:
22

3+
with stdenv.lib;
4+
35
stdenv.mkDerivation rec {
46
name = "glew-1.10.0";
57

@@ -8,23 +10,38 @@ stdenv.mkDerivation rec {
810
sha256 = "01zki46dr5khzlyywr3cg615bcal32dazfazkf360s1znqh17i4r";
911
};
1012

11-
12-
buildInputs = [ x11 libXmu libXi ];
13-
propagatedBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h
13+
nativeBuildInputs = [ x11 libXmu libXi ];
14+
propagatedNativeBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h
1415

1516
patchPhase = ''
1617
sed -i 's|lib64|lib|' config/Makefile.linux
18+
${optionalString (stdenv ? cross) ''
19+
sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
20+
''}
21+
'';
22+
23+
buildFlags = [ "all" ];
24+
installFlags = [ "install.all" ];
25+
26+
preInstall = ''
27+
export GLEW_DEST="$out"
1728
'';
1829

19-
buildPhase = "make all";
20-
installPhase = ''
21-
GLEW_DEST=$out make install.all
30+
postInstall = ''
2231
mkdir -pv $out/share/doc/glew
2332
mkdir -p $out/lib/pkgconfig
2433
cp glew*.pc $out/lib/pkgconfig
2534
cp -r README.txt LICENSE.txt doc $out/share/doc/glew
2635
'';
2736

37+
crossAttrs.makeFlags = [
38+
"CC=${stdenv.cross.config}-gcc"
39+
"LD=${stdenv.cross.config}-gcc"
40+
"AR=${stdenv.cross.config}-ar"
41+
"STRIP="
42+
] ++ optional (stdenv.cross.libc == "msvcrt") "SYSTEM=mingw"
43+
++ optional (stdenv.cross.libc == "libSystem") "SYSTEM=darwin";
44+
2845
meta = {
2946
description = "An OpenGL extension loading library for C(++)";
3047
homepage = http://glew.sourceforge.net/;

0 commit comments

Comments
 (0)