mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
Process linker directives beginning with a colon
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
eg. -l :crti.o, with the same meaning as for other linkers (search library paths for an exact match) Also clean up some copy/pasting
This commit is contained in:
parent
1747b45649
commit
6ec4a10652
41
libtcc.c
41
libtcc.c
@ -1212,26 +1212,37 @@ ST_FUNC int tcc_add_crt(TCCState *s1, const char *filename)
|
||||
/* the library name is the same as the argument of the '-l' option */
|
||||
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
|
||||
{
|
||||
static const char * const libs[] = {
|
||||
#if defined TCC_TARGET_PE
|
||||
static const char * const libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL };
|
||||
const char * const *pp = s->static_link ? libs + 4 : libs;
|
||||
"%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll",
|
||||
#elif defined TCC_TARGET_MACHO
|
||||
static const char * const libs[] = { "%s/lib%s.dylib", "%s/lib%s.tbd", "%s/lib%s.a", NULL };
|
||||
const char * const *pp = s->static_link ? libs + 2 : libs;
|
||||
"%s/lib%s.dylib", "%s/lib%s.tbd",
|
||||
#elif defined TARGETOS_OpenBSD
|
||||
static const char * const libs[] = { "%s/lib%s.so.*", "%s/lib%s.a", NULL };
|
||||
const char * const *pp = s->static_link ? libs + 1 : libs;
|
||||
"%s/lib%s.so.*",
|
||||
#else
|
||||
static const char * const libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL };
|
||||
const char * const *pp = s->static_link ? libs + 1 : libs;
|
||||
"%s/lib%s.so",
|
||||
#endif
|
||||
int flags = s->filetype & AFF_WHOLE_ARCHIVE;
|
||||
while (*pp) {
|
||||
int ret = tcc_add_library_internal(s, *pp,
|
||||
libraryname, flags, s->library_paths, s->nb_library_paths);
|
||||
if (ret != FILE_NOT_FOUND)
|
||||
return ret;
|
||||
++pp;
|
||||
"%s/lib%s.a",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char * const *pp = s->static_link
|
||||
? libs + sizeof(libs) / sizeof(*libs) - 2
|
||||
: libs;
|
||||
|
||||
/* if libraryname begins with a colon, it means search lib paths for
|
||||
exactly the following file, without lib prefix or anything */
|
||||
if (*libraryname == ':')
|
||||
libraryname++;
|
||||
else {
|
||||
int flags = s->filetype & AFF_WHOLE_ARCHIVE;
|
||||
while (*pp) {
|
||||
int ret = tcc_add_library_internal(s, *pp,
|
||||
libraryname, flags, s->library_paths, s->nb_library_paths);
|
||||
if (ret != FILE_NOT_FOUND)
|
||||
return ret;
|
||||
++pp;
|
||||
}
|
||||
}
|
||||
return tcc_add_dll(s, libraryname, AFF_PRINT_ERROR);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user