> It adds -lasan "early", but after the libraries and
> object files that are explicitly added to the linker command.
> Since -lm is explicitly added to the linker command, the implicitly
> added -lasan comes after. The -v command is below.
Hm, -lasan manages to override user-specified -lm on gcc trunk for x64:
$ /tmp/gcc-bootstrap-and-regtest/build-orig/gcc/xgcc
-B/tmp/gcc-bootstrap-and-regtest/build-orig/gcc/
/home/ygribov/src/gcc-master/gcc/testsuite/c-c++-common/asan/asan-interface-1.c
-B/tmp/gcc-bootstrap-and-regtest/build-orig/x86_64-unknown-linux-gnu/./libsanitizer/
-B/tmp/gcc-bootstrap-and-regtest/build-orig/x86_64-unknown-linux-gnu/./libsanitizer/asan/
-L/tmp/gcc-bootstrap-and-regtest/build-orig/x86_64-unknown-linux-gnu/./libsanitizer/asan/.libs
-fsanitize=address -g
-I/home/ygribov/src/gcc-master/gcc/testsuite/../../libsanitizer/include
-fno-diagnostics-show-caret -fdiagnostics-color=never -O0 -lm -o
./asan-interface-1.exe -v
...
/tmp/gcc-bootstrap-and-regtest/build-orig/gcc/collect2 -plugin
/tmp/gcc-bootstrap-and-regtest/build-orig/gcc/liblto_plugin.so
-plugin-opt=/tmp/gcc-bootstrap-and-regtest/build-orig/gcc/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccZD4gPg.res
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -o ./asan-interface-1.exe
/usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o
/tmp/gcc-bootstrap-and-regtest/build-orig/gcc/crtbegin.o
-L/tmp/gcc-bootstrap-and-regtest/build-orig/x86_64-unknown-linux-gnu/./libsanitizer/asan/.libs
-L/tmp/gcc-bootstrap-and-regtest/build-orig/gcc
-L/tmp/gcc-bootstrap-and-regtest/build-orig/x86_64-unknown-linux-gnu/./libsanitizer
-L/tmp/gcc-bootstrap-and-regtest/build-orig/x86_64-unknown-linux-gnu/./libsanitizer/asan
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
/tmp/gcc-bootstrap-and-regtest/build-orig/x86_64-unknown-linux-gnu/./libsanitizer/asan/libasan_preinit.o
-lasan /tmp/ccgt1Kd9.o -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc
-lgcc --as-needed -lgcc_s --no-as-needed
/tmp/gcc-bootstrap-and-regtest/build-orig/gcc/crtend.o
/usr/lib/x86_64-linux-gnu/crtn.o
-Y