Skip to content

Commit

Permalink
Accept pure static libraries without object files as -lib inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Aug 11, 2024
1 parent 6bd5d9a commit f869cf4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dmd/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,8 @@ version (IN_LLVM)
if (global.errors)
fatal();

if (!IN_LLVM && driverParams.lib && params.objfiles.length == 0)
// IN_LLVM: with -lib, accept no object files if there are library files
if (driverParams.lib && params.objfiles.length == 0 && (!IN_LLVM || params.libfiles.length == 0))
{
error(Loc.initial, "no input files");
return EXIT_FAILURE;
Expand Down Expand Up @@ -834,12 +835,11 @@ else
if (global.errors)
fatal();
int status = EXIT_SUCCESS;
if (!params.objfiles.length)
// IN_LLVM: with -lib, accept no object files if there are library files (verified earlier)
if (!params.objfiles.length && (!IN_LLVM || !driverParams.lib))
{
if (driverParams.link)
error(Loc.initial, "no object files to link");
if (IN_LLVM && !driverParams.link && driverParams.lib)
error(Loc.initial, "no object files");
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions tests/driver/merge_static_libs.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %ldc -lib %s -of=%t_1%lib
// RUN: %ldc -lib %s -of=%t_2%lib
// RUN: %ldc -lib %t_1%lib %t_2%lib -of=%t_merged%lib

void foo() {}

0 comments on commit f869cf4

Please sign in to comment.