mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-15 20:51:35 +00:00
[COFF] make /incremental control overwriting unchanged import libraries
Summary: r323164 made lld-link not overwrite import libraries when their contents haven't changed. MSVC's link.exe does this only when performing incremental linking. This change makes lld-link's import library overwriting similarly dependent on whether or not incremental linking is being performed. This is controlled by the /incremental or /incremental:no options. In addition, /opt:icf, /opt:ref, and /order turn off /incremental and issue a warning if /incremental was specified on the command line. Reviewers: rnk, ruiu, zturner Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42716 llvm-svn: 323930
This commit is contained in:
parent
7746899f48
commit
5ec448516d
@ -179,6 +179,7 @@ struct Configuration {
|
||||
bool AppContainer = false;
|
||||
bool MinGW = false;
|
||||
bool WarnLocallyDefinedImported = true;
|
||||
bool Incremental = true;
|
||||
};
|
||||
|
||||
extern Configuration *Config;
|
||||
|
@ -547,6 +547,12 @@ static void createImportLibrary(bool AsLib) {
|
||||
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<std::unique_ptr<MemoryBuffer>> OldBuf = MemoryBuffer::getFile(Path);
|
||||
@ -907,6 +913,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
// 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 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
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 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
|
||||
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;
|
||||
|
||||
|
@ -103,6 +103,9 @@ defm fixed : B<"fixed", "Disable base relocations",
|
||||
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 @@ multiclass QB<string name> {
|
||||
|
||||
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">;
|
||||
|
66
lld/test/COFF/incremental.test
Normal file
66
lld/test/COFF/incremental.test
Normal file
@ -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}}
|
@ -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}}
|
Loading…
x
Reference in New Issue
Block a user