<div dir="ltr"><div dir="ltr">This broke our macOS builders when building XRay with the following error:<div><br></div><div><div>FAILED: compiler-rt/lib/xray/CMakeFiles/RTXray.osx.dir/xray_trampoline_x86_64.S.o </div><div>/b/s/w/ir/kitchen-workdir/recipe_cleanup/clangfJXnpj/llvm_build_dir/./bin/clang --target=x86_64-apple-darwin17.7.0 -DXRAY_HAS_EXCEPTIONS=1 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/s/w/ir/kitchen-workdir/llvm-project/compiler-rt/lib/xray/.. -I/b/s/w/ir/kitchen-workdir/llvm-project/compiler-rt/lib/xray/../../include -fPIC -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -Wall -Wno-unused-parameter -O3  -arch x86_64   -UNDEBUG  -stdlib=libc++ -mmacosx-version-min=10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fno-rtti -MD -MT compiler-rt/lib/xray/CMakeFiles/RTXray.osx.dir/xray_trampoline_x86_64.S.o -MF compiler-rt/lib/xray/CMakeFiles/RTXray.osx.dir/xray_trampoline_x86_64.S.o.d -o compiler-rt/lib/xray/CMakeFiles/RTXray.osx.dir/xray_trampoline_x86_64.S.o   -c /b/s/w/ir/kitchen-workdir/llvm-project/compiler-rt/lib/xray/xray_trampoline_x86_64.S</div><div>/b/s/w/ir/kitchen-workdir/llvm-project/compiler-rt/lib/xray/xray_trampoline_x86_64.S:97:2: error: target does not support '.file' without a number</div><div> .file "xray_trampoline_x86.S"</div><div> ^</div></div><div><br></div><div>This has been compiling before so I don't understand why it hasn't crashed the compiler like your file-single.s test does. In any case, we probably need to change xray_trampoline_x86_64.S or revert this change.</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 21, 2018 at 3:38 PM Reid Kleckner via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: rnk<br>
Date: Fri Dec 21 15:35:48 2018<br>
New Revision: 349976<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=349976&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=349976&view=rev</a><br>
Log:<br>
[MC] Enable .file support on COFF and diagnose it on unsupported targets<br>
<br>
Summary:<br>
The "single parameter" .file directive appears to be an ELF-only feature<br>
that is intended to insert the main source filename into the string<br>
table table.<br>
<br>
I noticed that if you assemble an ELF .s file for COFF, typically it<br>
will assert right away on a .file directive near the top of the file. My<br>
first change was to make this emit a proper error in the asm parser so<br>
that we don't assert so easily.<br>
<br>
However, COFF actually does have some support for this directive, and if<br>
you emit an object file, llvm-mc does not assert. When emitting a COFF<br>
object, MC will take those file names and create "debug" symbol table<br>
entries for them. I'm not familiar with these kinds of symbol table<br>
entries, and I'm not aware of any users of them, but @compnerd added<br>
them a while ago. They don't introduce absolute paths, and most main<br>
source file paths are short enough that this extra entry shouldn't cause<br>
any problems, so I enabled the flag in MCAsmInfoCOFF that indicates that<br>
it's supported.<br>
<br>
This has the side effect of adding an extra debug symbol to every object<br>
produced by clang, which is a pretty big functional change. My question<br>
is, should we keep the functionality or remove it in the name of symbol<br>
table minimalism?<br>
<br>
Reviewers: mstorsjo, compnerd<br>
<br>
Subscribers: hiraditya, compnerd, llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D55900" rel="noreferrer" target="_blank">https://reviews.llvm.org/D55900</a><br>
<br>
Added:<br>
    llvm/trunk/test/MC/MachO/file-single.s<br>
Modified:<br>
    llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp<br>
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp<br>
    llvm/trunk/test/MC/COFF/file.s<br>
<br>
Modified: llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp?rev=349976&r1=349975&r2=349976&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp?rev=349976&r1=349975&r2=349976&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp Fri Dec 21 15:35:48 2018<br>
@@ -25,7 +25,7 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() {<br>
   COMMDirectiveAlignmentIsInBytes = false;<br>
   LCOMMDirectiveAlignmentType = LCOMM::ByteAlignment;<br>
   HasDotTypeDotSizeDirective = false;<br>
-  HasSingleParameterDotFile = false;<br>
+  HasSingleParameterDotFile = true;<br>
   WeakRefDirective = "\t.weak\t";<br>
   HasLinkOnceDirective = true;<br>
<br>
<br>
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=349976&r1=349975&r2=349976&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=349976&r1=349975&r2=349976&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Dec 21 15:35:48 2018<br>
@@ -3360,9 +3360,12 @@ bool AsmParser::parseDirectiveFile(SMLoc<br>
     }<br>
   }<br>
<br>
-  if (FileNumber == -1)<br>
+  if (FileNumber == -1) {<br>
+    if (!getContext().getAsmInfo()->hasSingleParameterDotFile())<br>
+      return Error(DirectiveLoc,<br>
+                   "target does not support '.file' without a number");<br>
     getStreamer().EmitFileDirective(Filename);<br>
-  else {<br>
+  } else {<br>
     // In case there is a -g option as well as debug info from directive .file,<br>
     // we turn off the -g option, directly use the existing debug info instead.<br>
     // Also reset any implicit ".file 0" for the assembler source.<br>
<br>
Modified: llvm/trunk/test/MC/COFF/file.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/file.s?rev=349976&r1=349975&r2=349976&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/file.s?rev=349976&r1=349975&r2=349976&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/COFF/file.s (original)<br>
+++ llvm/trunk/test/MC/COFF/file.s Fri Dec 21 15:35:48 2018<br>
@@ -1,6 +1,11 @@<br>
 // RUN: llvm-mc -triple i686-windows -filetype obj %s -o - | llvm-objdump -t - \<br>
 // RUN:   | FileCheck %s<br>
<br>
+// Round trip through .s output to exercise MCAsmStreamer.<br>
+// RUN: llvm-mc -triple i686-windows %s -o - \<br>
+// RUN:   | llvm-mc -triple i686-windows - -filetype=obj -o - | llvm-objdump -t - \<br>
+// RUN:   | FileCheck %s<br>
+<br>
 // RUN: llvm-mc -triple i686-windows -filetype obj %s -o - \<br>
 // RUN:          | llvm-readobj -symbols | FileCheck %s -check-prefix CHECK-SCN<br>
<br>
<br>
Added: llvm/trunk/test/MC/MachO/file-single.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/file-single.s?rev=349976&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/file-single.s?rev=349976&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/MachO/file-single.s (added)<br>
+++ llvm/trunk/test/MC/MachO/file-single.s Fri Dec 21 15:35:48 2018<br>
@@ -0,0 +1,8 @@<br>
+// RUN: not llvm-mc -triple i386-apple-darwin9 %s -o /dev/null 2>&1 | FileCheck %s<br>
+<br>
+// Previously this crashed MC.<br>
+<br>
+// CHECK: error: target does not support '.file' without a number<br>
+<br>
+        .file "dir/foo"<br>
+        nop<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>