Skip to content

clang: -shared -fsanitize=undefined doesn't link with libubsan #134504

@stsp

Description

@stsp
$ gcc -shared -o libex.so example.c -fsanitize=undefined
$ ldd libex.so
	linux-vdso.so.1 (0x000079ecce133000)
	libubsan.so.1 => /lib/x86_64-linux-gnu/libubsan.so.1 (0x000079eccda00000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000079eccd600000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x000079eccd200000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x000079ecce0df000)
	/lib64/ld-linux-x86-64.so.2 (0x000079ecce135000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x000079eccd913000)

$ clang -shared -fsanitize=undefined -o libex.so example.c
$ ldd libex.so
	linux-vdso.so.1 (0x000077ad748b4000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000077ad74600000)
	/lib64/ld-linux-x86-64.so.2 (0x000077ad748b6000)

As the result, when used with
-Wl,--no-undefined this breaks
on clang, but works properly with
gcc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions