summaryrefslogtreecommitdiff
path: root/src/logic/linkcmd
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-15 04:01:51 +0000
committermidipix <writeonce@midipix.org>2024-02-15 04:01:51 +0000
commit270b467ccfcc14e665acc8706bed0daef99134af (patch)
tree17d0d1b4056b8475c00ccfe61c299bd7bde53028 /src/logic/linkcmd
parent9f995b688efd7bd4d91539c4d82d7bd650d6a213 (diff)
downloadslibtool-270b467ccfcc14e665acc8706bed0daef99134af.tar.bz2
slibtool-270b467ccfcc14e665acc8706bed0daef99134af.tar.xz
link mode: only apply -Wl,--whole-archive to convenience libraries.
Diffstat (limited to 'src/logic/linkcmd')
-rw-r--r--src/logic/linkcmd/slbt_linkcmd_argv.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/logic/linkcmd/slbt_linkcmd_argv.c b/src/logic/linkcmd/slbt_linkcmd_argv.c
index 440be9e..6132b86 100644
--- a/src/logic/linkcmd/slbt_linkcmd_argv.c
+++ b/src/logic/linkcmd/slbt_linkcmd_argv.c
@@ -378,15 +378,26 @@ int slbt_exec_link_adjust_argument_vector(
*aarg++ = *carg++;
} else if (!(strcmp(dot,".a"))) {
- if (flibrary && !fwholearchive)
- *aarg++ = "-Wl,--whole-archive";
+ if (flibrary && !fwholearchive) {
+ strcpy(lib,*carg);
+ dot = strrchr(lib,'.');
+ strcpy(dot,".lai");
+
+ if ((fd = openat(fdcwd,lib,O_RDONLY,0)) < 0)
+ *aarg++ = "-Wl,--whole-archive";
+ }
dpath = lib;
sprintf(lib,"%s.slibtool.deps",*carg);
*aarg++ = *carg++;
- if (flibrary && !fwholearchive)
- *aarg++ = "-Wl,--no-whole-archive";
+ if (flibrary && !fwholearchive) {
+ if (fd < 0) {
+ *aarg++ = "-Wl,--no-whole-archive";
+ } else {
+ close(fd);
+ }
+ }
} else if (strcmp(dot,dctx->cctx->settings.dsosuffix)) {
*aarg++ = *carg++;