Q:

How to compile with an another libC on Linux? (gcc)

I want to compile my C program with an another C library like dietlibc or musl.
What gcc option should I use for this purpose?

A:

What gcc option should I use for this purpose?

You should read dietlibc or musl documentation. Example for dietlibc from here:
diet gcc -pipe -g -o t t.c

That is: dietlibc provides a wrapper command called diet which takes care of this for you.
Example for musl from here:
musl-gcc -static -Os hello.c

That is, musl provides a wrapper command called musl-gcc which takes care of this for you.
You can examine musl-gcc and diet to see exactly what options they pass the to the linker. Note however that the exact options may change from version to version, and you are better off always using the wrappers even if you know exactly which flags they pass.

