From ec5e56b417a69747befea0d373aeff18016433ad Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 14 Dec 2016 17:57:04 -0500 Subject: link mode: create an archive /dev/null symlink placeholder as needed. --- src/internal/slibtool_symlink_impl.c | 5 +++-- src/logic/slbt_exec_link.c | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c index 42185e8..d95beba 100644 --- a/src/internal/slibtool_symlink_impl.c +++ b/src/internal/slibtool_symlink_impl.c @@ -12,8 +12,9 @@ #include "slibtool_errinfo_impl.h" #include "slibtool_symlink_impl.h" -#define SLBT_DEV_NULL_FLAGS (SLBT_DRIVER_ALL_STATIC \ - | SLBT_DRIVER_DISABLE_SHARED) +#define SLBT_DEV_NULL_FLAGS (SLBT_DRIVER_ALL_STATIC \ + | SLBT_DRIVER_DISABLE_SHARED \ + | SLBT_DRIVER_DISABLE_STATIC) int slbt_create_symlink( const struct slbt_driver_ctx * dctx, diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index 3aa9d2f..8691760 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -786,6 +786,31 @@ static int slbt_exec_link_create_import_library( return 0; } +static int slbt_exec_link_create_noop_symlink( + const struct slbt_driver_ctx * dctx, + struct slbt_exec_ctx * ectx, + const char * arfilename) +{ + struct stat st; + + /* file exists? */ + if (!(lstat(arfilename,&st))) + return 0; + + /* needed? */ + if (errno == ENOENT) { + if (slbt_create_symlink( + dctx,ectx, + "/dev/null", + arfilename, + false)) + return SLBT_NESTED_ERROR(dctx); + return 0; + } + + return SLBT_SYSTEM_ERROR(dctx); +} + static int slbt_exec_link_create_archive( const struct slbt_driver_ctx * dctx, struct slbt_exec_ctx * ectx, @@ -807,7 +832,8 @@ static int slbt_exec_link_create_archive( /* -disable-static? */ if (dctx->cctx->drvflags & SLBT_DRIVER_DISABLE_STATIC) if (dctx->cctx->rpath) - return 0; + return slbt_exec_link_create_noop_symlink( + dctx,ectx,arfilename); /* initial state */ slbt_reset_arguments(ectx); -- cgit v1.2.3