summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-03-18 22:07:45 +0000
committerdim <dim@FreeBSD.org>2014-03-18 22:07:45 +0000
commitce0b21596585c6ddd828c54e5077ba0aecfae8fc (patch)
tree67bb26dee066c422ad2e624408df89bdc262af76 /contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff
parentf931c3355875cf6371ab8fbad62d0f35958db4a0 (diff)
downloadFreeBSD-src-ce0b21596585c6ddd828c54e5077ba0aecfae8fc.zip
FreeBSD-src-ce0b21596585c6ddd828c54e5077ba0aecfae8fc.tar.gz
Add separate patch files for all the customizations we have currently
applied to our copy of llvm/clang. These can be applied in alphabetical order to a pristine llvm/clang 3.4 release source tree, to result in the same version used in FreeBSD. This is intended to clearly document all the changes until now, which mostly consist of cherry pickings from the respective upstream trunks, plus a number of hand-written FreeBSD-specific ones. Hopefully those can eventually be cleaned up and sent upstream too. MFC after: 1 week X-MFC-With: r263313
Diffstat (limited to 'contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff')
-rw-r--r--contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff76
1 files changed, 76 insertions, 0 deletions
diff --git a/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff b/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff
new file mode 100644
index 0000000..587693d
--- /dev/null
+++ b/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff
@@ -0,0 +1,76 @@
+Pull in r196874 from upstream llvm trunk (by Andrew Trick):
+
+ 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?\226?\128?\153t 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?\226?\128?\153t 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.
+
+Introduced here: http://svn.freebsd.org/changeset/base/262611
+
+Index: include/llvm/MC/MCContext.h
+===================================================================
+--- include/llvm/MC/MCContext.h
++++ include/llvm/MC/MCContext.h
+@@ -278,6 +278,7 @@ namespace llvm {
+ /// This can be overridden by clients which want to control the reported
+ /// compilation directory and have it be something other than the current
+ /// working directory.
++ /// Returns an empty string if the current directory cannot be determined.
+ StringRef getCompilationDir() const { return CompilationDir; }
+
+ /// \brief Set the compilation directory for DW_AT_comp_dir
+Index: lib/MC/MCContext.cpp
+===================================================================
+--- lib/MC/MCContext.cpp
++++ lib/MC/MCContext.cpp
+@@ -47,8 +47,8 @@ MCContext::MCContext(const MCAsmInfo *mai, const M
+ 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;
+Index: lib/MC/MCDwarf.cpp
+===================================================================
+--- lib/MC/MCDwarf.cpp
++++ lib/MC/MCDwarf.cpp
+@@ -467,7 +467,8 @@ static void EmitGenDwarfAbbrev(MCStreamer *MCOS) {
+ EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
+ EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr);
+ EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string);
+- EmitAbbrev(MCOS, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string);
++ if (!context.getCompilationDir().empty())
++ EmitAbbrev(MCOS, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string);
+ StringRef DwarfDebugFlags = context.getDwarfDebugFlags();
+ if (!DwarfDebugFlags.empty())
+ EmitAbbrev(MCOS, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string);
+@@ -643,8 +644,10 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
+ MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string.
+
+ // AT_comp_dir, the working directory the assembly was done in.
+- MCOS->EmitBytes(context.getCompilationDir());
+- MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string.
++ if (!context.getCompilationDir().empty()) {
++ MCOS->EmitBytes(context.getCompilationDir());
++ MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string.
++ }
+
+ // AT_APPLE_flags, the command line arguments of the assembler tool.
+ StringRef DwarfDebugFlags = context.getDwarfDebugFlags();
OpenPOWER on IntegriCloud