diff options
author | dim <dim@FreeBSD.org> | 2014-02-28 17:12:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-02-28 17:12:31 +0000 |
commit | 0074a11a5664d590930bcae5158cbcf0ddc83a69 (patch) | |
tree | d428287e379d2908fa47b109c32edcbf5f8e623d /contrib/llvm/lib/MC/MCContext.cpp | |
parent | d494cb84495638a16df75345e9a3be4d43985327 (diff) | |
download | FreeBSD-src-0074a11a5664d590930bcae5158cbcf0ddc83a69.zip FreeBSD-src-0074a11a5664d590930bcae5158cbcf0ddc83a69.tar.gz |
Pull in r196874 from upstream llvm trunk:
Fix a crash that occurs when PWD is invalid.
MCJIT needs to be able to run in hostile environments, even when PWD
is invalid. There's no need to crash MCJIT in this case.
The obvious fix is to simply leave MCContext's CompilationDir empty
when PWD can't be determined. This way, MCJIT clients,
and other clients that link with LLVM don't need a valid working directory.
If we do want to guarantee valid CompilationDir, that should be done
only for clients of getCompilationDir(). This is as simple as checking
for an empty string.
The only current use of getCompilationDir is EmitGenDwarfInfo, which
won't conceivably run with an invalid working dir. However, in the
purely hypothetically and untestable case that this happens, the
AT_comp_dir will be omitted from the compilation_unit DIE.
This should help fix assertions occurring with ports-mgmt/tinderbox,
when it is using jails, and sometimes invalidates clang's current
working directory.
Reported by: decke
MFC after: 2 weeks
X-MFC-With: r261991
Diffstat (limited to 'contrib/llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | contrib/llvm/lib/MC/MCContext.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/contrib/llvm/lib/MC/MCContext.cpp b/contrib/llvm/lib/MC/MCContext.cpp index 3b45d16..a0acda5 100644 --- a/contrib/llvm/lib/MC/MCContext.cpp +++ b/contrib/llvm/lib/MC/MCContext.cpp @@ -47,8 +47,8 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri, AllowTemporaryLabels(true), DwarfCompileUnitID(0), AutoReset(DoAutoReset) { error_code EC = llvm::sys::fs::current_path(CompilationDir); - assert(!EC && "Could not determine the current directory"); - (void)EC; + if (EC) + CompilationDir.clear(); MachOUniquingMap = 0; ELFUniquingMap = 0; |