Index: lld/MachO/Config.h =================================================================== --- lld/MachO/Config.h +++ lld/MachO/Config.h @@ -133,6 +133,8 @@ SymbolPatterns exportedSymbols; SymbolPatterns unexportedSymbols; + bool writeModTimeToDebugInfo = true; + llvm::MachO::Architecture arch() const { return platformInfo.target.Arch; } llvm::MachO::PlatformKind platform() const { Index: lld/MachO/Driver.cpp =================================================================== --- lld/MachO/Driver.cpp +++ lld/MachO/Driver.cpp @@ -986,6 +986,9 @@ config->emitFunctionStarts = !args.hasArg(OPT_no_function_starts); config->emitBitcodeBundle = args.hasArg(OPT_bitcode_bundle); + // FIXME: Add a commandline flag for this too. + config->writeModTimeToDebugInfo = !getenv("ZERO_AR_DATE"); + std::array encryptablePlatforms{ PlatformKind::iOS, PlatformKind::watchOS, PlatformKind::tvOS}; config->emitEncryptionInfo = Index: lld/MachO/DriverUtils.cpp =================================================================== --- lld/MachO/DriverUtils.cpp +++ lld/MachO/DriverUtils.cpp @@ -280,6 +280,9 @@ } uint32_t macho::getModTime(StringRef path) { + if (!config->writeModTimeToDebugInfo) + return 0; + fs::file_status stat; if (!fs::status(path, stat)) if (fs::exists(stat)) Index: lld/test/MachO/stabs.s =================================================================== --- lld/test/MachO/stabs.s +++ lld/test/MachO/stabs.s @@ -11,23 +11,34 @@ # RUN: %lld -lSystem %t/test.o %t/foo.o %t/no-debug.o -o %t/test # RUN: (llvm-objdump --section-headers %t/test; dsymutil -s %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o \ +# RUN: -DTEST_TIME=0000000000000010 -DFOO_TIME=0000000000000020 ## 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; dsymutil -s %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) \ +# RUN: -DTEST_TIME=0000000000000010 -DFOO_TIME=0000000000000020 + +## Check that we don't emit modtimes if ZERO_AR_DATE is set. +# RUN: env ZERO_AR_DATE=1 %lld -lSystem %t/test.o %t/foo.o %t/no-debug.o \ +# RUN: -o %t/test +# RUN: (llvm-objdump --section-headers %t/test; dsymutil -s %t/test) | \ +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o \ +# RUN: -DTEST_TIME=0000000000000000 -DFOO_TIME=0000000000000000 ## 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; dsymutil -s %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o \ +# RUN: -DTEST_TIME=0000000000000010 -DFOO_TIME=0000000000000020 # RUN: cd %t && %lld -lSystem test.o foo.a no-debug.o -o %t/test # RUN: (llvm-objdump --section-headers %t/test; dsymutil -s %t/test) | \ -# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) +# RUN: FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\) \ +# RUN: -DTEST_TIME=0000000000000010 -DFOO_TIME=0000000000000020 # CHECK: Sections: # CHECK-NEXT: Idx Name @@ -38,7 +49,7 @@ # CHECK-NEXT: [[#MORE_TEXT_ID:]] more_text # CHECK: (N_SO ) 00 0000 0000000000000000 '/tmp/test.cpp' -# CHECK-NEXT: (N_OSO ) 03 0001 0000000000000010 '[[DIR]]/test.o' +# CHECK-NEXT: (N_OSO ) 03 0001 [[TEST_TIME]] '[[DIR]]/test.o' # CHECK-NEXT: (N_STSYM ) [[#%.2d,MORE_DATA_ID + 1]] 0000 [[#%.16x,STATIC:]] '_static_var' # CHECK-NEXT: (N_FUN ) [[#%.2d,TEXT_ID + 1]] 0000 [[#%.16x,MAIN:]] '_main' # CHECK-NEXT: (N_FUN ) 00 0000 0000000000000006{{$}} @@ -60,7 +71,7 @@ # CHECK-NEXT: (N_FUN ) 00 0000 0000000000000001{{$}} # CHECK-NEXT: (N_SO ) 01 0000 0000000000000000{{$}} # CHECK-NEXT: (N_SO ) 00 0000 0000000000000000 '/foo.cpp' -# CHECK-NEXT: (N_OSO ) 03 0001 0000000000000020 '[[FOO_PATH]]' +# CHECK-NEXT: (N_OSO ) 03 0001 [[FOO_TIME]] '[[FOO_PATH]]' # CHECK-NEXT: (N_FUN ) [[#%.2d,TEXT_ID + 1]] 0000 [[#%.16x,FOO:]] '_foo' # CHECK-NEXT: (N_FUN ) 00 0000 0000000000000001{{$}} # CHECK-NEXT: (N_SO ) 01 0000 0000000000000000{{$}}