https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77267
Bug ID: 77267 Summary: MPX does not work in a presence of "-Wl,-as-needed" option (Ubuntu default) Product: gcc Version: 6.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: aivchenk at gmail dot com Target Milestone: --- When compiling with -Wl,-as-needed libmpx.so and libmpxwrappers.so are not linked: >gcc -fcheck-pointer-bounds -mmpx any_mpx_test.c -Wl,-as-needed > ldd a.out linux-vdso.so.1 (0x00007ffc687a0000) libc.so.6 => /lib64/libc.so.6 (0x00000035c8c00000) /lib64/ld-linux-x86-64.so.2 (0x000055e88586f000) And hence, MPX does not work. (In a working scenario it should be like that: > ldd a.out linux-vdso.so.1 (0x00007fff53fe7000) libmpx.so.0 => /lib64/libmpx.so.0 (0x00007f135ac34000) libmpxwrappers.so.0 => /lib64/libmpxwrappers.so.0 (0x00007f135aa31000) libc.so.6 => /lib64/libc.so.6 (0x00000035c8c00000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00000035c9400000) /lib64/ld-linux-x86-64.so.2 (0x0000558619680000) ) This case is important because on Debian/Ubuntu -no-as-needed option is always implicitly added while linking.