diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -627,11 +627,11 @@ void SymtabSection::emitBeginSourceStab(DWARFUnit *compileUnit) { StabsEntry stab(N_SO); SmallString<261> dir(compileUnit->getCompilationDir()); - StringRef sep = sys::path::get_separator(); // We don't use `path::append` here because we want an empty `dir` to result // in an absolute path. `append` would give us a relative path for that case. - if (!dir.endswith(sep)) - dir += sep; + // FIXME: This assumes that the source was compiled on a POSIX machine. + if (!dir.endswith("/")) + dir += "/"; stab.strx = stringTableSection.addString( saver.save(dir + compileUnit->getUnitDIE().getShortName())); stabs.emplace_back(std::move(stab)); diff --git a/lld/test/MachO/stabs.s b/lld/test/MachO/stabs.s --- a/lld/test/MachO/stabs.s +++ b/lld/test/MachO/stabs.s @@ -1,5 +1,4 @@ -# REQUIRES: x86, shell -# UNSUPPORTED: system-windows +# REQUIRES: x86 # RUN: rm -rf %t; split-file %s %t # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o @@ -10,24 +9,28 @@ # RUN: llvm-ar rcsU %t/foo.a %t/foo.o # RUN: %lld -lSystem %t/test.o %t/foo.o %t/no-debug.o -o %t/test -# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o +# RUN: llvm-objdump --section-headers %t/test > %t/out +# RUN: llvm-nm -pa %t/test >> %t/out +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o < %t/out ## Check that we emit the right modtime even when the object file is in an ## archive. # RUN: %lld -lSystem %t/test.o %t/foo.a %t/no-debug.o -o %t/test -# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) +# RUN: llvm-objdump --section-headers %t/test > %t/out +# RUN: llvm-nm -pa %t/test >> %t/out +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) < %t/out ## Check that we emit absolute paths to the object files in our OSO entries ## even if our inputs are relative paths. # RUN: cd %t && %lld -lSystem test.o foo.o no-debug.o -o test -# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o +# RUN: llvm-objdump --section-headers %t/test > %t/out +# RUN: llvm-nm -pa %t/test >> %t/out +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o < %t/out # RUN: cd %t && %lld -lSystem test.o foo.a no-debug.o -o %t/test -# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) +# RUN: llvm-objdump --section-headers %t/test > %t/out +# RUN: llvm-nm -pa %t/test >> %t/out +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) < %t/out # CHECK: Sections: # CHECK-NEXT: Idx Name