Date: Sat, 4 Nov 2017 03:32:12 -0700 From: Mark Millard <markmi@dsl-only.net> To: FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, avg@freebsd.org, svn-src-head@freebsd.org, FreeBSD Current <freebsd-current@freebsd.org> 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>
next in thread | raw e-mail | index | archive | help
> 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 <posix_fallocate> . . . 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::object::ELFType<(llvm::support::endiann= ess)1, true> >(llvm::opt::InputArgList&) () #2 0x000000000040be3f in = lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>, bool) () #3 0x000000000040ae89 in lld::elf::link(llvm::ArrayRef<char const*>, = 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<std::unique_ptr<FileOutputBuffer>> 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 <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { SymbolTable<ELFT> Symtab; elf::Symtab<ELFT>::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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6140C4E2-168F-4E5D-B3C2-717ECB67C980>