Skip to content

Commit

Permalink
Merge pull request #26007 from obsidiansystems/cc-wrapper-prefix
Browse files Browse the repository at this point in the history
Get rid of gcc-cross-wrapper
  • Loading branch information
Ericson2314 committed Jun 23, 2017
2 parents c76f8d9 + 198dcec commit afd2bdb
Show file tree
Hide file tree
Showing 62 changed files with 560 additions and 931 deletions.
10 changes: 10 additions & 0 deletions doc/stdenv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,16 @@ script) if it exists.</para>
true.</para></listitem>
</varlistentry>

<varlistentry>
<term><varname>configurePlatforms</varname></term>
<listitem><para>
By default, when cross compiling, the configure script has <option>--build=...</option> and <option>--host=...</option> passed.
Packages can instead pass <literal>[ "build" "host" "target" ]</literal> or a subset to control exactly which platform flags are passed.
Compilers and other tools should use this to also pass the target platform, for example.
Note eventually these will be passed when in native builds too, to improve determinism: build-time guessing, as is done today, is a risk of impurity.
</para></listitem>
</varlistentry>

<varlistentry>
<term><varname>preConfigure</varname></term>
<listitem><para>Hook executed at the start of the configure
Expand Down
11 changes: 6 additions & 5 deletions pkgs/applications/audio/mpg123/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{stdenv, fetchurl, alsaLib }:
{ stdenv
, fetchurl, alsaLib
, buildPlatform, hostPlatform
}:

stdenv.mkDerivation rec {
name = "mpg123-1.23.8";
Expand All @@ -10,10 +13,8 @@ stdenv.mkDerivation rec {

buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;

crossAttrs = {
configureFlags = if stdenv.cross ? mpg123 then
"--with-cpu=${stdenv.cross.mpg123.cpu}" else "";
};
${if buildPlatform != hostPlatform then "configureFlags" else null} =
stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}";

meta = {
description = "Fast console MPEG Audio Player and decoder library";
Expand Down
13 changes: 8 additions & 5 deletions pkgs/applications/editors/ed/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ fetchurl, stdenv }:
{ stdenv, fetchurl
, buildPlatform, hostPlatform
}:

stdenv.mkDerivation rec {
name = "ed-${version}";
Expand Down Expand Up @@ -28,11 +30,12 @@ stdenv.mkDerivation rec {
make: *** [check] Error 127
*/
doCheck = !stdenv.isDarwin;
doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform);

crossAttrs = {
compileFlags = [ "CC=${stdenv.cross.config}-gcc" ];
};
configureFlags = if hostPlatform == buildPlatform then null else [
"--exec-prefix=${stdenv.cc.prefix}"
"CC=${stdenv.cc.prefix}cc"
];

meta = {
description = "An implementation of the standard Unix editor";
Expand Down
36 changes: 18 additions & 18 deletions pkgs/applications/editors/vim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
sha256 = "18ifhv5q9prd175q3vxbqf6qyvkk6bc7d2lhqdk0q78i68kv9y0c";
}
# apple frameworks
, Carbon, Cocoa }:
, Carbon, Cocoa
, buildPlatform, hostPlatform
}:

let
common = callPackage ./common.nix {};
Expand All @@ -17,12 +19,26 @@ stdenv.mkDerivation rec {
inherit (common) version src postPatch hardeningDisable enableParallelBuilding meta;

buildInputs = [ ncurses pkgconfig ]
++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
++ stdenv.lib.optionals hostPlatform.isDarwin [ Carbon Cocoa ];
nativeBuildInputs = [ gettext ];

configureFlags = [
"--enable-multibyte"
"--enable-nls"
] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [
"vim_cv_toupper_broken=no"
"--with-tlib=ncurses"
"vim_cv_terminfo=yes"
"vim_cv_tty_group=tty"
"vim_cv_tty_mode=0660"
"vim_cv_getcwd_broken=no"
"vim_cv_stat_ignores_slash=yes"
"ac_cv_sizeof_int=4"
"vim_cv_memmove_handles_overlap=yes"
"vim_cv_memmove_handles_overlap=yes"

# TODO(@Ericson2314): wont' be needed soon.
"STRIP=${hostPlatform.config}-strip"
];

postInstall = ''
Expand All @@ -31,22 +47,6 @@ stdenv.mkDerivation rec {
cp "${vimrc}" $out/share/vim/vimrc
'';

crossAttrs = {
configureFlags = [
"vim_cv_toupper_broken=no"
"--with-tlib=ncurses"
"vim_cv_terminfo=yes"
"vim_cv_tty_group=tty"
"vim_cv_tty_mode=0660"
"vim_cv_getcwd_broken=no"
"vim_cv_stat_ignores_slash=yes"
"ac_cv_sizeof_int=4"
"vim_cv_memmove_handles_overlap=yes"
"vim_cv_memmove_handles_overlap=yes"
"STRIP=${stdenv.cross.config}-strip"
];
};

__impureHostDeps = [ "/dev/ptmx" ];

# To fix the trouble in vim73, that it cannot cross-build with this patch
Expand Down
8 changes: 6 additions & 2 deletions pkgs/applications/networking/browsers/lynx/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{ stdenv, fetchurl, ncurses, gzip, pkgconfig
{ stdenv, buildPackages
, fetchurl, pkgconfig, ncurses, gzip
, sslSupport ? true, openssl ? null
, buildPlatform, hostPlatform
}:

assert sslSupport -> openssl != null;
Expand All @@ -15,7 +17,9 @@ stdenv.mkDerivation rec {

configureFlags = [ "--enable-widec" ] ++ stdenv.lib.optional sslSupport "--with-ssl";

nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig;
nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig
++ stdenv.lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;

buildInputs = [ ncurses gzip ] ++ stdenv.lib.optional sslSupport openssl.dev;

meta = with stdenv.lib; {
Expand Down
6 changes: 4 additions & 2 deletions pkgs/applications/video/mplayer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
, libjpegSupport ? true, libjpeg ? null
, useUnfreeCodecs ? false
, darwin ? null
, hostPlatform
}:

assert fontconfigSupport -> (fontconfig != null);
Expand Down Expand Up @@ -185,13 +186,14 @@ stdenv.mkDerivation rec {
'';

crossAttrs = {
dontSetConfigureCross = true;
configurePlatforms = [];
# Some things (vidix) are nanonote specific. Once someone cares, we can make options from them.
# Note, the `target` vs `host` confusion is intensional.
preConfigure = ''
configureFlags="`echo $configureFlags |
sed -e 's/--codecsdir[^ ]\+//' \
-e 's/--enable-runtime-cpudetection//' `"
configureFlags="$configureFlags --target=${stdenv.cross.arch}-linux
configureFlags="$configureFlags --target=${hostPlatform.arch}-linux
--enable-cross-compile --cc=$crossConfig-gcc --as=$crossConfig-as
--disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc"
'';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/video/omxplayer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let
enableParallelBuilding = true;

crossAttrs = {
dontSetConfigureCross = true;
configurePlatforms = [];
configureFlags = configureFlags ++ [
"--cross-prefix=${stdenv.cross.config}-"
"--enable-cross-compile"
Expand Down

0 comments on commit afd2bdb

Please sign in to comment.