Skip to content

Commit

Permalink
Merge branch 'aarch64-armv7' of git://github.com/lheckemann/nix
Browse files Browse the repository at this point in the history
Support extra compatible architectures (#1916)
  • Loading branch information
shlevy committed Apr 23, 2018
2 parents e2b0283 + 639c166 commit 8e6108f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
19 changes: 19 additions & 0 deletions doc/manual/command-ref/conf-file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,25 @@ false</literal>.</para>
</varlistentry>


<varlistentry xml:id="conf-extra-platforms"><term><literal>extra-platforms</literal></term>

<listitem><para>Platforms other than the native one which
this machine is capable of building for. This can be useful for
supporting additional architectures on compatible machines:
i686-linux can be built on x86_64-linux machines (and the default
for this setting reflects this); armv7 is backwards-compatible with
armv6 and armv5tel; some aarch64 machines can also natively run
32-bit ARM code; and qemu-user may be used to support non-native
platforms (though this may be slow and buggy). Most values for this
are not enabled by default because build systems will often
misdetect the target platform and generate incompatible code, so you
may wish to cross-check the results of using this option against
proper natively-built versions of your
derivations.</para></listitem>

</varlistentry>


<varlistentry xml:id="conf-extra-substituters"><term><literal>extra-substituters</literal></term>

<listitem><para>Additional binary caches appended to those
Expand Down
4 changes: 3 additions & 1 deletion src/build-remote/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ int main (int argc, char * * argv)
source >> drvPath;
auto requiredFeatures = readStrings<std::set<std::string>>(source);

auto canBuildLocally = amWilling && (neededSystem == settings.thisSystem);
auto canBuildLocally = amWilling
&& ( neededSystem == settings.thisSystem

This comment has been minimized.

Copy link
@dtzWill

dtzWill Apr 24, 2018

Member

small nit-- is the whitespace here intentional?

This comment has been minimized.

Copy link
@shlevy

shlevy Apr 24, 2018

Author Member

Looks like it... @lheckemann?

This comment has been minimized.

Copy link
@lheckemann

lheckemann Apr 24, 2018

Member

Yes, the idea being to make the two sides of the || clear. I'll agree that it's not beautiful though…

This comment has been minimized.

Copy link
@dtzWill

dtzWill Apr 24, 2018

Member

Meh, just don't see multiple spaces after open paren often, so just thought I'd check.

|| settings.extraPlatforms.get().count(neededSystem) > 0);

/* Error ignored here, will be caught later */
mkdir(currentLoad.c_str(), 0777);
Expand Down
4 changes: 4 additions & 0 deletions src/libstore/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,10 @@ void setupSeccomp()
seccomp_arch_add(ctx, SCMP_ARCH_X32) != 0)
throw SysError("unable to add X32 seccomp architecture");

if (settings.thisSystem == "aarch64-linux" &&
seccomp_arch_add(ctx, SCMP_ARCH_ARM) != 0)
printError("unsable to add ARM seccomp architecture; this may result in spurious build failures if running 32-bit ARM processes.");

/* Prevent builders from creating setuid/setgid binaries. */
for (int perm : { S_ISUID, S_ISGID }) {
if (seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EPERM), SCMP_SYS(chmod), 1,
Expand Down
12 changes: 2 additions & 10 deletions src/libstore/derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,8 @@ bool BasicDerivation::isBuiltin() const
bool BasicDerivation::canBuildLocally() const
{
return platform == settings.thisSystem
|| isBuiltin()
#if __linux__
|| (platform == "i686-linux" && settings.thisSystem == "x86_64-linux")
|| (platform == "armv6l-linux" && settings.thisSystem == "armv7l-linux")
|| (platform == "armv5tel-linux" && (settings.thisSystem == "armv7l-linux" || settings.thisSystem == "armv6l-linux"))
#elif __FreeBSD__
|| (platform == "i686-linux" && settings.thisSystem == "x86_64-freebsd")
|| (platform == "i686-linux" && settings.thisSystem == "i686-freebsd")
#endif
;
|| settings.extraPlatforms.get().count(platform) > 0
|| isBuiltin();
}


Expand Down
7 changes: 7 additions & 0 deletions src/libstore/globals.hh
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ public:
"Nix store has a valid signature (that is, one signed using a key "
"listed in 'trusted-public-keys'."};

Setting<StringSet> extraPlatforms{this,
SYSTEM == "x86_64-linux" ? StringSet{"i686-linux"} : StringSet{},
"extra-platforms",
"Additional platforms that can be built on the local system. "
"These may be supported natively (e.g. armv7 on some aarch64 CPUs "
"or using hacks like qemu-user."};

This comment has been minimized.

Copy link
@dezgeg

dezgeg Apr 24, 2018

Contributor
In file included from src/libstore/store-api.hh:8:0,
                 from src/nix/add-to-store.cc:3:
src/libstore/globals.hh:299:19: warning: comparison with string literal results in unspecified behavior [-Waddress]
         SYSTEM == "x86_64-linux" ? StringSet{"i686-linux"} : StringSet{},
                   ^~~~~~~~~~~~~~

This comment has been minimized.

Copy link
@shlevy

shlevy Apr 24, 2018

Author Member

Fixed

Setting<Strings> substituters{this,
nixStore == "/nix/store" ? Strings{"https://cache.nixos.org/"} : Strings(),
"substituters",
Expand Down

0 comments on commit 8e6108f

Please sign in to comment.