From owner-svn-src-head@freebsd.org Sat Nov 4 10:32:15 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D46EAE6A719 for ; Sat, 4 Nov 2017 10:32:15 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: from asp.reflexion.net (outbound-mail-210-143.reflexion.net [208.70.210.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9A915681A2 for ; Sat, 4 Nov 2017 10:32:15 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: (qmail 8241 invoked from network); 4 Nov 2017 10:32:14 -0000 Received: from unknown (HELO mail-cs-01.app.dca.reflexion.local) (10.81.19.1) by 0 (rfx-qmail) with SMTP; 4 Nov 2017 10:32:14 -0000 Received: by mail-cs-01.app.dca.reflexion.local (Reflexion email security v8.40.3) with SMTP; Sat, 04 Nov 2017 06:32:14 -0400 (EDT) Received: (qmail 22100 invoked from network); 4 Nov 2017 10:32:13 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with (AES256-SHA encrypted) SMTP; 4 Nov 2017 10:32:13 -0000 Received: from [192.168.1.25] (c-76-115-7-162.hsd1.or.comcast.net [76.115.7.162]) by iron2.pdx.net (Postfix) with ESMTPSA id 3A1D1EC8FCC; Sat, 4 Nov 2017 03:32:13 -0700 (PDT) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r325320 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs [breaks lld on zfs: lld uses fallocate] Message-Id: <6140C4E2-168F-4E5D-B3C2-717ECB67C980@dsl-only.net> Date: Sat, 4 Nov 2017 03:32:12 -0700 To: FreeBSD Toolchain , avg@freebsd.org, svn-src-head@freebsd.org, FreeBSD Current X-Mailer: Apple Mail (2.3273) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Nov 2017 10:32:15 -0000 > Author: avg > Date: Thu Nov 2 13:49:08 2017 > New Revision: 325320 > URL:=20 > https://svnweb.freebsd.org/changeset/base/325320 >=20 >=20 > Log: > Disable posix_fallocate(2) for ZFS > . . . Turns out lld uses fallocate and so can fail on zfs now. The following is the lld for a amd64 -> aarch64 cross-buildworld. = /usr/obj/cortexA53_clang/arm64.aarch64/usr/src/arm64.aarch64/tmp/usr/bin/l= d: error: cannot open output file a.out: Invalid argument This resulted from: Breakpoint 5, 0x0000000000cf1cd1 in llvm::sys::fs::resize_file(int, = unsigned long) () (gdb) disass Dump of assembler code for function _ZN4llvm3sys2fs11resize_fileEim: . . . 0x0000000000cf1ce5 <+21>: callq 0x1ad5880 . . . via the error status return value handling. It ends up with: Breakpoint 3, 0x000000000041c6e4 in lld::elf::error(llvm::Twine const&) = () (gdb) bt #0 0x000000000041c6e4 in lld::elf::error(llvm::Twine const&) () #1 0x00000000004113b1 in void = lld::elf::LinkerDriver::link >(llvm::opt::InputArgList&) () #2 0x000000000040be3f in = lld::elf::LinkerDriver::main(llvm::ArrayRef, bool) () #3 0x000000000040ae89 in lld::elf::link(llvm::ArrayRef, = bool, llvm::raw_ostream&) () #4 0x000000000054cd61 in main () Progressing from posix_fallocate's call to its caller and so on: # grep -r "fallocate" /usr/src/contrib/llvm/ | more /usr/src/contrib/llvm/lib/Support/Unix/Path.inc: // If we have = posix_fallocate use it. Unlike ftruncate it always allocates /usr/src/contrib/llvm/lib/Support/Unix/Path.inc: if (int Err =3D = ::posix_fallocate(FD, 0, Size)) { Is called by: std::error_code resize_file(int FD, uint64_t Size) { #if defined(HAVE_POSIX_FALLOCATE) // If we have posix_fallocate use it. Unlike ftruncate it always = allocates // space, so we get an error if the disk is full. if (int Err =3D ::posix_fallocate(FD, 0, Size)) { if (Err !=3D EOPNOTSUPP) return std::error_code(Err, std::generic_category()); } #endif // Use ftruncate as a fallback. It may or may not allocate space. At = least on // OS X with HFS+ it does. if (::ftruncate(FD, Size) =3D=3D -1) return std::error_code(errno, std::generic_category()); return std::error_code(); } # grep -r "resize_file" /usr/src/contrib/llvm/ | more /usr/src/contrib/llvm/lib/Support/FileOutputBuffer.cpp: EC =3D = sys::fs::resize_file(FD, Size); /usr/src/contrib/llvm/lib/Support/Unix/Path.inc:std::error_code = resize_file(int FD, uint64_t Size) { /usr/src/contrib/llvm/lib/Support/Windows/Path.inc:std::error_code = resize_file(int FD, uint64_t Size) { /usr/src/contrib/llvm/include/llvm/Support/FileSystem.h:std::error_code = resize_file(int FD, uint64_t Size); Is called by: ErrorOr> FileOutputBuffer::create(StringRef FilePath, size_t Size, unsigned = Flags) { // Check file is not a regular file, in which case we cannot remove = it. . . . #ifndef LLVM_ON_WIN32 // . . . EC =3D sys::fs::resize_file(FD, Size); if (EC) return EC; #endif Is called by: std::error_code elf::tryCreateFile(StringRef Path) { if (Path.empty()) return std::error_code(); return FileOutputBuffer::create(Path, 1).getError(); } Is called by: template void LinkerDriver::link(opt::InputArgList &Args) { SymbolTable Symtab; elf::Symtab::X =3D &Symtab; Target =3D getTarget(); Config->MaxPageSize =3D getMaxPageSize(Args); Config->ImageBase =3D getImageBase(Args); // Default output filename is "a.out" by the Unix tradition. if (Config->OutputFile.empty()) Config->OutputFile =3D "a.out"; // Fail early if the output file or map file is not writable. If a = user has a // long link, e.g. due to a large LTO link, they do not wish to run it = and // find that it failed because there was a mistake in their = command-line. if (auto E =3D tryCreateFile(Config->OutputFile)) error("cannot open output file " + Config->OutputFile + ": " + = E.message()); And the error call is then made once tryCreateFile returns. =3D=3D=3D Mark Millard markmi at dsl-only.net