On 16/10/15 17:35, Segher Boessenkool wrote:
Hi!
On Fri, Oct 16, 2015 at 04:58:06PM +0100, Szabolcs Nagy wrote:
#if DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
+ "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
#elif DEFAULT_LIBC == LIBC_GLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
+#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
+ "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
+#elif DEFAULT_LIBC == LIBC_MUSL
+#define CHOOSE_DYNAMIC_LINKER(G, U, M) \
+ "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
#else
#error "Unsupported DEFAULT_LIBC"
#endif
This doesn't really scale, I wonder if some more elegant non-quadratic
way is possible? Not that I expect terribly many other libcs to show
up in the near future ;-)
it is also error prone, but it was easier to use the
existing infrastructure than to figure out a clean way..
i guess the macro could be changed to
#define CHOOSE_LD(G,U,M,D) \
"%{mglibc:" G ";:" \
"%{muclibc:" U ";:" \
"%{mmusl:" M ";:" \
D \
"}}}"
where D is the default and then
#if DEFAULT_LIBC == LIBC_UCLIBC
#define DEFAULT_LD UCLIBC_LD
#elif
..
#endif
#define LINUX_LD \
CHOOSE_LD(GLIBC_LD, UCLIBC_LD, MUSL_LD, DEFAULT_LD)
but then the default dynlinker is listed twice
in the expansion of LINUX_LD.
i don't see an easy way to do this -mlibc logic in
the linkspec.