From f2467eb6a0070176a5b1cd76aa330b84431f8258 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 5 Apr 2012 13:03:19 +0200 Subject: [PATCH] On Linux, pretend we're building on Linux 2.6 Setting the UNAME26 personality causes "uname" to return "2.6.x", regardless of the kernel version. This improves determinism in a few misbehaved packages. --- src/libstore/build.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 467f16597..c13ea6d23 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1794,10 +1794,21 @@ void DerivationGoal::startBuilder() throw SysError(format("changing into `%1%'") % tmpDir); #ifdef CAN_DO_LINUX32_BUILDS + /* Change the personality to 32-bit if we're doing an + i686-linux build on an x86_64-linux machine. */ if (drv.platform == "i686-linux" && thisSystem == "x86_64-linux") { if (personality(0x0008 | 0x8000000 /* == PER_LINUX32_3GB */) == -1) throw SysError("cannot set i686-linux personality"); } + + /* Impersonate a Linux 2.6 machine to get some determinism + in builds that depend on the kernel version. */ + if ((drv.platform == "i686-linux" || drv.platform == "x86_64-linux") && + queryBoolSetting("build-impersonate-linux-26", true)) + { + int cur = personality(0xffffffff); + if (cur != -1) personality(cur | 0x0020000 /* == UNAME26 */); + } #endif /* Fill in the environment. */