aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2016-05-20 15:12:32 +0300
committerseyko <seyko2@gmail.com>2016-05-20 15:12:32 +0300
commit19a169ceb896f78205bc23b847938c58f14d1dda (patch)
tree3bb430b5c22acf6c024749760d522c95c4c92b61 /tcc.c
parent1339d0475954fa2278977562b618d9bab044bc82 (diff)
downloadtinycc-19a169ceb896f78205bc23b847938c58f14d1dda.tar.gz
tinycc-19a169ceb896f78205bc23b847938c58f14d1dda.tar.bz2
--whole-archive support
A patch is implemented as suggested in tinycc-devel mail list. From: Reuben Thomas Date: Thu, 31 Jul 2014 16:52:53 +0100 Subject: [PATCH] Add --{no,}-whole-archive support I resurrected the patch supplied to the mailing list in 2009 Since --whole-archive is a useful flag to get tcc working with autotools, and of course in its own right, I suggest you have a look at the patch and see if it is acceptable. I cannot see any suggestion that it was actively rejected last time round, just no evidence that it was ever added.
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/tcc.c b/tcc.c
index b340d9b..5e0a64a 100644
--- a/tcc.c
+++ b/tcc.c
@@ -247,6 +247,13 @@ static int64_t getclock_us(void)
#endif
}
+static void set_whole_archive(TCCState* s, int on)
+{
+ s->whole_archive = on;
+ if (1 == s->verbose)
+ printf("%cwhole-archive>\n", s->whole_archive? '+' : '-');
+}
+
int main(int argc, char **argv)
{
TCCState *s;
@@ -301,6 +308,14 @@ int main(int argc, char **argv)
for(i = ret = 0; i < s->nb_files && ret == 0; i++) {
int filetype = *(unsigned char *)s->files[i];
const char *filename = s->files[i] + 1;
+ if (filetype == TCC_FILETYPE_AR_WHOLE_ON ||
+ filetype == TCC_FILETYPE_AR_WHOLE_OFF)
+ {
+ set_whole_archive(s, filetype == TCC_FILETYPE_AR_WHOLE_ON);
+ continue;
+ }
+ if (1 == s->verbose)
+ printf("-> %s\n", filename);
if (filename[0] == '-' && filename[1] == 'l') {
if (tcc_add_library(s, filename + 2) < 0) {
/* don't fail on -lm as it's harmless to skip math lib */
@@ -310,8 +325,6 @@ int main(int argc, char **argv)
}
}
} else {
- if (1 == s->verbose)
- printf("-> %s\n", filename);
if (!s->outfile)
s->outfile = default_outputfile(s, filename);
if (tcc_add_file(s, filename, filetype) < 0)
@@ -335,6 +348,7 @@ int main(int argc, char **argv)
}
}
}
+ set_whole_archive(s, 0);
if (0 == ret) {
if (s->output_type == TCC_OUTPUT_MEMORY) {