Allows eg. -Wl,-I/lib/ld-musl-aarch64.so.1,-nostdlib Before, only -Wl,-opt,arg was allowed. Looks like most of the code to do this was already there, maybe this was the original aim and was forgotten. --- libtcc.c | 20 +++++++++++++------- tcc-doc.texi | 3 +++ tcc.c | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/libtcc.c b/libtcc.c index 63da9dfa..5c994a3c 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1316,7 +1316,7 @@ static int link_option(const char *str, const char *val, const char **ptr) if (*str == '-') str++; - /* then str & val should match (potentially up to '=') */ + /* then str & val should match (potentially up to '=' or ',') */ p = str; q = val; @@ -1327,7 +1327,7 @@ static int link_option(const char *str, const char *val, const char **ptr) ret = -1; } - while (*q != '\0' && *q != '=') { + while (!strchr("=,", *q)) { if (*p != *q) return 0; p++; @@ -1341,7 +1341,7 @@ static int link_option(const char *str, const char *val, const char **ptr) if (*p != ',' && *p != '=') return 0; p++; - } else if (*p) { + } else if (*p && *p != ',') { return 0; } *ptr = p; @@ -1445,7 +1445,7 @@ static int tcc_set_linker(TCCState *s, const char *option) copy_linker_arg(&s->elfint, p, 0); } else if (strncmp("-I/", option, 3) == 0 || strncmp("-I.", option, 3) == 0) { - p = option; + p = option + strcspn(option, ","); copy_linker_arg(&s->elfint, option + 2, 0); } else if (link_option(option, "enable-new-dtags", &p)) { s->enable_new_dtags = 1; @@ -1510,9 +1510,15 @@ static int tcc_set_linker(TCCState *s, const char *option) err: return tcc_error_noabort("unsupported linker option '%s'", option); } - if (ignoring) - tcc_warning_c(warn_unsupported)("unsupported linker option '%s'", option); - option = skip_linker_arg(&p); + { + const char * old_option = option; + option = skip_linker_arg(&p); + if (ignoring) { + tcc_warning_c(warn_unsupported)("unsupported linker option '%.*s'", + (int)(p - old_option), old_option); + ignoring = 0; + } + } } return 1; } diff --git a/tcc-doc.texi b/tcc-doc.texi index bcaf30bf..53133d6a 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -357,6 +357,9 @@ Generate an object file combining all input files. @item -nostdlib Don't implicitly link with libc, the C runtime files, and libtcc1. +@item -Wl,-opt1,arg,-opt2 +Pass a comma-separated list of linker options, which may be as follows: + @item -Wl,-nostdlib Don't search the default paths for libraries (@file{/usr/local/lib}, @file{/usr/lib} and @file{/lib}). Only the paths specified with @option{-L} diff --git a/tcc.c b/tcc.c index 84c0944a..6ef88247 100644 --- a/tcc.c +++ b/tcc.c @@ -132,7 +132,7 @@ static const char help2[] = #ifdef TCC_TARGET_X86_64 " no-sse disable floats on x86_64\n" #endif - "-Wl,... linker options:\n" + "-Wl,...,... linker options:\n" " -nostdlib do not search standard library paths\n" " -[no-]whole-archive load lib(s) fully/only as needed\n" " -export-all-symbols same as -rdynamic\n" @@ -154,7 +154,7 @@ static const char help2[] = #if defined(TCC_TARGET_MACHO) " -install_name= set DT_SONAME elf tag (soname macOS alias)\n" #else - " -Ipath, -dynamic-linker=path set ELF interpreter to path" + " -Ipath, -dynamic-linker=path set ELF interpreter to path\n" #endif " -Bsymbolic set DT_SYMBOLIC elf tag\n" " -oformat=[elf32/64-* binary] set executable output format\n" -- 2.48.1 _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel