https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98165
Bug ID: 98165 Summary: Use of the UB sanitizer links the the program with libstdc++ Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: bruno at clisp dot org CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- I would like to use the 'signed-integer-overflow' sanitizer (part of the undefined behaviour sanitizer) for all my C programs, as a security measure. However, doing so with GCC causes a link dependency towards libstdc++: $ gcc -Wall -fsanitize=signed-integer-overflow foo.c $ ldd ./a.out linux-vdso.so.1 (0x00007ffc73977000) libubsan.so.1 => /lib/x86_64-linux-gnu/libubsan.so.1 (0x00007fbec9aa0000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbec98b6000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbec98b0000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbec988e000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbec96ad000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbec9692000) /lib64/ld-linux-x86-64.so.2 (0x00007fbeca42a000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbec9541000) I don't want this, because libstdc++ increases the startup time of programs (from ca. 2 ms to ca. 7 ms). This is with gcc 10.2.0. With clang 11.0.0, I don't have this problem: $ clang -fsanitize=signed-integer-overflow foo.c $ ldd ./a.out linux-vdso.so.1 => (0x00007fffc25e3000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5fc1486000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5fc127e000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5fc0f75000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5fc0d71000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5fc0b5b000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5fc0791000) /lib64/ld-linux-x86-64.so.2 (0x00007f5fc16a3000)