Index: lld/trunk/COFF/Config.h =================================================================== --- lld/trunk/COFF/Config.h +++ lld/trunk/COFF/Config.h @@ -179,6 +179,7 @@ bool AppContainer = false; bool MinGW = false; bool WarnLocallyDefinedImported = true; + bool Incremental = true; }; extern Configuration *Config; Index: lld/trunk/COFF/Driver.cpp =================================================================== --- lld/trunk/COFF/Driver.cpp +++ lld/trunk/COFF/Driver.cpp @@ -547,6 +547,12 @@ std::string LibName = getImportName(AsLib); std::string Path = getImplibPath(); + if (!Config->Incremental) { + HandleError(writeImportLibrary(LibName, Path, Exports, Config->Machine, + false, Config->MinGW)); + return; + } + // If the import library already exists, replace it only if the contents // have changed. ErrorOr> OldBuf = MemoryBuffer::getFile(Path); @@ -907,6 +913,7 @@ // Handle /debug if (Args.hasArg(OPT_debug, OPT_debug_dwarf, OPT_debug_ghash)) { Config->Debug = true; + Config->Incremental = true; if (auto *Arg = Args.getLastArg(OPT_debugtype)) Config->DebugTypes = parseDebugType(Arg->getValue()); else @@ -1113,6 +1120,9 @@ Config->AllowBind = Args.hasFlag(OPT_allowbind, OPT_allowbind_no, true); Config->AllowIsolation = Args.hasFlag(OPT_allowisolation, OPT_allowisolation_no, true); + Config->Incremental = + Args.hasFlag(OPT_incremental, OPT_incremental_no, + !Config->DoGC && !Config->DoICF && !Args.hasArg(OPT_order)); Config->NxCompat = Args.hasFlag(OPT_nxcompat, OPT_nxcompat_no, true); Config->TerminalServerAware = Args.hasFlag(OPT_tsaware, OPT_tsaware_no, true); Config->DebugDwarf = Args.hasArg(OPT_debug_dwarf); @@ -1120,6 +1130,23 @@ Config->MapFile = getMapFile(Args); + if (Config->Incremental && Config->DoGC) { + warn("ignoring '/INCREMENTAL' because REF is enabled; use '/OPT:NOREF' to " + "disable"); + Config->Incremental = false; + } + + if (Config->Incremental && Config->DoICF) { + warn("ignoring '/INCREMENTAL' because ICF is enabled; use '/OPT:NOICF' to " + "disable"); + Config->Incremental = false; + } + + if (Config->Incremental && Args.hasArg(OPT_order)) { + warn("ignoring '/INCREMENTAL' due to '/ORDER' specification"); + Config->Incremental = false; + } + if (errorCount()) return; Index: lld/trunk/COFF/Options.td =================================================================== --- lld/trunk/COFF/Options.td +++ lld/trunk/COFF/Options.td @@ -103,6 +103,9 @@ defm highentropyva : B<"highentropyva", "Enable 64-bit ASLR (default on 64-bit)", "Disable 64-bit ASLR">; +defm incremental : B<"incremental", + "Keep original import library if contents are unchanged", + "Replace import library file even if contents are unchanged">; defm largeaddressaware : B<"largeaddressaware", "Enable large addresses (default on 64-bit)", "Disable large addresses (default on 32-bit)">; @@ -148,8 +151,6 @@ def functionpadmin : F<"functionpadmin">; def ignoreidl : F<"ignoreidl">; -def incremental : F<"incremental">; -def no_incremental : F<"incremental:no">; def nologo : F<"nologo">; def throwingnew : F<"throwingnew">; def editandcontinue : F<"editandcontinue">; Index: lld/trunk/test/COFF/incremental.test =================================================================== --- lld/trunk/test/COFF/incremental.test +++ lld/trunk/test/COFF/incremental.test @@ -0,0 +1,66 @@ +# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj +# RUN: lld-link -out:%t.dll -dll %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -incremental %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=WARN-REF %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -incremental %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -debug %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -debug %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=KEEP %s + +# RUN: lld-link -out:%t.dll -dll -debug -incremental:no %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -debug -incremental:no %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -opt:icf %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -opt:icf %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,icf %t.obj 2>&1 \ +# RUN: | FileCheck -check-prefix=WARN-ICF %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,icf %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -debug -opt:icf %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -debug -opt:icf %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -opt:ref %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -opt:ref %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -incremental -opt:ref %t.obj 2>&1 \ +# RUN: | FileCheck -check-prefix=WARN-REF %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -incremental -opt:ref %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -debug -opt:ref %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -debug -opt:ref %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# NOWARN-NOT: ignoring '/INCREMENTAL' +# WARN-ICF: ignoring '/INCREMENTAL' because ICF is enabled; use '/OPT:NOICF' to disable +# WARN-REF: ignoring '/INCREMENTAL' because REF is enabled; use '/OPT:NOREF' to disable +# KEEP: {{Feb 1 1980|1980-02-01}} +# NOKEEP-NOT: {{Feb 1 1980|1980-02-01}} Index: lld/trunk/test/COFF/unchanged-importlib.test =================================================================== --- lld/trunk/test/COFF/unchanged-importlib.test +++ lld/trunk/test/COFF/unchanged-importlib.test @@ -1,7 +0,0 @@ -# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj -# RUN: lld-link -out:%t.dll -dll %t.obj -# RUN: touch -t 198002011200.00 %t.lib -# RUN: lld-link -out:%t.dll -dll %t.obj -# RUN: ls -l %t.lib | FileCheck --check-prefix=CHECK %s - -# CHECK: {{Feb 1 1980|1980-02-01}}