From owner-freebsd-toolchain@FreeBSD.ORG Tue May 7 20:58:12 2013 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D6FB9B73; Tue, 7 May 2013 20:58:12 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-ve0-x233.google.com (mail-ve0-x233.google.com [IPv6:2607:f8b0:400c:c01::233]) by mx1.freebsd.org (Postfix) with ESMTP id 8D3D719D; Tue, 7 May 2013 20:58:12 +0000 (UTC) Received: by mail-ve0-f179.google.com with SMTP id oz11so1103514veb.10 for ; Tue, 07 May 2013 13:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to:cc :content-type; bh=N3fEH2M5pdXsZTyzYTeBsuWs+zKm6Ynzt/AtAGXJ4k0=; b=GMMNe0Kf+X+KNIciGzbEzdC72r9anTNVSTad5x5YIXJIZ4NwyqbSNef9IVuNgtWu3V /YRpEHqZnRMlZ5R7kCgbCYvYGLo4rTQblHTPd8YakkLLKwH+8NmcUTk4z0t9BTPP78NP jqvTTr3toeRaBSyfMYvJhC3yiE0tpcX2NEX/PvejsGDmqJHQFZIf1yhWP9jqsmEA2Ao1 GuMH7NVczBvTJjkgY40mzaNzOd3SqBbZEO2Xbvls5fmn98JlrkNDloIo9hnWZSQcDu2d JIXi2XkYyZlXZFN/ZTx/+WwxR5fB/kHbVg4usS4UAkXxyuhwQCrYjx0XqdfbM0Md6r+O R6pg== MIME-Version: 1.0 X-Received: by 10.52.21.173 with SMTP id w13mr2072722vde.99.1367960292154; Tue, 07 May 2013 13:58:12 -0700 (PDT) Received: by 10.220.141.72 with HTTP; Tue, 7 May 2013 13:58:12 -0700 (PDT) Date: Tue, 7 May 2013 13:58:12 -0700 Message-ID: Subject: clang doesn't make temporary files in all instances, causes build races by not using mk*temp(3) in /tmp From: Garrett Cooper To: dim@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1 Cc: toolchain@freebsd.org X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 May 2013 20:58:12 -0000 Hi Dimitriy, I ran into the following error when trying to execute make tinderbox with FreeBSD svn head with ATF changes I'm going to push to benno@: cc -O -pipe -DHAVE_CONFIG_H -I/scratch/freebsd/head-svn/gnu/lib/libgomp -I. -I/scratch/freebsd/head-svn/gnu/lib/libgomp/../../../contrib/gcclibs/libgomp -I/scratch/freebsd/head-svn/gnu/lib/libgomp/../../../contrib/gcclibs/libgomp/config/posix -std=gnu99 -Qunused-arguments -c /scratch/freebsd/head-svn/gnu/lib/libgomp/../../../contrib/gcclibs/libgomp/config/posix/bar.c -o bar.o cc: error: unable to make temporary file: /tmp/bar: can't make unique filename: Permission denied *** [bar.o] Error code 1 Did some poking around in the clang source and it looks like it's doing some less than intelligent things when generating "temporary" paths (from contrib/llvm/tools/clang/lib/Driver/Driver.cpp ): 1598 std::string Driver::GetTemporaryPath(StringRef Prefix, const char *Suffix) 1599 const { 1600 // FIXME: This is lame; sys::Path should provide this function (in particular, 1601 // it should know how to find the temporary files dir). 1602 std::string Error; 1603 const char *TmpDir = ::getenv("TMPDIR"); 1604 if (!TmpDir) 1605 TmpDir = ::getenv("TEMP"); 1606 if (!TmpDir) 1607 TmpDir = ::getenv("TMP"); 1608 if (!TmpDir) 1609 TmpDir = "/tmp"; 1610 llvm::sys::Path P(TmpDir); 1611 P.appendComponent(Prefix); 1612 if (P.makeUnique(false, &Error)) { 1613 Diag(clang::diag::err_unable_to_make_temp) << Error; 1614 return ""; 1615 } 1616 1617 // FIXME: Grumble, makeUnique sometimes leaves the file around!? PR3837. 1618 P.eraseFromDisk(false, 0); 1619 1620 if (Suffix) 1621 P.appendSuffix(Suffix); 1622 return P.str(); This logic (line 1612) is racy and incorrect. This _needs_ to be fixed in clang to properly prefix and rename to the target path in the filesystem where the compilation is being done in order to avoid races with partial compilations, etc. Thanks, -Garrett